修复获取雷池密码,将other写为独立文件,新增acme

This commit is contained in:
lsy 2024-09-23 01:19:11 +08:00
parent 743aff6bb3
commit 09e4e01f67
4 changed files with 143 additions and 39 deletions

View File

@ -13,6 +13,6 @@ SUBNET_PREFIX=172.22.222
IMAGE_PREFIX=swr.cn-east-3.myhuaweicloud.com/chaitin-safeline IMAGE_PREFIX=swr.cn-east-3.myhuaweicloud.com/chaitin-safeline
EOF EOF
sudo docker compose up -d || "安装失败" $$ exit sudo docker compose up -d || "安装失败" $$ exit
declare password=$( docker exec safeline-mgt resetadmin | grep password | awk -F "" '{print $2}' ) declare password=$( docker exec safeline-mgt resetadmin &> /dev/null | grep password | awk -F "" '{print $2}' )
echo "账号admin" echo "账号admin"
echo "密码:${password}" echo "密码:${password}"

99
Config/Other/Acme.sh Normal file
View File

@ -0,0 +1,99 @@
#!/bin/bash
declare mail
declare domain
declare domain_str=''
read -p "请输入用来申请域名的邮箱:" mail
if [[ $mail =~ "\w+@\w+\.[a-z]+" ]];then
echo "邮箱不合法"
exit
fi
echo "请输入需要申请SSL证书的域名"
while(1);do
read -p "不输入退出添加:" domain
if [[ -z $domain ]];then
break
elif [[ $domain =~ "\w+\.[a-z]+" ]];then
echo "域名不合法"
exit
domain_str="$domain_str -d $domain"
fi
done
if [[ -z $domain_str ]]; then
echo "需要添加的域名不能为空"
exit
fi
declare pick_mode
read "1.http验证"
read "2.dns验证"
read -p "请选择验证模式" pick_mode
if [[ ! -d "${HOME}/.acme.sh" ]];then
curl https://get.acme.sh | sh -s "email=$mail"
fi
case $pick_mode in
'1')
declare pick_start
echo "请到服务器将80和443端口开启,将域名解析到本机"
read -p "解析完成请输入 y" pick_start
if [[ ! $pick_start =~ [Yy] ]];then
exit
fi
eval "${HOME}/.acme.sh/acme.sh --issue $domain_str --standalone"
;;
'2')
declare pick=0
declare -a mode_arr
mode_arr[1]="TXT记录"
mode_arr[2]='cloudflare'
for i in $mode_arr ; do
pick=$(( pick+1 ))
ehco "${pick}.${mode_arr[$pick]}"
done
read -p "请选择验证模式" pick_mode
if [[ $pick_mode =~ [1-${pick}] ]]; then
exit
fi
case ${mode_arr[$pick_mode]} in
'TXT记录')
declare $log_output=$(acme.sh --issue --dns $domain_str --yes-I-know-dns-manual-mode-enough-go-ahead-please)
declare domain=$( echo "$log_output" | grep "Domain:" | awk -F ": " '{print $2}')
declare txt_value=$(echo "$log_output" | grep "TXT value:" | awk -F ": " '{print $2}')
echo "请到dns系统解析TXT记录"
echo "域名: $domain"
echo "文本记录: $txt_value"
read -p "解析完成请输入 y" pick
if [[ $pick =~ [Yy] ]]; then
eval "${HOME}/.acme.sh/acme.sh --renew $domain_str --yes-I-know-dns-manual-mode-enough-go-ahead-please"
else
echo "解析完成后请输入下面的命令完成验证"
echo "${HOME}/.acme.sh/acme.sh --renew $domain_str --yes-I-know-dns-manual-mode-enough-go-ahead-please"
fi
;;
'cloudflare')
declare CF_Key
declare CF_Email
read -p "请输入cloudflare的邮箱" CF_Email
if [[ $CF_Email =~ "\w+@\w+\.[a-z]+" ]];then
echo "邮箱不合法"
exit
fi
read -p "请输入cloudflare的密钥" CF_Key
if [[ $CF_Key =~ "\w+" ]];then
echo "密钥不合法"
exit
fi
export CF_Key=$CF_Key
export CF_Email=$CF_Email
eval "${HOME}/.acme.sh/acme.sh --issue $domain_str --dns dns_cf"
esac
;;
esac

37
Config/Other/Language.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
declare lang
echo "1.中文"
echo "2.英文"
read -p "请输入:" lang
if [[ -f "/usr/bin/apt-get" ]];then
sudo apt-get update -y
sudo apt-get install -y locales
sudo apt-get install -y language-pack-zh-hans
elif [[ -f "/usr/bin/apt" ]];then
sudo apt update -y
sudo apt install -y locales
sudo apt install -y language-pack-zh-hans
else
echo "暂不支持该系统一键更换语言"
exit
fi
sudo sed -i '/^#/! s/^/# /' /etc/locale.gen
if ! grep LC_ALL /etc/default/locale &> /dev/null; then
echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale
fi
case $lang in
'1')
sudo sed -i 's/.*zh_CN.UTF-8.*/zh_CN.UTF-8 UTF-8/g' /etc/locale.gen
sudo sed -i "s/^LANG.*/LANG=zh_CN.UTF-8/g" /etc/default/locale
sudo sed -i "s/^LC_ALL.*/LC_ALL=zh_CN.UTF-8/g" /etc/default/locale
;;
'2')
sudo sed -i 's/.*en_US.UTF-8.*/en_US.UTF-8 UTF-8/g' /etc/locale.gen
sudo sed -i "s/^LANG.*/LANG=en_US.UTF-8/g" /etc/default/locale
sudo sed -i "s/^LC_ALL.*/LC_ALL=en_US.UTF-8/g" /etc/default/locale
;;
esac
sudo locale-gen
update-locale
source /etc/default/locale
echo "语言更换成功"

View File

@ -2,6 +2,7 @@ declare pick
echo "========Other========" echo "========Other========"
echo "1.开启BBR" echo "1.开启BBR"
echo "2.更换系统语言" echo "2.更换系统语言"
echo "3.申请SSL证书"
echo "输入其他任意返回主页" echo "输入其他任意返回主页"
echo "========Other========" echo "========Other========"
read -p "请输入:" pick read -p "请输入:" pick
@ -19,42 +20,9 @@ case "$pick" in
sysctl net.ipv4.tcp_available_congestion_control | grep bbr && echo "bbr 开启成功" sysctl net.ipv4.tcp_available_congestion_control | grep bbr && echo "bbr 开启成功"
;; ;;
'2') '2')
declare lang bash "${path_script}/Config/Other/Language.sh"
echo "1.中文"
echo "2.英文"
read -p "请输入:" lang
if [[ -f "/usr/bin/apt-get" ]];then
sudo apt-get update -y
sudo apt-get install -y locales
sudo apt-get install -y language-pack-zh-hans
elif [[ -f "/usr/bin/apt" ]];then
sudo apt update -y
sudo apt install -y locales
sudo apt install -y language-pack-zh-hans
else
echo "暂不支持该系统一键更换语言"
exit
fi
sudo sed -i '/^#/! s/^/# /' /etc/locale.gen
if ! grep LC_ALL /etc/default/locale &> /dev/null; then
echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale
fi
case $lang in
'1')
sudo sed -i 's/.*zh_CN.UTF-8.*/zh_CN.UTF-8 UTF-8/g' /etc/locale.gen
sudo sed -i "s/^LANG.*/LANG=zh_CN.UTF-8/g" /etc/default/locale
sudo sed -i "s/^LC_ALL.*/LC_ALL=zh_CN.UTF-8/g" /etc/default/locale
;; ;;
'2') '3')
sudo sed -i 's/.*en_US.UTF-8.*/en_US.UTF-8 UTF-8/g' /etc/locale.gen bash "${path_script}/Config/Other/Acme.sh"
sudo sed -i "s/^LANG.*/LANG=en_US.UTF-8/g" /etc/default/locale
sudo sed -i "s/^LC_ALL.*/LC_ALL=en_US.UTF-8/g" /etc/default/locale
;; ;;
esac esac
sudo locale-gen
update-locale
source /etc/default/locale
echo "请手动执行下面的命令:
source /etc/default/locale"
echo "语言更换成功"
esac