]> gitweb.fluxo.info Git - scripts.git/commitdiff
Fix: status: run mrconfig-update less often
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 4 Aug 2024 03:11:12 +0000 (00:11 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 4 Aug 2024 03:11:12 +0000 (00:11 -0300)
status

diff --git a/status b/status
index 1478c8c28489d540c3a1779116e386c75c81a4ce..948cba6cd7d3f0a1012f3db06c06cd58fd95a84b 100755 (executable)
--- a/status
+++ b/status
@@ -77,12 +77,34 @@ function status_run {
 
     # Update your mrconfig and check all registered repositories
     if which mr &> /dev/null; then
+      local mrconfig="$HOME/.custom/mrconfig-automatic"
+      local mrconfig_run="0"
+
+      # Run mrconfig-updater if there's still no config
+      if [ ! -e "$mrconfig" ]; then
+        mrconfig_run="1"
+      else
+        local mrconfig_timestamp="`stat -c '%Z' $mrconfig`"
+        local timestamp="`date +%s`"
+        local mrconfig_age="$(( timestamp - mrconfig_timestamp ))"
+        local mrconfig_interval="3600"
+
+        # Run mrconfig-updater only every hour or so
+        if (( $mrconfig_age >= $mrconfig_interval )); then
+          mrconfig_run="1"
+        fi
+      fi
+
+      if [ "$mrconfig_run" == "1" ]; then
+        mrconfig-updater
+      fi
+
       # Pipe through cat so we don't have to deal with mr's dynamic output weirdness
-      #mrconfig-updater && mr -m status | cat
+      #mr -m status | cat
 
       # Replace eventual "/mnt/crypt/home/$USER" with "~/" from output
       # Piping through sed also handles mr's dynamic output weirdness
-      mrconfig-updater && mr -m status | sed -e "s|/mnt/crypt/home/$USER/|~/|" -e "s|$HOME|~|"
+      mr -m status | sed -e "s|/mnt/crypt/home/$USER/|~/|" -e "s|$HOME|~|"
     fi
 
     # Use this as an opportunity to save our configs