Add files via upload

This commit is contained in:
MvsCode
2024-06-17 18:15:50 +08:00
committed by GitHub
parent 4007b40ad8
commit 70d01413e9
2 changed files with 86 additions and 60 deletions

View File

@@ -6,12 +6,12 @@
[![Stars][stars-shield]][stars-url]
[![Forks][forks-shield]][forks-url]
[repo-shield]: https://img.shields.io/badge/GitHub-MvsCode%2Ffrps--onekey-brightgreen?style=flat-square&logo=github
[repo-url]: https://github.com/MvsCode/frps-onekey
[stars-shield]: https://img.shields.io/github/stars/MvsCode/frps-onekey.svg?style=flat-square&logo=github&color=yellow
[stars-url]: https://github.com/MvsCode/frps-onekey/stargazers
[forks-shield]: https://img.shields.io/github/forks/MvsCode/frps-onekey.svg?style=flat-square&logo=github&color=green
[forks-url]: https://github.com/MvsCode/frps-onekey/network/members
[repo-shield]: https://img.shields.io/badge/GitHub-mvscode%2Ffrps--onekey-brightgreen?style=flat-square&logo=github
[repo-url]: https://github.com/mvscode/frps-onekey
[stars-shield]: https://img.shields.io/github/stars/mvscode/frps-onekey.svg?style=flat-square&logo=github&color=yellow
[stars-url]: https://github.com/mvscode/frps-onekey/stargazers
[forks-shield]: https://img.shields.io/github/forks/mvscode/frps-onekey.svg?style=flat-square&logo=github&color=green
[forks-url]: https://github.com/mvscode/frps-onekey/network/members
*Frp 是一个高性能的反向代理应用,可以帮助您轻松地进行内网穿透,对外网提供服务,支持 tcp, http, https 等协议类型,并且 web 服务支持根据域名进行路由转发。*
@@ -76,5 +76,17 @@ Usage: /etc/init.d/frps {start|stop|restart|status|config|version}
#### Changed
* Change curl common to get server ip from wget common
### [1.0.4] - 2024-06-17
#### Update
* Add trace option at log level
* Update shell update function
#### Changed
* Change curl common to get server ip from wget common

View File

@@ -7,7 +7,7 @@ export PATH
# Set environment variables
export FRPS_VER="$LATEST_RELEASE"
export FRPS_VER_32BIT="$LATEST_RELEASE"
export FRPS_INIT="https://raw.githubusercontent.com/mvsCode/frps-onekey/master/frps.init"
export FRPS_INIT="https://raw.githubusercontent.com/mvscode/frps-onekey/master/frps.init"
export gitee_download_url="https://gitee.com/mvscode/frps-onekey/releases/download"
export github_download_url="https://github.com/fatedier/frp/releases/download"
export gitee_latest_version_api="https://gitee.com/api/v5/repos/mvscode/frps-onekey/releases/latest"
@@ -15,7 +15,7 @@ export github_latest_version_api="https://api.github.com/repos/fatedier/frp/rele
# Program information
program_name="frps"
version="1.0.3"
version="1.0.4"
str_program_dir="/usr/local/${program_name}"
program_init="/etc/init.d/${program_name}"
program_config_file="frps.toml"
@@ -31,38 +31,48 @@ shell_update() {
echo "Checking for shell updates..."
# Fetch the remote shell version from the specified URL
remote_shell_version=$(wget --no-check-certificate -qO- "${str_install_shell}" | sed -n '/^version/p' | cut -d'"' -f2)
remote_shell_version=$(wget --no-check-certificate -qO- "${str_install_shell}"| sed -n '/^version/p' | cut -d'"' -f2)
# Check if the remote shell version is not empty
if [ -n "${remote_shell_version}" ]; then
# Check if the local version is different from the remote version
if [[ "${version}" != "${remote_shell_version}" ]]; then
# Echo a message to indicate that a new version has been found
echo -e "${COLOR_GREEN}Found a new version, updating now!${COLOR_END}"
# Check if the remote version is greater than the local version
if version_gt "${remote_shell_version}" "${version}"; then
# Echo a message to indicate the old and new versions
echo -e "${COLOR_GREEN}Found a new version. Current version: ${version}, New version: ${remote_shell_version}${COLOR_END}"
echo
# Echo a message to indicate that we're updating the shell
echo -n "Updating shell..."
# Ask the user if they want to update
read -p "Do you want to update to version ${remote_shell_version}? (y/n) " choice
case "$choice" in
y|Y)
# Download the new version
echo "Downloading the new version..."
if ! wget --no-check-certificate -qO "$0" "${str_install_shell}"; then
echo -e "${COLOR_RED}Failed to download the new version.${COLOR_END}"
return 1
fi
# Attempt to download the new version and overwrite the current script
if ! wget --no-check-certificate -qO "$0" "${str_install_shell}"; then
# Echo a message to indicate that the update failed
echo -e " [${COLOR_RED}failed${COLOR_END}]"
echo
exit 1
else
# Echo a message to indicate that the update was successful
echo -e " [${COLOR_GREEN}OK${COLOR_END}]"
echo
# Echo a message to instruct the user to re-run the script
echo -e "${COLOR_GREEN}Please re-run${COLOR_END} ${COLOR_PINK}$0 ${frps_action}${COLOR_END}"
echo
exit 1
fi
exit 1
# Update the script
echo "Updating the script..."
chmod +x "${str_install_shell}"
"${str_install_shell}" update
;;
n|N)
echo "Skipping update."
;;
*)
echo "Invalid choice. Skipping update."
;;
esac
else
echo "You are running the latest version."
fi
fi
}
# Function to compare two version strings
version_gt() {
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"
}
fun_frps(){
local clear_flag=""
clear_flag=$1
@@ -438,35 +448,39 @@ pre_install_frps(){
[ -n "${input_number}" ] && set_max_pool_count="${input_number}"
echo -e "${program_name} max_pool_count: ${COLOR_YELOW}${set_max_pool_count}${COLOR_END}"
echo -e ""
echo -e "Please select ${COLOR_GREEN}log_level${COLOR_END}"
echo "1: info (default)"
echo "2: warn"
echo "3: error"
echo "4: debug"
echo "-------------------------"
read -e -p "Enter your choice (1, 2, 3, 4 or exit. default [1]): " str_log_level
case "${str_log_level}" in
1|[Ii][Nn][Ff][Oo])
str_log_level="info"
;;
2|[Ww][Aa][Rr][Nn])
str_log_level="warn"
;;
3|[Ee][Rr][Rr][Oo][Rr])
str_log_level="error"
;;
4|[Dd][Ee][Bb][Uu][Gg])
str_log_level="debug"
;;
[eE][xX][iI][tT])
exit 1
;;
*)
str_log_level="info"
;;
esac
echo -e "log_level: ${COLOR_YELOW}${str_log_level}${COLOR_END}"
echo -e ""
echo -e "Please select ${COLOR_GREEN}log_level${COLOR_END}"
echo "1: info (default)"
echo "2: warn"
echo "3: error"
echo "4: debug"
echo "5: trace"
echo "-------------------------"
read -e -p "Enter your choice (1, 2, 3, 4, 5 or exit. default [1]): " str_log_level
case "${str_log_level}" in
1|[Ii][Nn][Ff][Oo])
str_log_level="info"
;;
2|[Ww][Aa][Rr][Nn])
str_log_level="warn"
;;
3|[Ee][Rr][Rr][Oo][Rr])
str_log_level="error"
;;
4|[Dd][Ee][Bb][Uu][Gg])
str_log_level="debug"
;;
5|[Tt][Rr][Aa][Cc][Ee])
str_log_level="trace"
;;
[eE][xX][iI][tT])
exit 1
;;
*)
str_log_level="info"
;;
esac
echo -e "log_level: ${COLOR_YELOW}${str_log_level}${COLOR_END}"
echo -e ""
fun_input_log_max_days
[ -n "${input_number}" ] && set_log_max_days="${input_number}"
echo -e "${program_name} log_max_days: ${COLOR_YELOW}${set_log_max_days}${COLOR_END}"