取消使用sudo和安装软件sudo,增加一键安装软件

This commit is contained in:
lsy 2024-09-23 18:25:54 +08:00
parent 7e937c202e
commit 79b0c6c28d
9 changed files with 37 additions and 25 deletions

View File

@ -14,7 +14,7 @@ services:
ports: ports:
- "${port}:5244" - "${port}:5244"
EOF EOF
sudo docker compose up -d || "安装失败" $$ exit docker compose up -d || "安装失败" $$ exit
declare password=$( sudo docker exec -it alist ./alist admin random | grep password | awk '{print $4}') declare password=$( docker exec -it alist ./alist admin random | grep password | awk '{print $4}')
echo "账号admin" echo "账号admin"
echo "密码:${password}" echo "密码:${password}"

View File

@ -1,5 +1,10 @@
#!/bin/bash #!/bin/bash
if ! command -v sudo &> /dev/null; then
echo "该软件需要安装sudo才能正常安装"
exit
fi
declare path=$1 declare path=$1
declare port=$2 declare port=$2

View File

@ -16,6 +16,6 @@ services:
- ./data:/data - ./data:/data
- ./letsencrypt:/etc/letsencrypt - ./letsencrypt:/etc/letsencrypt
EOF EOF
sudo docker compose up -d docker compose up -d
echo "Email: admin@example.com" echo "Email: admin@example.com"
echo "Password: changeme" echo "Password: changeme"

View File

@ -12,7 +12,7 @@ POSTGRES_PASSWORD="safeline"
SUBNET_PREFIX=172.22.222 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 docker compose up -d || "安装失败" $$ exit
declare password=$( docker exec safeline-mgt resetadmin &> /dev/null | 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}"

View File

@ -8,7 +8,7 @@ if [[ -z $password ]];then
password="Siyuan" password="Siyuan"
fi fi
sudo chown -R 1000:1000 $path chown -R 1000:1000 $path
cd $path cd $path
cat > "docker-compose.yml" << EOF cat > "docker-compose.yml" << EOF
version: "3.9" version: "3.9"
@ -27,5 +27,5 @@ services:
- "--lang=zh_CN" - "--lang=zh_CN"
- "--accessAuthCode=$password" - "--accessAuthCode=$password"
EOF EOF
sudo docker compose up -d || "安装失败" $$ exit docker compose up -d || "安装失败" $$ exit
echo "访问密码:$password" echo "访问密码:$password"

View File

@ -40,5 +40,5 @@ mv "$admin" "../admin"
mv "$email" "../email" mv "$email" "../email"
cd .. cd ..
rm -rf vaultwarden-lang-zhcn-main rm -rf vaultwarden-lang-zhcn-main
sudo docker compose up -d || echo "安装失败" && exit docker compose up -d || echo "安装失败" && exit
echo "需要反向代理,使用https,才能正常使用" echo "需要反向代理,使用https,才能正常使用"

View File

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

View File

@ -4,7 +4,7 @@ if ! [[ $version -ge 5 ]];then
echo "系统内核版本过低" echo "系统内核版本过低"
exit exit
fi 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.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' | sudo 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"
sudo sysctl -p || echo "bbr 开启失败" sysctl -p || echo "bbr 开启失败"
sysctl net.ipv4.tcp_available_congestion_control | grep bbr && echo "bbr 开启成功" sysctl net.ipv4.tcp_available_congestion_control | grep bbr && echo "bbr 开启成功"

View File

@ -31,6 +31,7 @@ soft_dick['git']=0
soft_dick['vim']=0 soft_dick['vim']=0
soft_dick['wget']=0 soft_dick['wget']=0
soft_dick['curl']=0 soft_dick['curl']=0
soft_dick['sudo']=0
soft_dick['ssh']=0 soft_dick['ssh']=0
soft_dick['zsh']=0 soft_dick['zsh']=0
soft_dick['Beautify-zsh']=1 soft_dick['Beautify-zsh']=1
@ -48,7 +49,13 @@ done
read -p "请输入需要安装的软件序号,用 空格 隔开:" pick read -p "请输入需要安装的软件序号,用 空格 隔开:" pick
if [[ -z $pick ]];then 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 elif [[ ! $pick =~ [1-"${#soft_dick[@]}"\ ] ]];then
echo "输入错误" echo "输入错误"
exit exit