diff options
| author | Lukasz Kasprzak <lukasz.kasprzak@pm.me> | 2026-04-14 22:32:43 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukasz.kasprzak@pm.me> | 2026-04-14 22:32:43 +0200 |
| commit | 83f7fe4b8402bab171d110703a1b1115efbc9b28 (patch) | |
| tree | 19110702c7d740f6bd8ee4f5d2ebcb97442be237 /straper/db/public/cron/cron.daily/apt-compat | |
| parent | 51d43498b07dc97d795947964534f0903cd05db5 (diff) | |
| download | bin-83f7fe4b8402bab171d110703a1b1115efbc9b28.tar.gz bin-83f7fe4b8402bab171d110703a1b1115efbc9b28.zip | |
cleaned up many scrits and deleted some that were of no use; renamed a lot
Diffstat (limited to 'straper/db/public/cron/cron.daily/apt-compat')
| -rwxr-xr-x | straper/db/public/cron/cron.daily/apt-compat | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/straper/db/public/cron/cron.daily/apt-compat b/straper/db/public/cron/cron.daily/apt-compat deleted file mode 100755 index bde3237..0000000 --- a/straper/db/public/cron/cron.daily/apt-compat +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -set -e - -# Systemd systems use a systemd timer unit which is preferable to -# run. We want to randomize the apt update and unattended-upgrade -# runs as much as possible to avoid hitting the mirrors all at the -# same time. The systemd time is better at this than the fixed -# cron.daily time -if [ -d /run/systemd/system ]; then - exit 0 -fi - -check_power() -{ - # laptop check, on_ac_power returns: - # 0 (true) System is on main power - # 1 (false) System is not on main power - # 255 (false) Power status could not be determined - # Desktop systems always return 255 it seems - if command -v on_ac_power >/dev/null; then - if on_ac_power; then - : - elif [ $? -eq 1 ]; then - return 1 - fi - fi - return 0 -} - -# sleep for a random interval of time (default 30min) -# (some code taken from cron-apt, thanks) -random_sleep() -{ - RandomSleep=1800 - eval $(apt-config shell RandomSleep APT::Periodic::RandomSleep) - if [ $RandomSleep -eq 0 ]; then - return - fi - if [ -z "$RANDOM" ] ; then - # A fix for shells that do not have this bash feature. - RANDOM=$(( $(dd if=/dev/urandom bs=2 count=1 2> /dev/null | cksum | cut -d' ' -f1) % 32767 )) - fi - TIME=$(($RANDOM % $RandomSleep)) - sleep $TIME -} - -# delay the job execution by a random amount of time -random_sleep - -# ensure we don't do this on battery -check_power || exit 0 - -# run daily job -exec /usr/lib/apt/apt.systemd.daily |
