Skip to content

Instantly share code, notes, and snippets.

@book000
Last active December 21, 2024 07:16
Show Gist options
  • Save book000/4083adcd8202e523fbf4993beea65b2b to your computer and use it in GitHub Desktop.
Save book000/4083adcd8202e523fbf4993beea65b2b to your computer and use it in GitHub Desktop.
frps install & upgrader
#!/bin/bash
set -eu
# jq がインストールされていない場合はインストールする
if ! type jq > /dev/null 2>&1; then
sudo apt-get install -y jq
fi
# frp の最新バージョンを取得する
latest_tag=$(curl -s https://api.github.com/repos/fatedier/frp/releases/latest | jq -r '.tag_name')
latest_version=${latest_tag#v}
frp_version=$latest_version
echo "latest version: $latest_version (tag: $latest_tag)"
# frp の最新バージョンがインストールされているか確認する
# frps --version でバージョンを取得。
if [ -x frps ]; then
installed_version=$(./frps --version)
echo "installed version: $installed_version"
if [ "$installed_version" = "$latest_version" ]; then
echo "frps v$latest_version is already installed"
exit 0
fi
fi
# frp の最新バージョンをダウンロードし、展開する
echo "installing frps v$latest_version"
wget -O "frp_${frp_version}_linux_amd64.tar.gz" -q "https://github.com/fatedier/frp/releases/download/v${frp_version}/frp_${frp_version}_linux_amd64.tar.gz"
tar x --strip=1 --wildcards '*/frps' -f frp_${frp_version}_linux_amd64.tar.gz
# tar.gz ファイルを削除する
rm frp_${frp_version}_linux_amd64.tar.gz
echo "frps v$latest_version is installed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment