2023-07-23 23:14:59 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
#fonts color
|
|
|
|
|
Green="\033[32m"
|
|
|
|
|
Red="\033[31m"
|
|
|
|
|
Yellow="\033[33m"
|
|
|
|
|
BLUE="\033[36m"
|
|
|
|
|
Plain="\033[0m"
|
|
|
|
|
red() {
|
|
|
|
|
echo -e "\033[31m\033[01m$1\033[0m"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
green() {
|
|
|
|
|
echo -e "\033[32m\033[01m$1\033[0m"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yellow() {
|
|
|
|
|
echo -e "\033[33m\033[01m$1\033[0m"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_root() {
|
|
|
|
|
if [ 0 == $UID ]; then
|
|
|
|
|
green "当前用户是root用户,进入安装流程 "
|
|
|
|
|
sleep 3
|
|
|
|
|
else
|
|
|
|
|
red "当前用户不是root用户,请切换到root用户后重新执行脚本 "
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
check_system() {
|
|
|
|
|
source '/etc/os-release'
|
|
|
|
|
if [[ "${ID}" == "centos" && ${VERSION_ID} -ge 7 ]]; then
|
|
|
|
|
green "当前系统为 Centos ${VERSION_ID} ${VERSION} "
|
|
|
|
|
INS="yum"
|
|
|
|
|
elif [[ "${ID}" == "debian" && ${VERSION_ID} -ge 8 ]]; then
|
|
|
|
|
green "当前系统为 Debian ${VERSION_ID} ${VERSION} "
|
|
|
|
|
INS="apt"
|
|
|
|
|
$INS update
|
|
|
|
|
## 添加 Nginx apt源
|
|
|
|
|
elif [[ "${ID}" == "ubuntu" && $(echo "${VERSION_ID}" | cut -d '.' -f1) -ge 16 ]]; then
|
|
|
|
|
green "当前系统为 Ubuntu ${VERSION_ID} ${UBUNTU_CODENAME} "
|
|
|
|
|
INS="apt"
|
|
|
|
|
rm /var/lib/dpkg/lock
|
|
|
|
|
dpkg --configure -a
|
|
|
|
|
rm /var/lib/apt/lists/lock
|
|
|
|
|
rm /var/cache/apt/archives/lock
|
|
|
|
|
$INS update
|
|
|
|
|
else
|
|
|
|
|
red "当前系统为 ${ID} ${VERSION_ID} 不在支持的系统列表内,安装中断 "
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_self_cert() {
|
|
|
|
|
mkdir self
|
2023-08-29 16:19:26 +00:00
|
|
|
|
$INS install openssl -y
|
2023-07-23 23:14:59 +00:00
|
|
|
|
# openssl genrsa -out self/1.key 2048
|
|
|
|
|
openssl ecparam -genkey -name prime256v1 -noout -out self/1.key
|
|
|
|
|
# 生成CA证书
|
|
|
|
|
openssl req -new -x509 -days 3650 -key self/1.key -out self/1.crt -subj "/C=US/O=DigiCert Inc. /CN=DigiCert Local Root CA"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
install_self() {
|
|
|
|
|
get_self_cert
|
|
|
|
|
echo "你的证书:"
|
|
|
|
|
cat self/1.crt
|
|
|
|
|
echo "你的证书密钥:"
|
|
|
|
|
cat self/1.key
|
|
|
|
|
echo "所有文件在self文件夹下"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uninstall_self() {
|
|
|
|
|
rm -r self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
install_docker() {
|
2023-08-29 16:19:26 +00:00
|
|
|
|
$INS install curl -y
|
2023-07-23 23:14:59 +00:00
|
|
|
|
curl -fsSL https://get.docker.com | sh
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run_gost() {
|
|
|
|
|
# 下载脚本
|
2023-08-29 09:56:10 +00:00
|
|
|
|
curl -fsSL https://git.igewu.org/yanglc/xbbox/raw/branch/main/rungost.sh -o rungost.sh
|
2023-07-23 23:14:59 +00:00
|
|
|
|
|
|
|
|
|
# 添加可执行权限并运行脚本
|
|
|
|
|
chmod +x rungost.sh
|
|
|
|
|
./rungost.sh
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-29 09:20:09 +00:00
|
|
|
|
self_cert() {
|
|
|
|
|
# 下载脚本
|
2023-08-29 12:04:51 +00:00
|
|
|
|
curl -fsSL https://git.igewu.org/yanglc/xbbox/raw/branch/main/selfcert.sh -o selfcert.sh
|
2023-08-29 09:20:09 +00:00
|
|
|
|
|
|
|
|
|
chmod +x selfsert.sh
|
|
|
|
|
./selfcert.sh
|
|
|
|
|
}
|
|
|
|
|
wginstall(){
|
2023-08-29 12:04:51 +00:00
|
|
|
|
curl -fsSL https://git.igewu.org/yanglc/xbbox/raw/branch/main/wginstall.sh -o wginstall.sh
|
2023-08-29 09:20:09 +00:00
|
|
|
|
|
|
|
|
|
chmod +x wginstall.sh
|
|
|
|
|
./wginstall.sh
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-23 23:14:59 +00:00
|
|
|
|
menu() {
|
|
|
|
|
echo -e "—————————————— 小白工具箱一键脚本 ——————————————"""
|
|
|
|
|
echo -e "\t---authored by yanglc---"
|
|
|
|
|
echo -e "${Green}0.${Plain} 退出 "
|
|
|
|
|
echo -e "${Green}1.${Plain} 生成自签证书 "
|
|
|
|
|
echo -e "${Green}2.${Plain} 删除自签证书 "
|
|
|
|
|
echo -e "${Green}3.${Plain} 安装Docker "
|
|
|
|
|
echo -e "${Green}4.${Plain} gost控制脚本"
|
2023-08-29 09:20:09 +00:00
|
|
|
|
echo -e "${Green}5.${Plain} 自签证书脚本(备用)"
|
|
|
|
|
echo -e "${Green}6.${Plain} Wireguard配置脚本"
|
2023-07-23 23:14:59 +00:00
|
|
|
|
|
|
|
|
|
# 调用is_root()函数来检查是否为root用户
|
|
|
|
|
is_root
|
|
|
|
|
|
|
|
|
|
read -rp "请输入数字:" menu_num
|
|
|
|
|
case $menu_num in
|
|
|
|
|
0)
|
|
|
|
|
exit 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
|
|
|
|
install_self
|
|
|
|
|
;;
|
|
|
|
|
2)
|
|
|
|
|
uninstall_self
|
|
|
|
|
;;
|
|
|
|
|
3)
|
|
|
|
|
install_docker
|
|
|
|
|
;;
|
|
|
|
|
4)
|
|
|
|
|
run_gost
|
|
|
|
|
;;
|
2023-08-29 09:20:09 +00:00
|
|
|
|
5)
|
|
|
|
|
self_cert
|
|
|
|
|
;;
|
|
|
|
|
6)
|
|
|
|
|
wginstall
|
|
|
|
|
;;
|
2023-07-23 23:14:59 +00:00
|
|
|
|
*)
|
|
|
|
|
red "请输入正确的数字"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-29 09:20:09 +00:00
|
|
|
|
menu
|