11#! /bin/bash
22# info: add cron job for hestia autoupdates
3- # options: NONE
3+ # options: MODE
44#
5- # The function adds cronjob for hestia autoupdate.
5+ # The function adds cronjob for hestia autoupdate from apt or git .
66
77
88# ----------------------------------------------------------#
1111
1212# Argument definition
1313user=admin
14+ mode=$1
1415
1516# Includes
1617source $HESTIA /func/main.sh
@@ -24,8 +25,9 @@ source $HESTIA/conf/hestia.conf
2425is_system_enabled " $CRON_SYSTEM " ' CRON_SYSTEM'
2526is_package_full ' CRON_JOBS'
2627get_next_cronjob
27- check_cron=$( grep ' v-update-sys-hestia-all' $USER_DATA /cron.conf)
28- if [ ! -z " $check_cron " ]; then
28+ check_cron_apt=$( grep ' v-update-sys-hestia-all' $USER_DATA /cron.conf)
29+ check_cron_git=$( grep ' v-update-sys-hestia-git' $USER_DATA /cron.conf)
30+ if [ ! -z " $check_cron_apt " ] || [ ! -z " $check_cron_git " ]; then
2931 exit
3032fi
3133
@@ -42,13 +44,27 @@ time_n_date=$(date +'%T %F')
4244time=$( echo " $time_n_date " | cut -f 1 -d \ )
4345date=$( echo " $time_n_date " | cut -f 2 -d \ )
4446
47+ # Remove existing cron job
48+ $BIN /v-delete-cron-hestia-autoupdate
49+
4550# Define time somewhere at night
46- min=$( generate_password ' 012345' ' 2' )
47- hour=$( generate_password ' 1234567' ' 1' )
48- day=' *'
49- month=' *'
50- wday=' *'
51- command=' sudo /usr/local/hestia/bin/v-update-sys-hestia-all'
51+ if [ -z " $mode " ] || [ " $mode " = " apt" ]; then
52+ min=$( generate_password ' 012345' ' 2' )
53+ hour=$( generate_password ' 1234567' ' 1' )
54+ day=' *'
55+ month=' *'
56+ wday=' *'
57+ command=' sudo /usr/local/hestia/bin/v-update-sys-hestia-all'
58+ fi
59+
60+ if [ " $mode " = " git" ]; then
61+ min=' 0'
62+ hour=' 0'
63+ day=' *'
64+ month=' *'
65+ wday=' *'
66+ command=' sudo /usr/local/hestia/bin/v-update-sys-hestia-git'
67+ fi
5268
5369# Concatenating cron string
5470str=" JOB='$job ' MIN='$min ' HOUR='$hour ' DAY='$day ' MONTH='$month ' WDAY='$wday '"
0 commit comments