除了自动更新ssl证书忘写了,其他完成
This commit is contained in:
parent
b73e72c2e9
commit
26f0cd3774
@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
declare pick
|
||||||
|
echo "========Automation========"
|
||||||
|
echo "1.自动备份"
|
||||||
|
echo "2.自动更新软件"
|
||||||
|
echo "3.自动Docker compose应用"
|
||||||
|
echo "4.自动更新ssh证书"
|
||||||
|
echo "输入其他任意返回主页"
|
||||||
|
echo "========Automation========"
|
||||||
|
read -p "请输入:" pick
|
||||||
|
|
||||||
|
if [[ ${pick} -lt 1 || ${pick} -gt 4 ]];then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -p "请输入脚本存放路径(默认:/var/script):" path
|
||||||
|
|
||||||
|
if [[ -z $path ]];then
|
||||||
|
path='/var/script'
|
||||||
|
fi
|
||||||
|
mkdir -p "$path"
|
||||||
|
|
||||||
|
|
||||||
|
case $pick in
|
||||||
|
'1')
|
||||||
|
bash Config/Automation/backup.sh "$path"
|
||||||
|
;;
|
||||||
|
'2')
|
||||||
|
bash Config/Automation/update.sh "$path"
|
||||||
|
;;
|
||||||
|
'3')
|
||||||
|
if ! command -v docker &> /dev/null; then
|
||||||
|
echo "docker未安装"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
if [[ -f "${path}/up-docker_compose.sh" ]];then
|
||||||
|
echo "该路径文件已经存在"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
declare web_path
|
||||||
|
read -p "请输入数据目录,默认 /var/www :" web_path
|
||||||
|
if [[ -z ${web_path} ]];then
|
||||||
|
web_path='/var/www'
|
||||||
|
fi
|
||||||
|
cat > "${path}/up-docker_compose.sh" << EOF
|
||||||
|
#!/bin/bash
|
||||||
|
docker_path="${web_path}"
|
||||||
|
for dir in "web_path"/*/; do
|
||||||
|
cd "\$dir" || exit
|
||||||
|
sudo docker compose pull
|
||||||
|
sudo docker compose up -d
|
||||||
|
done
|
||||||
|
EOF
|
||||||
|
chmod +x "${path}/up-docker_compose.sh"
|
||||||
|
sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败"
|
||||||
|
;;
|
||||||
|
'4')
|
||||||
|
echo "国内忘写了"
|
||||||
|
esac
|
||||||
|
echo "配置完成"
|
@ -52,7 +52,7 @@ if [[ $pick == '1' ]];then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
sudo echo "{\"registry-mirrors\": [\"${url}\"]}" > "/etc/docker/daemon.json"
|
sudo echo "{\"registry-mirrors\": [\"${url}\"]}" > "/etc/docker/daemon.json"
|
||||||
sudo systemctl restart docker
|
sudo systemctl restart docker 2>> /dev/null|| echo "docker 重启失败"
|
||||||
echo "换源成功"
|
echo "换源成功"
|
||||||
|
|
||||||
elif [[ $pick == '2' ]];then
|
elif [[ $pick == '2' ]];then
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!bin/bash
|
#!/bin/bash
|
||||||
declare pick
|
declare pick
|
||||||
echo "========Login========"
|
echo "========Login========"
|
||||||
echo "1.修改root密码"
|
echo "1.修改root密码"
|
||||||
|
@ -21,7 +21,7 @@ soft_array[3]='curl'
|
|||||||
soft_array[4]='git'
|
soft_array[4]='git'
|
||||||
soft_array[5]='ssh'
|
soft_array[5]='ssh'
|
||||||
soft_array[6]='zsh'
|
soft_array[6]='zsh'
|
||||||
|
soft_array[7]='zip'
|
||||||
|
|
||||||
echo "======一键安装常用软件======"
|
echo "======一键安装常用软件======"
|
||||||
for i in "${soft_array[@]}"
|
for i in "${soft_array[@]}"
|
||||||
|
@ -29,11 +29,11 @@ echo "========Sources========"
|
|||||||
read -p "请输入:" pick
|
read -p "请输入:" pick
|
||||||
|
|
||||||
|
|
||||||
if [[ ${pick} -le 0 || ${pick} -gt ${#sources_dick[*]} ]];then
|
if [[ -z $pick ]];then
|
||||||
echo "输入错误"
|
|
||||||
exit
|
|
||||||
elif [[ -z $pick ]];then
|
|
||||||
declare url='http://mirrors.ustc.edu.cn'
|
declare url='http://mirrors.ustc.edu.cn'
|
||||||
|
elif [[ ${pick} -le 0 || ${pick} -gt ${#sources_dick[*]} ]];then
|
||||||
|
echo "输入错误"
|
||||||
|
exit
|
||||||
else
|
else
|
||||||
pick=${pcik_array[$pick]}
|
pick=${pcik_array[$pick]}
|
||||||
declare url=${sources_dick[$pick]}
|
declare url=${sources_dick[$pick]}
|
||||||
@ -43,11 +43,16 @@ fi
|
|||||||
|
|
||||||
case "$version" in
|
case "$version" in
|
||||||
'bookworm')
|
'bookworm')
|
||||||
{
|
cat > "/etc/apt/sources.list" << EOF
|
||||||
echo "deb ${url}/debian/ bookworm main contrib non-free non-free-firmware"
|
deb ${url}/debian/ bookworm main contrib non-free non-free-firmware
|
||||||
echo "deb ${url}/debian/ bookworm-updates main contrib non-free non-free-firmware"
|
deb ${url}/debian/ bookworm-updates main contrib non-free non-free-firmware
|
||||||
echo "deb ${url}/debian/ bookworm-backports main contrib non-free non-free-firmware"
|
deb ${url}/debian/ bookworm-backports main contrib non-free non-free-firmware
|
||||||
} > /etc/apt/sources.list
|
EOF
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
echo "暂不支持该系统配置自动更新软件"
|
||||||
|
exit
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
echo "换源成功"
|
Loading…
Reference in New Issue
Block a user