Files
shellscripts/tailscale_script.sh
Your Name b00f025742 update
2024-11-12 00:07:46 +08:00

42 lines
954 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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