Last active
April 26, 2024 13:28
-
-
Save jjhesk/e4c8224b8a76601601424be5a725522f to your computer and use it in GitHub Desktop.
One line install frps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
version="0.57.0" | |
linux_amd_url="https://github.com/fatedier/frp/releases/download/v${version}/frp_${version}_linux_amd64.tar.gz" | |
execution_path="/usr/bin/frps" | |
execution_path_config="/srv/frps/config.toml" | |
download_path="/tmp/frp_combo.tar.gz" | |
local_path_after_extract="tmp/frp_${version}_linux_amd64" | |
if [[ "$EUID" -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
if [[ -z $(command -v systemctl) ]]; then | |
echo "systemctl not found" | |
exit 1 | |
fi | |
if [[ ! -d /etc/systemd/system ]]; then | |
echo "Systemd directory not found" | |
exit 1 | |
fi | |
wget "$linux_amd_url" -O "$download_path" | |
tar -xzvf $download_path -C /tmp | |
cp -f "/${local_path_after_extract}/frps" /usr/bin/frps | |
cp -f "/${local_path_after_extract}/frpc" /usr/bin/frpc | |
echo "FRP server is now installed to the system v${version}" | |
systemctl disable frps.service &>/dev/null | |
find /etc/systemd -name 'auto-update.*' -exec rm -f {} \; | |
mkdir -p $execution_path | |
if [ ! -f $execution_path_config ]; then | |
echo "bindPort = 7000" > $execution_path_config | |
fi | |
if [ ! -f /etc/systemd/system/frps.service ]; then | |
cat > /etc/systemd/system/frps.service << EOF | |
[Unit] | |
# 服务名称,可自定义 | |
Description = frp server | |
After = network.target syslog.target | |
Wants = network.target | |
[Service] | |
Type = simple | |
User=root | |
Restart=always | |
# 启动frps的命令,需修改为您的frps的安装路径 | |
ExecStart = $execution_path -c $execution_path_config | |
[Install] | |
WantedBy = multi-user.target | |
EOF | |
fi | |
sudo systemctl status frps | |
sudo systemctl enable frps | |
sudo systemctl start frps | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment