|
|
@@ -1,8 +1,8 @@
|
|
|
#!/bin/bash
|
|
|
# info: add cron job for hestia autoupdates
|
|
|
-# options: NONE
|
|
|
+# options: MODE
|
|
|
#
|
|
|
-# The function adds cronjob for hestia autoupdate.
|
|
|
+# The function adds cronjob for hestia autoupdate from apt or git.
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
|
@@ -11,6 +11,7 @@
|
|
|
|
|
|
# Argument definition
|
|
|
user=admin
|
|
|
+mode=$1
|
|
|
|
|
|
# Includes
|
|
|
source $HESTIA/func/main.sh
|
|
|
@@ -24,8 +25,9 @@ source $HESTIA/conf/hestia.conf
|
|
|
is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM'
|
|
|
is_package_full 'CRON_JOBS'
|
|
|
get_next_cronjob
|
|
|
-check_cron=$(grep 'v-update-sys-hestia-all' $USER_DATA/cron.conf)
|
|
|
-if [ ! -z "$check_cron" ]; then
|
|
|
+check_cron_apt=$(grep 'v-update-sys-hestia-all' $USER_DATA/cron.conf)
|
|
|
+check_cron_git=$(grep 'v-update-sys-hestia-git' $USER_DATA/cron.conf)
|
|
|
+if [ ! -z "$check_cron_apt" ] || [ ! -z "$check_cron_git" ]; then
|
|
|
exit
|
|
|
fi
|
|
|
|
|
|
@@ -42,13 +44,27 @@ time_n_date=$(date +'%T %F')
|
|
|
time=$(echo "$time_n_date" |cut -f 1 -d \ )
|
|
|
date=$(echo "$time_n_date" |cut -f 2 -d \ )
|
|
|
|
|
|
+# Remove existing cron job
|
|
|
+$BIN/v-delete-cron-hestia-autoupdate
|
|
|
+
|
|
|
# Define time somewhere at night
|
|
|
-min=$(generate_password '012345' '2')
|
|
|
-hour=$(generate_password '1234567' '1')
|
|
|
-day='*'
|
|
|
-month='*'
|
|
|
-wday='*'
|
|
|
-command='sudo /usr/local/hestia/bin/v-update-sys-hestia-all'
|
|
|
+if [ -z "$mode" ] || [ "$mode" = "apt" ]; then
|
|
|
+ min=$(generate_password '012345' '2')
|
|
|
+ hour=$(generate_password '1234567' '1')
|
|
|
+ day='*'
|
|
|
+ month='*'
|
|
|
+ wday='*'
|
|
|
+ command='sudo /usr/local/hestia/bin/v-update-sys-hestia-all'
|
|
|
+fi
|
|
|
+
|
|
|
+if [ "$mode" = "git" ]; then
|
|
|
+ min='0'
|
|
|
+ hour='0'
|
|
|
+ day='*'
|
|
|
+ month='*'
|
|
|
+ wday='*'
|
|
|
+ command='sudo /usr/local/hestia/bin/v-update-sys-hestia-git'
|
|
|
+fi
|
|
|
|
|
|
# Concatenating cron string
|
|
|
str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'"
|