42 lines
954 B
Bash
42 lines
954 B
Bash
#!/bin/bash
|
||
|
||
# 检查并安装 curl
|
||
check_and_install_curl() {
|
||
if ! command -v curl &> /dev/null; then
|
||
echo "curl 未安装。正在尝试安装 curl..."
|
||
sudo apt-get update && sudo apt-get install curl -y
|
||
echo "curl 已安装。"
|
||
else
|
||
echo "curl 已安装。"
|
||
fi
|
||
}
|
||
|
||
# 安装 Tailscale
|
||
install_tailscale() {
|
||
check_and_install_curl
|
||
echo "正在安装 Tailscale..."
|
||
curl -fsSL https://tailscale.com/install.sh | sudo sh
|
||
echo "Tailscale 已安装。"
|
||
}
|
||
|
||
# 卸载 Tailscale
|
||
uninstall_tailscale() {
|
||
echo "正在卸载 Tailscale..."
|
||
sudo apt-get remove --purge tailscale -y
|
||
echo "Tailscale 已卸载。"
|
||
}
|
||
|
||
# 用户界面
|
||
echo "选择操作:"
|
||
echo "1) 安装 Tailscale"
|
||
echo "2) 卸载 Tailscale"
|
||
echo "3) 退出"
|
||
read -p "输入选择(1-3):" choice
|
||
|
||
case $choice in
|
||
1) install_tailscale ;;
|
||
2) uninstall_tailscale ;;
|
||
3) exit 0 ;;
|
||
*) echo "无效输入。" ;;
|
||
esac
|