From 79b0c6c28d66c781d7e0a464931848629695f36d Mon Sep 17 00:00:00 2001 From: lsy Date: Mon, 23 Sep 2024 18:25:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=BD=BF=E7=94=A8sudo?= =?UTF-8?q?=E5=92=8C=E5=AE=89=E8=A3=85=E8=BD=AF=E4=BB=B6sudo,=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E9=94=AE=E5=AE=89=E8=A3=85=E8=BD=AF=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/Docker/Alist.sh | 4 ++-- Config/Docker/Gitea.sh | 5 +++++ Config/Docker/Nginx-proxy-manager.sh | 2 +- Config/Docker/Safeline.sh | 2 +- Config/Docker/Siyuan.sh | 4 ++-- Config/Docker/Vaultwarden.sh | 2 +- Config/Other/Language_set.sh | 28 ++++++++++++++-------------- Config/Other/bbr_open.sh | 6 +++--- Menus/Software.sh | 9 ++++++++- 9 files changed, 37 insertions(+), 25 deletions(-) diff --git a/Config/Docker/Alist.sh b/Config/Docker/Alist.sh index c074a0c..6b407c5 100644 --- a/Config/Docker/Alist.sh +++ b/Config/Docker/Alist.sh @@ -14,7 +14,7 @@ services: ports: - "${port}:5244" EOF -sudo docker compose up -d || "安装失败" $$ exit -declare password=$( sudo docker exec -it alist ./alist admin random | grep password | awk '{print $4}') +docker compose up -d || "安装失败" $$ exit +declare password=$( docker exec -it alist ./alist admin random | grep password | awk '{print $4}') echo "账号:admin" echo "密码:${password}" diff --git a/Config/Docker/Gitea.sh b/Config/Docker/Gitea.sh index 7f56dea..f196212 100644 --- a/Config/Docker/Gitea.sh +++ b/Config/Docker/Gitea.sh @@ -1,5 +1,10 @@ #!/bin/bash +if ! command -v sudo &> /dev/null; then + echo "该软件需要安装sudo才能正常安装" + exit +fi + declare path=$1 declare port=$2 diff --git a/Config/Docker/Nginx-proxy-manager.sh b/Config/Docker/Nginx-proxy-manager.sh index ee1af6a..d06cad1 100644 --- a/Config/Docker/Nginx-proxy-manager.sh +++ b/Config/Docker/Nginx-proxy-manager.sh @@ -16,6 +16,6 @@ services: - ./data:/data - ./letsencrypt:/etc/letsencrypt EOF -sudo docker compose up -d +docker compose up -d echo "Email: admin@example.com" echo "Password: changeme" diff --git a/Config/Docker/Safeline.sh b/Config/Docker/Safeline.sh index 51fdbe6..360e5f4 100644 --- a/Config/Docker/Safeline.sh +++ b/Config/Docker/Safeline.sh @@ -12,7 +12,7 @@ POSTGRES_PASSWORD="safeline" SUBNET_PREFIX=172.22.222 IMAGE_PREFIX=swr.cn-east-3.myhuaweicloud.com/chaitin-safeline EOF -sudo docker compose up -d || "安装失败" $$ exit +docker compose up -d || "安装失败" $$ exit declare password=$( docker exec safeline-mgt resetadmin &> /dev/null | grep password | awk -F ":" '{print $2}' ) echo "账号:admin" echo "密码:${password}" diff --git a/Config/Docker/Siyuan.sh b/Config/Docker/Siyuan.sh index f9cbf56..b734537 100644 --- a/Config/Docker/Siyuan.sh +++ b/Config/Docker/Siyuan.sh @@ -8,7 +8,7 @@ if [[ -z $password ]];then password="Siyuan" fi -sudo chown -R 1000:1000 $path +chown -R 1000:1000 $path cd $path cat > "docker-compose.yml" << EOF version: "3.9" @@ -27,5 +27,5 @@ services: - "--lang=zh_CN" - "--accessAuthCode=$password" EOF -sudo docker compose up -d || "安装失败" $$ exit +docker compose up -d || "安装失败" $$ exit echo "访问密码:$password" diff --git a/Config/Docker/Vaultwarden.sh b/Config/Docker/Vaultwarden.sh index fc4f013..57b67ce 100644 --- a/Config/Docker/Vaultwarden.sh +++ b/Config/Docker/Vaultwarden.sh @@ -40,5 +40,5 @@ mv "$admin" "../admin" mv "$email" "../email" cd .. rm -rf vaultwarden-lang-zhcn-main -sudo docker compose up -d || echo "安装失败" && exit +docker compose up -d || echo "安装失败" && exit echo "需要反向代理,使用https,才能正常使用" diff --git a/Config/Other/Language_set.sh b/Config/Other/Language_set.sh index 3521ccb..51a0e2b 100644 --- a/Config/Other/Language_set.sh +++ b/Config/Other/Language_set.sh @@ -4,34 +4,34 @@ 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 + apt-get update -y + apt-get install -y locales + 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 + apt update -y + apt install -y locales + apt install -y language-pack-zh-hans else echo "暂不支持该系统一键更换语言" exit fi -sudo sed -i '/^#/! s/^/# /' /etc/locale.gen +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 + sed -i 's/.*zh_CN.UTF-8.*/zh_CN.UTF-8 UTF-8/g' /etc/locale.gen + sed -i "s/^LANG.*/LANG=zh_CN.UTF-8/g" /etc/default/locale + 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 + sed -i 's/.*en_US.UTF-8.*/en_US.UTF-8 UTF-8/g' /etc/locale.gen + sed -i "s/^LANG.*/LANG=en_US.UTF-8/g" /etc/default/locale + sed -i "s/^LC_ALL.*/LC_ALL=en_US.UTF-8/g" /etc/default/locale ;; esac -sudo locale-gen +locale-gen update-locale source /etc/default/locale echo "语言更换成功" \ No newline at end of file diff --git a/Config/Other/bbr_open.sh b/Config/Other/bbr_open.sh index 5f51590..ca485f3 100644 --- a/Config/Other/bbr_open.sh +++ b/Config/Other/bbr_open.sh @@ -4,7 +4,7 @@ if ! [[ $version -ge 5 ]];then echo "系统内核版本过低" exit fi -grep -q "net.core.default_qdisc=fq" "/etc/sysctl.conf" || echo 'net.core.default_qdisc=fq' | sudo tee -a "/etc/sysctl.conf" -grep -q "net.ipv4.tcp_congestion_control=bbr" "/etc/sysctl.conf" || echo 'net.ipv4.tcp_congestion_control=bbr' | sudo tee -a "/etc/sysctl.conf" -sudo sysctl -p || echo "bbr 开启失败" +grep -q "net.core.default_qdisc=fq" "/etc/sysctl.conf" || echo 'net.core.default_qdisc=fq' | tee -a "/etc/sysctl.conf" +grep -q "net.ipv4.tcp_congestion_control=bbr" "/etc/sysctl.conf" || echo 'net.ipv4.tcp_congestion_control=bbr' | tee -a "/etc/sysctl.conf" +sysctl -p || echo "bbr 开启失败" sysctl net.ipv4.tcp_available_congestion_control | grep bbr && echo "bbr 开启成功" \ No newline at end of file diff --git a/Menus/Software.sh b/Menus/Software.sh index c448842..68b248c 100644 --- a/Menus/Software.sh +++ b/Menus/Software.sh @@ -31,6 +31,7 @@ soft_dick['git']=0 soft_dick['vim']=0 soft_dick['wget']=0 soft_dick['curl']=0 +soft_dick['sudo']=0 soft_dick['ssh']=0 soft_dick['zsh']=0 soft_dick['Beautify-zsh']=1 @@ -48,7 +49,13 @@ done read -p "请输入需要安装的软件序号,用 空格 隔开:" pick if [[ -z $pick ]];then - exit + for (( i = 1; i <= ${#soft_dick[@]}; i++ )); do + if [[ $i != 1 ]]; then + pick="$pick $i" + else + pick="$i" + fi + done elif [[ ! $pick =~ [1-"${#soft_dick[@]}"\ ] ]];then echo "输入错误" exit