linux下frp更新居然也需要手动执行,于是网上搜索一番,找到了一个自动化脚本,自己修改了一下,分享给大家。
感谢这位博主分享的自动化脚本。
自动化脚本
控制台执行内容
1 2 3 4 5
| nano update_frp.sh
chmod +x update_frp.sh ./update_frp.sh
|
自动化升级脚本
修改/var/www/frp、frps、linux_amd64为你需要的值
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #!/usr/bin/env bash
[ -z "${FRP_PATH}" ] && FRP_PATH=/var/www/frp
[ -z "${FRP_END}" ] && FRP_END=frps
[ -z "${ARCH}" ] && ARCH=linux_amd64 [ -z "${SUDO}" ] && [ "${NO_SUDO}" != "Y" ] && which sudo >/dev/null 2>&1 && SUDO=sudo
VER=$(${FRP_PATH}/${FRP_END} -v)
RELEASE_URL="https://api.github.com/repos/fatedier/frp/releases/latest" TMP_NAME=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) TMP_DIR="/tmp/frp_${TMP_NAME}"
mkdir -p "${TMP_DIR}" pushd "${TMP_DIR}" >/dev/null
DL_URL=$(curl -s ${RELEASE_URL} | grep ${ARCH} | grep browser_download_url | cut -d '"' -f 4)
if (echo ${DL_URL} | grep ${VER}) >/dev/null 2>&1; then echo already latest version! else wget ${DL_URL} -O frp.tar.gz tar zxvf frp.tar.gz cd frp_*
$SUDO cp -f "${FRP_END}" "${FRP_PATH}/"
CUR_VER=$(${FRP_PATH}/${FRP_END} -v) echo "Update FRP Complete (${VER} -> ${CUR_VER})!" fi
popd >/dev/null
rm -rf "${TMP_DIR}"
systemctl restart frp
|
systemd服务配置
1 2 3
| cd /etc/systemd/system nano frp.service
|
systemd服务配置详情
将/var/www/frp改为你的frp执行地址
1 2 3 4 5 6 7 8 9 10 11 12 13
| [Unit]
Description = frp server After = network.target syslog.target Wants = network.target
[Service] Type = simple
ExecStart = /usr/local/frp/frps -c /usr/local/frp/frps.toml
[Install] WantedBy = multi-user.target
|