25 Commits

Author SHA1 Message Date
mvscode
bd2ad22b0b Update README.md 2024-09-21 11:54:00 +08:00
mvscode
5a8a211841 Add files via upload 2024-07-27 22:56:15 +08:00
mvscode
6011cded16 Update README.md 2024-07-27 22:39:21 +08:00
mvscode
3350154c18 Update README.md 2024-07-27 17:06:06 +03:00
mvscode
73a73adecb Update README.md 2024-07-27 17:03:52 +03:00
mvscode
9be39f4b24 Merge pull request #114 from mvscode/dev
Dev
2024-07-24 14:32:12 +08:00
mvscode
09075d7465 Update install-frps.sh 2024-07-24 14:22:29 +08:00
mvscode
40b2dc00b3 Add files via upload 2024-07-24 14:20:12 +08:00
mvscode
d2c6817ec1 Update install-frps.sh 2024-07-24 14:07:47 +08:00
mvscode
d3ca27b699 Add files via upload 2024-07-24 14:04:27 +08:00
mvscode
136356348c Add files via upload 2024-07-24 14:02:21 +08:00
mvscode
b9e6c6861e Add files via upload 2024-07-24 14:00:42 +08:00
mvscode
2091a76e50 Add files via upload 2024-07-24 13:57:52 +08:00
mvscode
9c9c79d6de Add files via upload 2024-07-24 10:15:02 +08:00
mvscode
91bd7d81ce Add files via upload 2024-07-24 10:12:56 +08:00
mvscode
6fab896993 Add files via upload 2024-07-18 17:14:32 +08:00
mvscode
70869272fa Add files via upload 2024-07-18 17:13:11 +08:00
mvscode
d9aece1dcf Add files via upload 2024-07-18 17:10:54 +08:00
mvscode
b68b0d1dc4 Merge pull request #112 from mvscode/dev
Dev
2024-06-26 14:20:34 +08:00
mvscode
07be762bf7 Add files via upload 2024-06-26 12:07:13 +08:00
mvscode
35e42fcc39 Add files via upload 2024-06-26 12:01:29 +08:00
mvscode
26e21f19d7 Add files via upload 2024-06-26 11:59:18 +08:00
mvscode
27f8e57933 Add files via upload 2024-06-25 15:56:05 +08:00
MvsCode
f324a3e684 Merge pull request #111 from MvsCode/dev
Update install-frps.sh
2024-06-20 16:43:40 +08:00
MvsCode
178492d97b Update install-frps.sh 2024-06-20 16:42:37 +08:00
3 changed files with 205 additions and 95 deletions

View File

@@ -52,10 +52,53 @@ Usage: /etc/init.d/frps {start|stop|restart|status|config|version}
## Script ChangeLog
---------------------------------------
### [1.0.1] - 2024-06-07
### [1.0.7] - 2024-07-24
#### Added
* Add progress bar for download frps tar file
[Issue 101](https://github.com/mvscode/frps-onekey/issues/101)
#### Fixed
* fix typo
### [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
* frps program config file change to frps.toml from frps.int
* Change curl command to get server ip from wget command [Issue 117](https://github.com/mvscode/frps-onekey/issues/117)
### [1.0.2] - 2024-06-13
@@ -68,34 +111,18 @@ Usage: /etc/init.d/frps {start|stop|restart|status|config|version}
etc..
```
### [1.0.3] - 2024-06-16
#### Amendment
* Amend function name to frps
### [1.0.1] - 2024-06-07
#### 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
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
ProgramName="Frps"
ProgramName="frps"
ProgramPath="/usr/local/frps"
NAME=frps
BIN=${ProgramPath}/${NAME}
CONFIGFILE=${ProgramPath}/frps.toml
SCRIPTNAME=/etc/init.d/${NAME}
version="2023"
version="2024"
program_version=`${BIN} --version`
RET_VAL=0
[ -x ${BIN} ] || exit 0
strLog=""
fun_clangcn()
fun_frps()
{
echo ""
echo "+---------------------------------------------------------+"
@@ -57,7 +57,7 @@ fun_load_config(){
fun_start()
{
if [ "${arg1}" = "start" ]; then
fun_clangcn
fun_frps
fi
if fun_check_run; then
echo "${ProgramName} (pid $PID) already running."
@@ -78,7 +78,7 @@ fun_start()
fun_stop(){
if [ "${arg1}" = "stop" ] || [ "${arg1}" = "restart" ]; then
fun_clangcn
fun_frps
fi
if fun_check_run; then
echo -n "Stoping ${ProgramName} (pid $PID)... "
@@ -108,19 +108,23 @@ fun_status(){
fi
}
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
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
OS=Debian
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
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
echo "Not support OS, Please reinstall OS and retry!"
return 1
echo "Unsupported OS. Please use a supported Linux distribution and retry!"
exit 1
fi
}
fun_config(){
@@ -156,7 +160,7 @@ case "${arg1}" in
fun_help
;;
*)
fun_clangcn
fun_frps
echo "Usage: $SCRIPTNAME {start|stop|restart|status|config|version}"
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_name="frps"
version="1.0.5"
version="1.0.7"
str_program_dir="/usr/local/${program_name}"
program_init="/etc/init.d/${program_name}"
program_config_file="frps.toml"
@@ -81,7 +81,7 @@ fun_frps(){
fi
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 "+------------------------------------------------------------+"
echo ""
@@ -113,38 +113,55 @@ get_char(){
stty echo
stty $SAVEDSTTY
}
# Check OS
# Check Server OS
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
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
OS=Debian
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OS=Ubuntu
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OS=Fedora
else
echo "Not support OS, Please reinstall OS and retry!"
echo "Unsupported OS. Please use a supported Linux distribution and retry!"
exit 1
fi
}
# Get version
getversion(){
if [[ -s /etc/redhat-release ]];then
grep -oE "[0-9.]+" /etc/redhat-release
local version
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
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
}
# CentOS version
centosversion(){
local code=$1
local version="`getversion`"
local main_ver=${version%%.*}
if [ $main_ver == $code ];then
return 0
# Check server os version
check_os_version(){
local required_version=$1
local current_version=$(getversion)
if [[ "$(echo -e "$current_version\n$required_version" | sort -V | head -n1)" == "$required_version" ]]; then
return 0 # when current version > required version
else
return 1
return 1 # when current version < required version
fi
}
# Check OS bit
@@ -165,12 +182,6 @@ check_os_bit() {
*) echo "Unknown architecture";;
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(){
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
@@ -208,7 +219,7 @@ fun_randstr(){
fun_getServer(){
def_server_url="github"
echo ""
echo -e "Please select ${program_name} download url:"
echo -e "Please select ${COLOR_PINK}${program_name} download${COLOR_END} url:"
echo -e "[1].gitee"
echo -e "[2].github (default)"
read -e -p "Enter your choice (1, 2 or exit. default [${def_server_url}]): " set_server_url
@@ -257,27 +268,84 @@ fun_download_file(){
# download
if [ ! -s ${str_program_dir}/${program_name} ]; then
rm -fr ${program_latest_filename} frp_${FRPS_VER}_linux_${ARCHS}
if ! wget -q ${program_latest_file_url} -O ${program_latest_filename}; then
echo -e " ${COLOR_RED}failed${COLOR_END}"
exit 1
fi
tar xzf ${program_latest_filename}
mv frp_${FRPS_VER}_linux_${ARCHS}/frps ${str_program_dir}/${program_name}
rm -fr ${program_latest_filename} frp_${FRPS_VER}_linux_${ARCHS}
echo -e "Downloading ${program_name}..."
echo ""
curl -L --progress-bar "${program_latest_file_url}" -o "${program_latest_filename}" 2>&1 | show_progress
echo ""
if [ $? -ne 0 ]; then
echo -e " ${COLOR_RED}Download failed${COLOR_END}"
exit 1
fi
# Verify the downloaded file exists and is not empty
if [ ! -s ${program_latest_filename} ]; then
echo -e " ${COLOR_RED}Downloaded file is empty or not found${COLOR_END}"
exit 1
fi
echo -e "Extracting ${program_name}..."
echo ""
tar xzf ${program_latest_filename}
mv frp_${FRPS_VER}_linux_${ARCHS}/frps ${str_program_dir}/${program_name}
rm -fr ${program_latest_filename} frp_${FRPS_VER}_linux_${ARCHS}
fi
chown root:root -R ${str_program_dir}
if [ -s ${str_program_dir}/${program_name} ]; then
[ ! -x ${str_program_dir}/${program_name} ] && chmod 755 ${str_program_dir}/${program_name}
else
echo -e " ${COLOR_RED}failed${COLOR_END}"
exit 1
echo -e " ${COLOR_RED}failed${COLOR_END}"
exit 1
fi
}
# Helper function to format the progress bar
show_progress() {
local TOTAL_SIZE=1000000 # Assume total size is 1000000 bytes
local CURRENT_SIZE=0 # Initial download size is 0 bytes
local GREEN='\033[1;32m'
local NC='\033[0m' # No Color
while [ $CURRENT_SIZE -lt $TOTAL_SIZE ] || [ $PERCENTAGE -lt 100 ]; do
PERCENTAGE=$(awk "BEGIN {printf \"%.0f\", $CURRENT_SIZE*100/$TOTAL_SIZE}")
if ! [[ "$PERCENTAGE" =~ ^[0-9]+$ ]] ; then
PERCENTAGE=0
fi
local completed=$((PERCENTAGE / 2))
local remaining=$((50 - completed))
if [ $PERCENTAGE -eq 100 ]; then
completed=50
remaining=0
fi
printf "\r${GREEN}%2d%% [" "$PERCENTAGE"
for ((i = 0; i < completed; i++)); do
if [ $i -eq $((completed - 1)) ]; then
printf ">"
else
printf "="
fi
done
for ((i = 0; i < remaining; i++)); do
printf " "
done
printf "]${NC}"
CURRENT_SIZE=$((CURRENT_SIZE + $((RANDOM % 50000 + 1))))
sleep 0.05
done
echo -e "\nDownload complete!"
}
function __readINI() {
INIFILE=$1; SECTION=$2; ITEM=$3
_readIni=`awk -F '=' '/\['$SECTION'\]/{a=1}a==1&&$1~/'$ITEM'/{print $2;exit}' $INIFILE`
echo ${_readIni}
}
# Check port
fun_check_port(){
port_flag=""
@@ -413,35 +481,41 @@ fun_input_quic_bind_port(){
pre_install_frps(){
fun_frps
echo -e "Check your server setting, please wait..."
echo ""
disable_selinux
# Check if the frps service is already running
if pgrep -x "${program_name}" >/dev/null; then
echo -e "${COLOR_GREEN}${program_name} is already installed and running.${COLOR_END}"
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 ""
read -p "Do you want to re-install ${program_name}? (y/n) " choice
echo ""
case "$choice" in
y|Y)
echo "Re-installing ${program_name}..."
install_frps
echo -e "${COLOR_GREEN} Re-installing ${program_name}...${COLOR_END}"
;;
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
clear
fun_frps
fun_getServer
fun_getVer
echo -e ""
echo -e "Loading You Server IP, please wait..."
defIP=$(curl -s https://api.ipify.org)
echo -e "You Server IP:${COLOR_GREEN}${defIP}${COLOR_END}"
echo -e ""
echo -e "————————————————————————————————————————————"
echo -e " ${COLOR_RED}Please input your server setting:${COLOR_END}"
echo -e "————————————————————————————————————————————"
@@ -481,15 +555,15 @@ else
[ -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 "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
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"
;;
@@ -613,14 +687,14 @@ else
echo -e "Dashboard password : ${COLOR_GREEN}${set_dashboard_pwd}${COLOR_END}"
echo -e "token : ${COLOR_GREEN}${set_token}${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 "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 file : ${COLOR_GREEN}${str_log_file_flag}${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 "quic bind port : ${COLOR_GREEN}${set_quic_bind_port}${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 "quic bind port : ${COLOR_GREEN}${set_quic_bind_port}${COLOR_END}"
echo "=============================================="
echo ""
echo "Press any key to start...or Press Ctrl+c to cancel"
@@ -777,7 +851,8 @@ EOF
echo -n "download ${program_name} ..."
rm -f ${str_program_dir}/${program_name} ${program_init}
fun_download_file
echo " done"
echo "Done"
echo ""
echo -n "download ${program_init}..."
if [ ! -s ${program_init} ]; then
if ! wget -q ${FRPS_INIT} -O ${program_init}; then
@@ -789,7 +864,9 @@ EOF
echo " done"
echo -n "setting ${program_name} boot..."
[ ! -x ${program_init} ] && chmod +x ${program_init}
if [ "${OS}" == 'CentOS' ]; then
chmod +x ${program_init}
chkconfig --add ${program_name}
@@ -797,8 +874,10 @@ EOF
chmod +x ${program_init}
update-rc.d -f ${program_name} defaults
fi
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
${program_init} start
@@ -842,17 +921,17 @@ fi
echo -e "vhost https port : ${COLOR_GREEN}${set_vhost_https_port}${COLOR_END}"
echo -e "token : ${COLOR_GREEN}${set_token}${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 "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 file : ${COLOR_GREEN}${str_log_file_flag}${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 "quic bind port : ${COLOR_GREEN}${set_quic_bind_port}${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 "quic bind port : ${COLOR_GREEN}${set_quic_bind_port}${COLOR_END}"
echo "================================================"
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 password : ${COLOR_GREEN}${set_dashboard_pwd}${COLOR_END}"
echo "================================================"
@@ -1015,7 +1094,7 @@ update_program_server_frps() {
echo "============== Update $program_name =============="
update_config_frps
checkos
check_centosversion
check_os_version
check_os_bit
fun_getVer
@@ -1077,7 +1156,7 @@ strPath=$(pwd)
rootness
fun_set_text_color
checkos
check_centosversion
check_os_version
check_os_bit
pre_install_packs
shell_update