Skip to content

Commit ac81abf

Browse files
author
Kristan Kenney
committed
Merge branch 'feature/v-add-cron-hestia-autoupdate' into staging/features
2 parents b9b6677 + 6f4f550 commit ac81abf

File tree

5 files changed

+42
-18
lines changed

5 files changed

+42
-18
lines changed

bin/v-add-cron-hestia-autoupdate

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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
#----------------------------------------------------------#
@@ -11,6 +11,7 @@
1111

1212
# Argument definition
1313
user=admin
14+
mode=$1
1415

1516
# Includes
1617
source $HESTIA/func/main.sh
@@ -24,8 +25,9 @@ source $HESTIA/conf/hestia.conf
2425
is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM'
2526
is_package_full 'CRON_JOBS'
2627
get_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
3032
fi
3133

@@ -42,13 +44,27 @@ time_n_date=$(date +'%T %F')
4244
time=$(echo "$time_n_date" |cut -f 1 -d \ )
4345
date=$(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
5470
str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'"

bin/v-delete-cron-hestia-autoupdate

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ source $HESTIA/conf/hestia.conf
2222
#----------------------------------------------------------#
2323

2424
is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM'
25-
check_cron=$(grep 'v-update-sys-hestia-all' $USER_DATA/cron.conf)
26-
if [ -z "$check_cron" ]; then
27-
exit
28-
fi
25+
check_cron_apt=$(grep 'v-update-sys-hestia-all' $USER_DATA/cron.conf)
26+
check_cron_git=$(grep 'v-update-sys-hestia-git' $USER_DATA/cron.conf)
2927

3028
# Perform verification if read-only mode is enabled
3129
check_hestia_demo_mode
@@ -37,7 +35,13 @@ check_hestia_demo_mode
3735

3836

3937
# Deleting job
40-
job=$(echo $check_cron|tr ' ' "\n"|grep JOB|cut -f 2 -d "'")
38+
if [ ! -z "$check_cron_apt" ]; then
39+
job=$(echo $check_cron_apt|tr ' ' "\n"|grep JOB|cut -f 2 -d "'")
40+
fi
41+
if [ ! -z "$check_cron_git" ]; then
42+
job=$(echo $check_cron_git|tr ' ' "\n"|grep JOB|cut -f 2 -d "'")
43+
fi
44+
4145
sed -i "/JOB='$job' /d" $USER_DATA/cron.conf
4246

4347
# Sorting jobs by id

bin/v-update-sys-hestia-git

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# - Will download from the hestiacp repository
88
# - Pulls code from staging/beta branch
99
# - install: installs package immediately
10+
# - install-auto: installs package and schedules automatic updates from Git
1011
# - 'all': (optional) - compiles nginx and php alongside panel.
1112
# this option takes a long time, only use when needed
1213

@@ -421,8 +422,11 @@ install_build() {
421422

422423
# Define installation routine
423424

424-
if [ "$install" = "install" ] || [ "$install" = "yes" ]; then
425+
if [ "$install" = "install" ] || [ "$install" = "yes" ] || [ "$install" = "install-auto" ]; then
425426
install_build
427+
if [ "$install" = "install-auto" ]; then
428+
$HESTIA/bin/v-add-cron-hestia-autoupdate git
429+
fi
426430
else
427431
warning_message
428432
read -p "Do you wish to proceed with the installation? [y/n] " answer

install/hst-install-debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ command="sudo $HESTIA/bin/v-update-sys-rrd"
18481848
$HESTIA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
18491849

18501850
# Enable automatic updates
1851-
$HESTIA/bin/v-add-cron-hestia-autoupdate
1851+
$HESTIA/bin/v-add-cron-hestia-autoupdate apt
18521852

18531853
# Building initital rrd images
18541854
$HESTIA/bin/v-update-sys-rrd

install/hst-install-ubuntu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,7 @@ command="sudo $HESTIA/bin/v-update-sys-rrd"
18521852
$HESTIA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
18531853

18541854
# Enable automatic updates
1855-
$HESTIA/bin/v-add-cron-hestia-autoupdate
1855+
$HESTIA/bin/v-add-cron-hestia-autoupdate apt
18561856

18571857
# Building initital rrd images
18581858
$HESTIA/bin/v-update-sys-rrd

0 commit comments

Comments
 (0)