Browse Source

[Firewall-ipset] enable daily ipset autoupdate

Finishes the feature added in #819
Robert Zollner 5 years ago
parent
commit
03ff18ac89
2 changed files with 8 additions and 2 deletions
  1. 6 0
      bin/v-add-firewall-ipset
  2. 2 2
      bin/v-update-firewall-ipset

+ 6 - 0
bin/v-add-firewall-ipset

@@ -161,6 +161,12 @@ fi
 chmod 660 $HESTIA/data/firewall/ipset.conf
 chmod 660 $HESTIA/data/firewall/ipset.conf
 chmod 660 "${IPSET_PATH}/${IPSET_FILE}.iplist"
 chmod 660 "${IPSET_PATH}/${IPSET_FILE}.iplist"
 
 
+# Install ipset daily cron updater
+if ! grep --no-messages "v-update-firewall-ipset" $HESTIA/data/queue/daily.pipe; then
+    cmd="$BIN/v-update-firewall-ipset yes"
+    echo "$cmd" >> $HESTIA/data/queue/daily.pipe
+fi
+
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Hestia                             #
 #                       Hestia                             #

+ 2 - 2
bin/v-update-firewall-ipset

@@ -41,9 +41,9 @@ for ipset_name in $(search_objects "$ipset_hstobject" 'SUSPENDED' 'no' 'LISTNAME
 
 
     last_updated_ts=$(date -d "$ipset_date $ipset_time" +%s)
     last_updated_ts=$(date -d "$ipset_date $ipset_time" +%s)
     now=$(date +%s)
     now=$(date +%s)
-    hours_since_update=$(( (now - last_updated_ts) / 60 ))
+    hours_since_update=$(( (now - last_updated_ts) / (60*60) ))
 
 
-    if [[ "$hours_since_update" -lt 70 ]] && [ "$force" = 'no' ]; then
+    if [[ "$hours_since_update" -lt 24 ]] && [ "$force" = 'no' ]; then
         # load existing ip list files in the kernel but don't auto update them
         # load existing ip list files in the kernel but don't auto update them
         $BIN/v-add-firewall-ipset "$ipset_name"
         $BIN/v-add-firewall-ipset "$ipset_name"
         continue
         continue