新增acme自动更新,重写自动化菜单
This commit is contained in:
parent
607fc5978e
commit
7ccaa345d1
11
Config/Automation/acme.sh
Normal file
11
Config/Automation/acme.sh
Normal file
@ -0,0 +1,11 @@
|
||||
declare path="$1"
|
||||
|
||||
if [[ -f "${path}/acme.sh" ]];then
|
||||
echo "该路径文件已经存在"
|
||||
fi
|
||||
|
||||
cat > "${path}/acme.sh" << EOF
|
||||
#!/bin/bash
|
||||
${HOME}/.acme.sh/acme.sh --upgrade
|
||||
${HOME}/.acme.sh/acme.sh --renew-all
|
||||
EOF
|
@ -1,12 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare path="$1"
|
||||
declare cron="$2"
|
||||
declare web_path
|
||||
declare local_pick
|
||||
declare baidu_pick
|
||||
declare aliyun_pick
|
||||
declare cron
|
||||
declare ignore=1
|
||||
|
||||
|
||||
@ -103,12 +101,6 @@ for item in "$web_path"/*; do
|
||||
rm "\${item_name}_\${date_time}.tar.gz"
|
||||
done
|
||||
EOF
|
||||
chmod +x "$path/backup.sh"
|
||||
|
||||
declare cron_job="${cron} ${path}/backup.sh"
|
||||
(crontab -l 2>/dev/null | grep -v "backup.sh") | sudo crontab -
|
||||
|
||||
sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败"
|
||||
|
||||
if [[ $local_pick == [Yy] ]];then
|
||||
echo "本地备份路径:${web_path}/年份/目录名称"
|
||||
|
23
Config/Automation/up-docker_compose.sh
Normal file
23
Config/Automation/up-docker_compose.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare path="$1"
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "docker未安装"
|
||||
exit
|
||||
fi
|
||||
if [[ -f "${path}/up-docker_compose.sh" ]];then
|
||||
echo "该路径文件已经存在"
|
||||
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
|
||||
for dir in "${web_path}"/*/; do
|
||||
cd "\$dir" || exit
|
||||
sudo docker compose pull
|
||||
sudo docker compose up -d
|
||||
done
|
||||
EOF
|
@ -1,5 +1,4 @@
|
||||
declare path="$1"
|
||||
declare cron="$2"
|
||||
|
||||
if [[ -f "${path}/update.sh" ]];then
|
||||
echo "该路径文件已经存在"
|
||||
@ -20,11 +19,3 @@ else
|
||||
echo "暂不支持该系统配置自动更新软件"
|
||||
exit
|
||||
fi
|
||||
|
||||
chmod +x "${path}/update.sh"
|
||||
|
||||
declare cron_job="${cron} ${path}/update.sh"
|
||||
(crontab -l 2>/dev/null | grep -v "update.sh") | sudo crontab -
|
||||
(crontab -l 2>/dev/null; echo "$cron_job") | sudo crontab -
|
||||
|
||||
sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败"
|
@ -3,15 +3,18 @@
|
||||
declare path_script=$1
|
||||
declare pick
|
||||
echo "========Automation========"
|
||||
echo "1.自动备份"
|
||||
echo "2.自动更新软件"
|
||||
echo "3.自动Docker compose应用"
|
||||
echo "4.自动更新ssh证书"
|
||||
declare print_number=0
|
||||
declare -a print_array
|
||||
for i in "${path_script}/Config/Automation"/*;do
|
||||
print_number=$((print_number + 1))
|
||||
print_array[$print_number]=$(awk -F '.' '{print $1}' <<< "$(basename $i)")
|
||||
echo "${print_number}.${print_array[$print_number]}"
|
||||
done
|
||||
echo "输入其他任意返回主页"
|
||||
echo "========Automation========"
|
||||
read -p "请输入:" pick
|
||||
|
||||
if [[ ${pick} -lt 1 || ${pick} -gt 4 ]];then
|
||||
if [[ ! ${pick} =~ [1-$print_number] ]];then
|
||||
exit
|
||||
fi
|
||||
|
||||
@ -46,44 +49,13 @@ if [[ "$cron" == '* * * * * ' ]];then
|
||||
exit
|
||||
fi
|
||||
|
||||
bash "${path_script}/Config/Automation/${print_array[pick]}.sh" "$path"
|
||||
|
||||
case $pick in
|
||||
'1')
|
||||
bash "${path_script}/Config/Automation/backup.sh" "$path" "$cron"
|
||||
;;
|
||||
'2')
|
||||
bash "${path_script}/Config/Automation/update.sh" "$path" "$cron"
|
||||
;;
|
||||
'3')
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "docker未安装"
|
||||
exit
|
||||
fi
|
||||
if [[ -f "${path}/up-docker_compose.sh" ]];then
|
||||
echo "该路径文件已经存在"
|
||||
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
|
||||
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"
|
||||
chmod +x "${path}/${print_array[pick]}"
|
||||
declare cron_job="${cron} ${path}/${print_array[pick]}"
|
||||
(crontab -l 2>/dev/null | grep -v "${print_array[pick]}") | sudo crontab -
|
||||
(crontab -l 2>/dev/null; echo "$cron_job") | sudo crontab -
|
||||
|
||||
declare cron_job="${cron} ${path}/up-docker_compose.sh"
|
||||
(crontab -l 2>/dev/null | grep -v "up-docker_compose.sh") | sudo crontab -
|
||||
(crontab -l 2>/dev/null; echo "$cron_job") | sudo crontab -
|
||||
sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败"
|
||||
|
||||
sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败"
|
||||
;;
|
||||
'4')
|
||||
echo "糟糕忘写了"
|
||||
esac
|
||||
echo "配置完成"
|
Loading…
Reference in New Issue
Block a user