From 09e4e01f67d087961b8574840c689bc1d092e6f5 Mon Sep 17 00:00:00 2001 From: lsy Date: Mon, 23 Sep 2024 01:19:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96=E9=9B=B7?= =?UTF-8?q?=E6=B1=A0=E5=AF=86=E7=A0=81,=E5=B0=86other=E5=86=99=E4=B8=BA?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E6=96=87=E4=BB=B6,=E6=96=B0=E5=A2=9Eacme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/Docker/Safeline.sh | 2 +- Config/Other/Acme.sh | 99 +++++++++++++++++++++++++++++++++++++++ Config/Other/Language.sh | 37 +++++++++++++++ Menus/Other.sh | 44 +++-------------- 4 files changed, 143 insertions(+), 39 deletions(-) create mode 100644 Config/Other/Acme.sh create mode 100644 Config/Other/Language.sh diff --git a/Config/Docker/Safeline.sh b/Config/Docker/Safeline.sh index b15ea7f..51fdbe6 100644 --- a/Config/Docker/Safeline.sh +++ b/Config/Docker/Safeline.sh @@ -13,6 +13,6 @@ SUBNET_PREFIX=172.22.222 IMAGE_PREFIX=swr.cn-east-3.myhuaweicloud.com/chaitin-safeline EOF 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 "密码:${password}" diff --git a/Config/Other/Acme.sh b/Config/Other/Acme.sh new file mode 100644 index 0000000..32d5ff5 --- /dev/null +++ b/Config/Other/Acme.sh @@ -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 + + + + diff --git a/Config/Other/Language.sh b/Config/Other/Language.sh new file mode 100644 index 0000000..3521ccb --- /dev/null +++ b/Config/Other/Language.sh @@ -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 "语言更换成功" \ No newline at end of file diff --git a/Menus/Other.sh b/Menus/Other.sh index fd97b7c..df53f7d 100644 --- a/Menus/Other.sh +++ b/Menus/Other.sh @@ -2,6 +2,7 @@ declare pick echo "========Other========" echo "1.开启BBR" echo "2.更换系统语言" +echo "3.申请SSL证书" echo "输入其他任意返回主页" echo "========Other========" read -p "请输入:" pick @@ -19,42 +20,9 @@ case "$pick" in sysctl net.ipv4.tcp_available_congestion_control | grep bbr && echo "bbr 开启成功" ;; '2') - 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 "请手动执行下面的命令: - source /etc/default/locale" - echo "语言更换成功" + bash "${path_script}/Config/Other/Language.sh" + ;; + '3') + bash "${path_script}/Config/Other/Acme.sh" + ;; esac \ No newline at end of file