Просмотр исходного кода

Enable automatic updates from Git via CLI

Kristan Kenney 5 лет назад
Родитель
Сommit
6f4f550b5a
2 измененных файлов с 23 добавлено и 10 удалено
  1. 21 9
      bin/v-add-cron-hestia-autoupdate
  2. 2 1
      bin/v-update-sys-hestia-git

+ 21 - 9
bin/v-add-cron-hestia-autoupdate

@@ -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,7 +11,7 @@
 
 # Argument definition
 user=admin
-
+mode=$1
 # Includes
 source $HESTIA/func/main.sh
 source $HESTIA/conf/hestia.conf
@@ -43,12 +43,24 @@ time=$(echo "$time_n_date" |cut -f 1 -d \ )
 date=$(echo "$time_n_date" |cut -f 2 -d \ )
 
 # 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'"

+ 2 - 1
bin/v-update-sys-hestia-git

@@ -7,6 +7,7 @@
 #           - Will download from the hestiacp repository
 #           - Pulls code from staging/beta branch
 #           - install: installs package immediately
+#           - install-auto: installs package and schedules automatic updates from Git
 #           - 'all': (optional) - compiles nginx and php alongside panel.
 #                                 this option takes a long time, only use when needed
 
@@ -421,7 +422,7 @@ install_build() {
 
 # Define installation routine
 
-if [ "$install" = "install" ] || [ "$install" = "yes" ]; then 
+if [ "$install" = "install" ] || [ "$install" = "yes" ] || [ "$install" = "install-auto" ]; then 
     install_build
 else
     warning_message