diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-12-17 11:05:38 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-12-17 11:05:38 -0200 |
commit | da6ab6e65eb502001d949c2783a48fd8ad7f7b91 (patch) | |
tree | 39a48b7da45e96e497337cf54bef39e53aa13945 /share | |
parent | 9d73ff39c0d2c43ab9799ea824698b4f7424c7b8 (diff) | |
download | hydra-da6ab6e65eb502001d949c2783a48fd8ad7f7b91.tar.gz hydra-da6ab6e65eb502001d949c2783a48fd8ad7f7b91.tar.bz2 |
Upgrade fixes
Diffstat (limited to 'share')
-rwxr-xr-x | share/hydractl/aperiodic-upgrade | 28 | ||||
-rwxr-xr-x | share/hydractl/upgrade | 2 |
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 |