Add files via upload

This commit is contained in:
mvscode
2024-06-25 15:56:05 +08:00
committed by GitHub
parent 178492d97b
commit 27f8e57933
3 changed files with 115 additions and 75 deletions

View File

@@ -52,10 +52,43 @@ Usage: /etc/init.d/frps {start|stop|restart|status|config|version}
## Script ChangeLog ## Script ChangeLog
--------------------------------------- ---------------------------------------
### [1.0.1] - 2024-06-07 ### [1.0.6] - 2024-06-25
#### Added
* Add new server os to support, RHEL,Rocky,AlmaLinux OS.
* Add new server os on frps.init file
#### Fixed
* fix check server os version script bug
### [1.0.5] - 2024-06-19
#### Added
* Add quic of transport protocol support,server port default same as https port.
* Add user-defined functions for the kcp bind port,server port default same as bind port.
#### Fixed
* Fix the script under frps server start faild still install complete bug.
### [1.0.4] - 2024-06-18
#### Updated
* Add trace option at log level, default is info
* Update shell update function, ask the user if they want to update
#### New
* frps support transport heartbeatTimeout = 90, default is enable
### [1.0.3] - 2024-06-16
#### Amendment
* Amend function name to frps
#### Changed #### Changed
* frps program config file change to frps.toml from frps.int * Change curl common to get server ip from wget common
### [1.0.2] - 2024-06-13 ### [1.0.2] - 2024-06-13
@@ -68,34 +101,18 @@ Usage: /etc/init.d/frps {start|stop|restart|status|config|version}
etc.. etc..
``` ```
### [1.0.3] - 2024-06-16 ### [1.0.1] - 2024-06-07
#### Amendment
* Amend function name to frps
#### Changed #### Changed
* Change curl common to get server ip from wget common * frps program config file change to frps.toml from frps.int
### [1.0.4] - 2024-06-18
#### Updated
* Add trace option at log level, default is info
* Update shell update function, ask the user if they want to update
#### New
* frps support transport heartbeatTimeout = 90, default is enable
### [1.0.5] - 2024-06-19
#### ADDED
* Add quic of transport protocol support,server port default same as https port.
* Add user-defined functions for the kcp bind port,server port default same as bind port.
#### Fixed
* Fix the script under frps server start faild still install complete bug.

View File

@@ -19,19 +19,19 @@
### END INIT INFO ### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
ProgramName="Frps" ProgramName="frps"
ProgramPath="/usr/local/frps" ProgramPath="/usr/local/frps"
NAME=frps NAME=frps
BIN=${ProgramPath}/${NAME} BIN=${ProgramPath}/${NAME}
CONFIGFILE=${ProgramPath}/frps.toml CONFIGFILE=${ProgramPath}/frps.toml
SCRIPTNAME=/etc/init.d/${NAME} SCRIPTNAME=/etc/init.d/${NAME}
version="2023" version="2024"
program_version=`${BIN} --version` program_version=`${BIN} --version`
RET_VAL=0 RET_VAL=0
[ -x ${BIN} ] || exit 0 [ -x ${BIN} ] || exit 0
strLog="" strLog=""
fun_clangcn() fun_frps()
{ {
echo "" echo ""
echo "+---------------------------------------------------------+" echo "+---------------------------------------------------------+"
@@ -57,7 +57,7 @@ fun_load_config(){
fun_start() fun_start()
{ {
if [ "${arg1}" = "start" ]; then if [ "${arg1}" = "start" ]; then
fun_clangcn fun_frps
fi fi
if fun_check_run; then if fun_check_run; then
echo "${ProgramName} (pid $PID) already running." echo "${ProgramName} (pid $PID) already running."
@@ -78,7 +78,7 @@ fun_start()
fun_stop(){ fun_stop(){
if [ "${arg1}" = "stop" ] || [ "${arg1}" = "restart" ]; then if [ "${arg1}" = "stop" ] || [ "${arg1}" = "restart" ]; then
fun_clangcn fun_frps
fi fi
if fun_check_run; then if fun_check_run; then
echo -n "Stoping ${ProgramName} (pid $PID)... " echo -n "Stoping ${ProgramName} (pid $PID)... "
@@ -108,19 +108,23 @@ fun_status(){
fi fi
} }
checkos(){ checkos(){
if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OS=CentOS OS=CentOS
elif grep -Eqi "Red Hat Enterprise Linux" /etc/issue || grep -Eq "Red Hat Enterprise Linux" /etc/*-release; then
OS=RHEL
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OS=Fedora
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
OS=Rocky
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then
OS=AlmaLinux
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OS=Debian OS=Debian
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OS=Ubuntu OS=Ubuntu
elif grep -Eqi "Alpine" /etc/issue || grep -Eq "Alpine" /etc/*-release; then
OS=Alpine
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OS=Fedora
else else
echo "Not support OS, Please reinstall OS and retry!" echo "Unsupported OS. Please use a supported Linux distribution and retry!"
return 1 exit 1
fi fi
} }
fun_config(){ fun_config(){
@@ -156,7 +160,7 @@ case "${arg1}" in
fun_help fun_help
;; ;;
*) *)
fun_clangcn fun_frps
echo "Usage: $SCRIPTNAME {start|stop|restart|status|config|version}" echo "Usage: $SCRIPTNAME {start|stop|restart|status|config|version}"
RET_VAL=1 RET_VAL=1
;; ;;

View File

@@ -15,7 +15,7 @@ export github_latest_version_api="https://api.github.com/repos/fatedier/frp/rele
# Program information # Program information
program_name="frps" program_name="frps"
version="1.0.5" version="1.0.6"
str_program_dir="/usr/local/${program_name}" str_program_dir="/usr/local/${program_name}"
program_init="/etc/init.d/${program_name}" program_init="/etc/init.d/${program_name}"
program_config_file="frps.toml" program_config_file="frps.toml"
@@ -81,7 +81,7 @@ fun_frps(){
fi fi
echo "" echo ""
echo "+------------------------------------------------------------+" echo "+------------------------------------------------------------+"
echo "| frps for Linux Server, Author Clang Mender MvsCode |" echo "| frps for Linux Server, Author Clang, Mender MvsCode |"
echo "| A tool to auto-compile & install frps on Linux |" echo "| A tool to auto-compile & install frps on Linux |"
echo "+------------------------------------------------------------+" echo "+------------------------------------------------------------+"
echo "" echo ""
@@ -113,38 +113,55 @@ get_char(){
stty echo stty echo
stty $SAVEDSTTY stty $SAVEDSTTY
} }
# Check OS # Check Server OS
checkos(){ checkos(){
if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OS=CentOS OS=CentOS
elif grep -Eqi "Red Hat Enterprise Linux" /etc/issue || grep -Eq "Red Hat Enterprise Linux" /etc/*-release; then
OS=RHEL
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OS=Fedora
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
OS=Rocky
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then
OS=AlmaLinux
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OS=Debian OS=Debian
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OS=Ubuntu OS=Ubuntu
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OS=Fedora
else else
echo "Not support OS, Please reinstall OS and retry!" echo "Unsupported OS. Please use a supported Linux distribution and retry!"
exit 1 exit 1
fi fi
} }
# Get version # Get version
getversion(){ getversion(){
if [[ -s /etc/redhat-release ]];then local version
grep -oE "[0-9.]+" /etc/redhat-release if [[ -f /etc/os-release ]]; then
source /etc/os-release
version="$VERSION_ID"
elif [[ -f /etc/redhat-release ]]; then
version=$(grep -oE "[0-9.]+" /etc/redhat-release)
else else
grep -oE "[0-9.]+" /etc/issue version=$(grep -oE "[0-9.]+" /etc/issue)
fi
if [[ -z "$version" ]]; then
echo "Unable to determine version" >&2
return 1
else
echo "$version"
fi fi
} }
# CentOS version # Check server os version
centosversion(){ check_os_version(){
local code=$1 local required_version=$1
local version="`getversion`" local current_version=$(getversion)
local main_ver=${version%%.*}
if [ $main_ver == $code ];then if [[ "$(echo -e "$current_version\n$required_version" | sort -V | head -n1)" == "$required_version" ]]; then
return 0 return 0 # when current version > required version
else else
return 1 return 1 # when current version < required version
fi fi
} }
# Check OS bit # Check OS bit
@@ -165,12 +182,6 @@ check_os_bit() {
*) echo "Unknown architecture";; *) echo "Unknown architecture";;
esac esac
} }
check_centosversion(){
if centosversion 5; then
echo "Not support CentOS 5.x, please change to CentOS 6,7 or Debian or Ubuntu or Fedora and try again."
exit 1
fi
}
# Disable selinux # Disable selinux
disable_selinux(){ disable_selinux(){
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
@@ -413,26 +424,30 @@ fun_input_quic_bind_port(){
pre_install_frps(){ pre_install_frps(){
fun_frps fun_frps
echo -e "Check your server setting, please wait..." echo -e "Check your server setting, please wait..."
echo ""
disable_selinux disable_selinux
# Check if the frps service is already running # Check if the frps service is already running
if pgrep -x "${program_name}" >/dev/null; then if pgrep -x "${program_name}" >/dev/null; then
echo -e "${COLOR_GREEN}${program_name} is already installed and running.${COLOR_END}" echo -e "${COLOR_GREEN}${program_name} is already installed and running.${COLOR_END}"
else else
echo -e "${COLOR_YELLOW}${program_name} is not running or not install.${COLOR_END}" echo -e "${COLOR_YELOW}${program_name} is not running or not install.${COLOR_END}"
echo "" echo ""
read -p "Do you want to re-install ${program_name}? (y/n) " choice read -p "Do you want to re-install ${program_name}? (y/n) " choice
echo "" echo ""
case "$choice" in case "$choice" in
y|Y) y|Y)
echo "Re-installing ${program_name}..." echo -e "${COLOR_GREEN} Re-installing ${program_name}...${COLOR_END}"
install_frps
;; ;;
n|N) n|N)
echo "Skipping installation." echo -e "${COLOR_YELOW} Skipping installation.${COLOR_END}"
echo ""
exit 1
;; ;;
*) *)
echo "Invalid choice. Skipping installation." echo -e "${COLOR_YELOW}Invalid choice. Skipping installation. ${COLOR_END}"
echo ""
exit 1
;; ;;
esac esac
clear clear
@@ -613,14 +628,14 @@ else
echo -e "Dashboard password : ${COLOR_GREEN}${set_dashboard_pwd}${COLOR_END}" echo -e "Dashboard password : ${COLOR_GREEN}${set_dashboard_pwd}${COLOR_END}"
echo -e "token : ${COLOR_GREEN}${set_token}${COLOR_END}" echo -e "token : ${COLOR_GREEN}${set_token}${COLOR_END}"
echo -e "subdomain_host : ${COLOR_GREEN}${set_subdomain_host}${COLOR_END}" echo -e "subdomain_host : ${COLOR_GREEN}${set_subdomain_host}${COLOR_END}"
echo -e "tcp_mux : ${COLOR_GREEN}${set_tcp_mux}${COLOR_END}" echo -e "tcp mux : ${COLOR_GREEN}${set_tcp_mux}${COLOR_END}"
echo -e "Max Pool count : ${COLOR_GREEN}${set_max_pool_count}${COLOR_END}" echo -e "Max Pool count : ${COLOR_GREEN}${set_max_pool_count}${COLOR_END}"
echo -e "Log level : ${COLOR_GREEN}${str_log_level}${COLOR_END}" echo -e "Log level : ${COLOR_GREEN}${str_log_level}${COLOR_END}"
echo -e "Log max days : ${COLOR_GREEN}${set_log_max_days}${COLOR_END}" echo -e "Log max days : ${COLOR_GREEN}${set_log_max_days}${COLOR_END}"
echo -e "Log file : ${COLOR_GREEN}${str_log_file_flag}${COLOR_END}" echo -e "Log file : ${COLOR_GREEN}${str_log_file_flag}${COLOR_END}"
echo -e "transport protocol : ${COLOR_GREEN}${set_transport_protocol}${COLOR_END}" echo -e "transport protocol : ${COLOR_GREEN}${set_transport_protocol}${COLOR_END}"
echo -e "kcp bind port : ${COLOR_GREEN}${set_kcp_bind_port}${COLOR_END}" echo -e "kcp bind port : ${COLOR_GREEN}${set_kcp_bind_port}${COLOR_END}"
echo -e "quic bind port : ${COLOR_GREEN}${set_quic_bind_port}${COLOR_END}" echo -e "quic bind port : ${COLOR_GREEN}${set_quic_bind_port}${COLOR_END}"
echo "==============================================" echo "=============================================="
echo "" echo ""
echo "Press any key to start...or Press Ctrl+c to cancel" echo "Press any key to start...or Press Ctrl+c to cancel"
@@ -789,7 +804,9 @@ EOF
echo " done" echo " done"
echo -n "setting ${program_name} boot..." echo -n "setting ${program_name} boot..."
[ ! -x ${program_init} ] && chmod +x ${program_init} [ ! -x ${program_init} ] && chmod +x ${program_init}
if [ "${OS}" == 'CentOS' ]; then if [ "${OS}" == 'CentOS' ]; then
chmod +x ${program_init} chmod +x ${program_init}
chkconfig --add ${program_name} chkconfig --add ${program_name}
@@ -797,8 +814,10 @@ EOF
chmod +x ${program_init} chmod +x ${program_init}
update-rc.d -f ${program_name} defaults update-rc.d -f ${program_name} defaults
fi fi
echo " done" echo " done"
[ -s ${program_init} ] && ln -s ${program_init} /usr/bin/${program_name}
[ -s ${program_init} ] && ln -sf ${program_init} /usr/bin/${program_name}
# Start the frps service # Start the frps service
${program_init} start ${program_init} start
@@ -842,17 +861,17 @@ fi
echo -e "vhost https port : ${COLOR_GREEN}${set_vhost_https_port}${COLOR_END}" echo -e "vhost https port : ${COLOR_GREEN}${set_vhost_https_port}${COLOR_END}"
echo -e "token : ${COLOR_GREEN}${set_token}${COLOR_END}" echo -e "token : ${COLOR_GREEN}${set_token}${COLOR_END}"
echo -e "subdomain_host : ${COLOR_GREEN}${set_subdomain_host}${COLOR_END}" echo -e "subdomain_host : ${COLOR_GREEN}${set_subdomain_host}${COLOR_END}"
echo -e "tcp_mux : ${COLOR_GREEN}${set_tcp_mux}${COLOR_END}" echo -e "tcp mux : ${COLOR_GREEN}${set_tcp_mux}${COLOR_END}"
echo -e "Max Pool count : ${COLOR_GREEN}${set_max_pool_count}${COLOR_END}" echo -e "Max Pool count : ${COLOR_GREEN}${set_max_pool_count}${COLOR_END}"
echo -e "Log level : ${COLOR_GREEN}${str_log_level}${COLOR_END}" echo -e "Log level : ${COLOR_GREEN}${str_log_level}${COLOR_END}"
echo -e "Log max days : ${COLOR_GREEN}${set_log_max_days}${COLOR_END}" echo -e "Log max days : ${COLOR_GREEN}${set_log_max_days}${COLOR_END}"
echo -e "Log file : ${COLOR_GREEN}${str_log_file_flag}${COLOR_END}" echo -e "Log file : ${COLOR_GREEN}${str_log_file_flag}${COLOR_END}"
echo -e "transport protocol : ${COLOR_GREEN}${set_transport_protocol}${COLOR_END}" echo -e "transport protocol : ${COLOR_GREEN}${set_transport_protocol}${COLOR_END}"
echo -e "kcp bind port : ${COLOR_GREEN}${set_kcp_bind_port}${COLOR_END}" echo -e "kcp bind port : ${COLOR_GREEN}${set_kcp_bind_port}${COLOR_END}"
echo -e "quic bind port : ${COLOR_GREEN}${set_quic_bind_port}${COLOR_END}" echo -e "quic bind port : ${COLOR_GREEN}${set_quic_bind_port}${COLOR_END}"
echo "================================================" echo "================================================"
echo -e "${program_name} Dashboard : ${COLOR_GREEN}http://${set_subdomain_host}:${set_dashboard_port}/${COLOR_END}" echo -e "${program_name} Dashboard : ${COLOR_GREEN}http://${set_subdomain_host}:${set_dashboard_port}/${COLOR_END}"
echo -e "Dashboard port : ${COLOR_GREEN}${set_dashboard_port}${COLOR_END}" echo -e "Dashboard port : ${COLOR_GREEN}${set_dashboard_port}${COLOR_END}"
echo -e "Dashboard user : ${COLOR_GREEN}${set_dashboard_user}${COLOR_END}" echo -e "Dashboard user : ${COLOR_GREEN}${set_dashboard_user}${COLOR_END}"
echo -e "Dashboard password : ${COLOR_GREEN}${set_dashboard_pwd}${COLOR_END}" echo -e "Dashboard password : ${COLOR_GREEN}${set_dashboard_pwd}${COLOR_END}"
echo "================================================" echo "================================================"
@@ -1015,7 +1034,7 @@ update_program_server_frps() {
echo "============== Update $program_name ==============" echo "============== Update $program_name =============="
update_config_frps update_config_frps
checkos checkos
check_centosversion check_os_version
check_os_bit check_os_bit
fun_getVer fun_getVer
@@ -1077,7 +1096,7 @@ strPath=$(pwd)
rootness rootness
fun_set_text_color fun_set_text_color
checkos checkos
check_centosversion check_os_version
check_os_bit check_os_bit
pre_install_packs pre_install_packs
shell_update shell_update