初始版本: sbp Hysteria2 服务管理命令
This commit is contained in:
commit
c43ab4a16e
3 files changed
+1243
No files matched your search
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo="${SBP_REPO:-justypist/sbp}"
|
||||
branch="${SBP_BRANCH:-main}"
|
||||
dest="${SBP_BIN:-$HOME/.local/bin}"
|
||||
url="https://raw.githubusercontent.com/${repo}/${branch}/sbp"
|
||||
|
||||
command -v curl >/dev/null 2>&1 || { echo "error: curl is required" >&2; exit 1; }
|
||||
command -v python3 >/dev/null 2>&1 || { echo "error: python3 is required" >&2; exit 1; }
|
||||
|
||||
mkdir -p "$dest"
|
||||
tmp="$(mktemp)"
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
|
||||
curl -fsSL "$url" -o "$tmp"
|
||||
head -n 1 "$tmp" | grep -q '^#!/usr/bin/env python3' || {
|
||||
echo "error: unexpected content from $url" >&2
|
||||
exit 1
|
||||
}
|
||||
chmod 755 "$tmp"
|
||||
mv "$tmp" "$dest/sbp"
|
||||
trap - EXIT
|
||||
|
||||
echo "installed $dest/sbp"
|
||||
case ":$PATH:" in
|
||||
*":$dest:"*) ;;
|
||||
*) echo "note: add $dest to PATH, for example: export PATH=\"$dest:\$PATH\"" ;;
|
||||
esac
|
||||
|
||||
if [ "${1:-}" = "--run" ]; then
|
||||
exec "$dest/sbp" install "${@:2}"
|
||||
fi
|
||||
Reference in new issue
Block a user