忘写时间了

This commit is contained in:
lsy 2024-07-26 18:45:04 +08:00
parent 8e81657f82
commit 8905b97ae2
3 changed files with 29 additions and 30 deletions

View File

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
declare path=$1 declare path=$1
declare cron=$2
declare web_path declare web_path
declare local_pick declare local_pick
declare baidu_pick declare baidu_pick
declare aliyun_pick declare aliyun_pick
declare -a cron_array=("分钟" "小时" "天数" "月份" "星期" )
declare cron declare cron
if [[ -f "${path}/update.sh" ]];then if [[ -f "${path}/update.sh" ]];then
@ -63,32 +63,6 @@ if [[ ! $aliyun_pick =~ [Nn] ]];then
./aliyunpan login ./aliyunpan login
fi fi
echo
echo "执行日期"
echo "星号(*):表示匹配任意值"
echo "逗号(,):用于分隔多个值"
echo "斜线(/):用于指定间隔值"
echo "连字符(-):用于指定范围"
declare tmp_time
for i in "${cron_array[@]}";do
read -p "${i},默认为 * " tmp_time
if [[ $tmp_time =~ ^[0-9]+$ || $tmp_time == '*' ]];then
cron+="${tmp_time} "
elif [[ -z ${tmp_time} ]];then
cron+='* '
else
echo "输入错误"
exit
fi
done
if [[ "$cron" == '* * * * * ' ]];then
read "该脚本会无时无刻执行,请重新输入"
exit
fi
cat > "${path}/backup.sh" << EOF cat > "${path}/backup.sh" << EOF
#!/bin/bash #!/bin/bash
declare date_time=$(date +"%Y_%m_%d") # 日期格式 declare date_time=$(date +"%Y_%m_%d") # 日期格式

View File

@ -1,5 +1,6 @@
declare version=$(cat /etc/os-release | grep '^ID' | awk -F '=' '{print $2}') declare version=$(cat /etc/os-release | grep '^ID' | awk -F '=' '{print $2}')
declare path=$1 declare path=$1
declare cron=$2
if [[ -f "${path}/update.sh" ]];then if [[ -f "${path}/update.sh" ]];then
echo "该路径文件已经存在" echo "该路径文件已经存在"

View File

@ -21,13 +21,37 @@ if [[ -z $path ]];then
fi fi
mkdir -p "$path" mkdir -p "$path"
echo "执行日期"
echo "星号(*):表示匹配任意值"
echo "逗号(,):用于分隔多个值"
echo "斜线(/):用于指定间隔值"
echo "连字符(-):用于指定范围"
declare tmp_time
declare -a cron_array=("分钟" "小时" "天数" "月份" "星期" )
for i in "${cron_array[@]}";do
read -p "${i},默认为 * " tmp_time
if [[ $tmp_time =~ ^[0-9]+$ || $tmp_time == '*' ]];then
cron+="${tmp_time} "
elif [[ -z ${tmp_time} ]];then
cron+='* '
else
echo "输入错误"
exit
fi
done
if [[ "$cron" == '* * * * * ' ]];then
read "该脚本会无时无刻执行,请重新输入"
exit
fi
case $pick in case $pick in
'1') '1')
bash Config/Automation/backup.sh "$path" bash Config/Automation/backup.sh "$path" "$cron"
;; ;;
'2') '2')
bash Config/Automation/update.sh "$path" bash Config/Automation/update.sh "$path" "$cron"
;; ;;
'3') '3')
if ! command -v docker &> /dev/null; then if ! command -v docker &> /dev/null; then
@ -61,6 +85,6 @@ EOF
sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败" sudo systemctl restart cron 2>> /dev/null || echo "自动任务重启失败"
;; ;;
'4') '4')
echo "国内忘写了" echo "糟糕忘写了"
esac esac
echo "配置完成" echo "配置完成"