aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rwxr-xr-xshare/hydractl/aperiodic-upgrade28
-rwxr-xr-xshare/hydractl/upgrade2
2 files changed, 17 insertions, 13 deletions
diff --git a/share/hydractl/aperiodic-upgrade b/share/hydractl/aperiodic-upgrade
index 505c309..ba09150 100755
--- a/share/hydractl/aperiodic-upgrade
+++ b/share/hydractl/aperiodic-upgrade
@@ -21,6 +21,13 @@ TIMEFRAME="${1:-86400}"
DATE="`date +%s`"
LOG="/var/lib/hydractl/aperidic-upgrade"
+# Upgrade and save timestamp
+function hydractl_aperiodic_upgrade {
+ hydractl upgrade
+ date +%s | $sudo tee $LOG > /dev/null
+ exit
+}
+
# Set sudo config
if [ "`whoami`" != 'root' ]; then
sudo="sudo"
@@ -29,26 +36,23 @@ fi
# Ensure log folder
$sudo mkdir -p "`dirname $LOG`"
+# Run
if [ ! -e "$LOG" ]; then
- # Upgrade anyway
- hydractl upgrade
+ hydractl_aperiodic_upgrade
else
LAST="`cat $LOG`"
- if [ -z "$LAST" ]; then
- hydractl upgrade
- else
+ if [ ! -z "$LAST" ]; then
INTERVAL="$(($DATE - $LAST))"
# More than $TIMEFRAME?
- if (( $INTERVAL > $TIMEFRAME )); then
- hydractl upgrade
+ if [ "$INTERVAL" -gt "$TIMEFRAME" ]; then
+ hydractl_aperiodic_upgrade
else
- echo "Please enjoy life for an additional $(($TIMEFRAME - $INTERVAL)) seconds before running this command again."
- exit
+ NEXT="$(($TIMEFRAME - $INTERVAL))"
+ echo "Please enjoy life for an additional $NEXT seconds before running this command again."
fi
+ else
+ hydractl_aperiodic_upgrade
fi
fi
-
-# Save timestamp
-date +%s | $sudo tee $LOG > /dev/null
diff --git a/share/hydractl/upgrade b/share/hydractl/upgrade
index ce4492c..cd8083b 100755
--- a/share/hydractl/upgrade
+++ b/share/hydractl/upgrade
@@ -45,7 +45,7 @@ hydractl chroot-upgrade
hydractl pbuilder-upgrade
# Upgrade all flatpak packages
-if which flatpak &> /dev/null
+if which flatpak &> /dev/null; then
$sudo flatpak update
fi