From fb051b00c096d9834bd06859ca5a36759b2cf612 Mon Sep 17 00:00:00 2001 From: risenzhang Date: Tue, 31 Dec 2019 16:10:11 +0800 Subject: [PATCH 1/4] add update frps & create systemd link --- f.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/f.sh b/f.sh index f0b91a9..92a7565 100644 --- a/f.sh +++ b/f.sh @@ -13,7 +13,7 @@ get_version(){ api_url="https://api.github.com/repos/fatedier/frp/releases/latest" - new_ver=`curl ${PROXY} -s ${api_url} --connect-timeout 10| grep 'tag_name' | cut -d\" -f4` + new_ver=`curl -s ${api_url} --connect-timeout 10| grep 'tag_name' | cut -d\" -f4` touch ./version.txt cat < ./version.txt @@ -41,12 +41,21 @@ install_frps(){ mv ./frp*/frps /usr/local/frps/frps mv ./frp*/frps_full.ini /usr/local/frps/frps.ini + ln -s /usr/local/frps/frps /usr/bin/frps + ln -s /usr/local/frps/frps.ini /etc/frp/frps.ini + + if [ -d "./frp*/systemd" ]; then + mv ./frp*/systemd/frps* /usr/local/frps/systemd/ + fi + rm -rf ./frp* } - # 添加开机自启动 add_auto_run(){ + if [ -d "/usr/local/frps/systemd" ]; then + ln -s /usr/local/frps/systemd/frps* /etc/systemd/system/ + else touch /etc/systemd/system/frps.service cat < /etc/systemd/system/frps.service [Unit] @@ -55,16 +64,28 @@ After=network.target Wants=network.target [Service] Type=simple -PIDFile=/var/run/frps.pid -ExecStart=/usr/local/frps/frps -c /usr/local/frps/frps.ini +PIDFile=/var/run/frps.pid +ExecStart=/usr/bin/frps -c /etc/frp/frps.ini RestartPreventExitStatus=23 Restart=always User=root [Install] WantedBy=multi-user.target EOF + fi } +# 更新frps +update_frps(){ + wget -N --no-check-certificate ${releases_url} + + tar -zxvf frp*.tar.gz + + mv ./frp*/frps /usr/local/frps/frps + mv ./frp*/systemd/frps* /usr/local/frps/systemd/ + + rm -rf ./frp* +} # 启动frps run_frps(){ @@ -80,7 +101,7 @@ set_uninstall(){ systemctl stop frps systemctl disable frps rm -rf /usr/local/frps - rm -rf /etc/systemd/system/frps.service >/dev/null 2>&1 + rm -rf /etc/systemd/system/frps* >/dev/null 2>&1 echo -e "卸载成功!" } From ffc97e2eea83d55ea8bee67f0b6d6e5202f81164 Mon Sep 17 00:00:00 2001 From: risenzhang Date: Tue, 31 Dec 2019 18:11:49 +0800 Subject: [PATCH 2/4] fix mv systemd & download url --- f.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/f.sh b/f.sh index 92a7565..81c9c73 100644 --- a/f.sh +++ b/f.sh @@ -13,7 +13,7 @@ get_version(){ api_url="https://api.github.com/repos/fatedier/frp/releases/latest" - new_ver=`curl -s ${api_url} --connect-timeout 10| grep 'tag_name' | cut -d\" -f4` + new_ver=`curl ${PROXY} -s ${api_url} --connect-timeout 10| grep 'tag_name' | cut -d\" -f4` touch ./version.txt cat < ./version.txt @@ -37,17 +37,19 @@ install_frps(){ rm -rf /usr/local/frps mkdir /usr/local/frps + mkdir /etc/frp mv ./frp*/frps /usr/local/frps/frps mv ./frp*/frps_full.ini /usr/local/frps/frps.ini + cd ./frp* + if [ -d "systemd" ]; then + mv systemd /usr/local/frps/ + fi + ln -s /usr/local/frps/frps /usr/bin/frps ln -s /usr/local/frps/frps.ini /etc/frp/frps.ini - if [ -d "./frp*/systemd" ]; then - mv ./frp*/systemd/frps* /usr/local/frps/systemd/ - fi - rm -rf ./frp* } @@ -101,6 +103,8 @@ set_uninstall(){ systemctl stop frps systemctl disable frps rm -rf /usr/local/frps + rm -rf /usr/bin/frps + rm -rf /etc/frp rm -rf /etc/systemd/system/frps* >/dev/null 2>&1 echo -e "卸载成功!" } From 1d53372892408567676f818ce96fd46d7de8d0be Mon Sep 17 00:00:00 2001 From: risenzhang Date: Tue, 31 Dec 2019 18:16:27 +0800 Subject: [PATCH 3/4] fix start frps permission error --- f.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/f.sh b/f.sh index 81c9c73..31cbe5e 100644 --- a/f.sh +++ b/f.sh @@ -45,6 +45,7 @@ install_frps(){ cd ./frp* if [ -d "systemd" ]; then mv systemd /usr/local/frps/ + sed -i '/^User/c\User = root' /usr/local/frps/systemd/frps.service fi ln -s /usr/local/frps/frps /usr/bin/frps From dc7c15bd61e403296213a989de3f7535065ee0a1 Mon Sep 17 00:00:00 2001 From: risenzhang Date: Tue, 31 Dec 2019 18:21:18 +0800 Subject: [PATCH 4/4] fix update frps --- f.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/f.sh b/f.sh index 31cbe5e..a5c5c4a 100644 --- a/f.sh +++ b/f.sh @@ -79,7 +79,8 @@ EOF } # 更新frps -update_frps(){ +set_update(){ + get_version wget -N --no-check-certificate ${releases_url} tar -zxvf frp*.tar.gz @@ -356,7 +357,7 @@ set_install(){ # 脚本菜单 case "$1" in - bind_port|bind_udp_port|kcp_bind_port|vhost_http_port|vhost_https_port|dashboard_port|dashboard_user|dashboard_pwd|token|subdomain_host|install|uninstall|unapache2) + bind_port|bind_udp_port|kcp_bind_port|vhost_http_port|vhost_https_port|dashboard_port|dashboard_user|dashboard_pwd|token|subdomain_host|install|uninstall|unapache2|update) set_$1 ;; *)