aboutsummaryrefslogtreecommitdiff
path: root/straper/db/public/cron
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukasz.kasprzak@pm.me>2026-03-20 19:16:32 +0100
committerLukasz Kasprzak <lukasz.kasprzak@pm.me>2026-03-20 19:16:32 +0100
commit39711cf6c2ec5a3b4480dcb4800cc3802bda5bf2 (patch)
tree9221704f413398cfb5d5759083b1e7032566820e /straper/db/public/cron
parent6b59b75c3a294060dea66bdee16ffaf95ae92889 (diff)
downloadbin-39711cf6c2ec5a3b4480dcb4800cc3802bda5bf2.tar.gz
bin-39711cf6c2ec5a3b4480dcb4800cc3802bda5bf2.zip
feat: first fully successful run e2e on straper
Diffstat (limited to 'straper/db/public/cron')
-rw-r--r--straper/db/public/cron/cron.d/.placeholder2
-rw-r--r--straper/db/public/cron/cron.d/anacron6
-rw-r--r--straper/db/public/cron/cron.d/certbot17
-rw-r--r--straper/db/public/cron/cron.d/e2scrub_all2
-rw-r--r--straper/db/public/cron/cron.d/zfs-auto-snapshot3
-rw-r--r--straper/db/public/cron/cron.d/zfsutils-linux7
-rw-r--r--straper/db/public/cron/cron.daily/.placeholder2
-rwxr-xr-xstraper/db/public/cron/cron.daily/0anacron12
-rwxr-xr-xstraper/db/public/cron/cron.daily/apt-compat55
-rwxr-xr-xstraper/db/public/cron/cron.daily/disk-alert4
-rwxr-xr-xstraper/db/public/cron/cron.daily/dpkg8
-rwxr-xr-xstraper/db/public/cron/cron.daily/logrotate18
-rwxr-xr-xstraper/db/public/cron/cron.daily/man-db50
-rwxr-xr-xstraper/db/public/cron/cron.daily/plocate35
-rwxr-xr-xstraper/db/public/cron/cron.daily/zfs-auto-snapshot6
-rw-r--r--straper/db/public/cron/cron.monthly/.placeholder2
-rwxr-xr-xstraper/db/public/cron/cron.monthly/0anacron12
-rwxr-xr-xstraper/db/public/cron/cron.monthly/zfs-auto-snapshot6
-rw-r--r--straper/db/public/cron/cron.weekly/.placeholder2
-rwxr-xr-xstraper/db/public/cron/cron.weekly/0anacron12
-rwxr-xr-xstraper/db/public/cron/cron.weekly/man-db40
-rwxr-xr-xstraper/db/public/cron/cron.weekly/tor16
-rwxr-xr-xstraper/db/public/cron/cron.weekly/zfs-auto-snapshot6
-rw-r--r--straper/db/public/cron/crontab22
24 files changed, 345 insertions, 0 deletions
diff --git a/straper/db/public/cron/cron.d/.placeholder b/straper/db/public/cron/cron.d/.placeholder
new file mode 100644
index 0000000..76cb8d0
--- /dev/null
+++ b/straper/db/public/cron/cron.d/.placeholder
@@ -0,0 +1,2 @@
+# DO NOT EDIT OR REMOVE
+# This file is a simple placeholder to keep dpkg from removing this directory
diff --git a/straper/db/public/cron/cron.d/anacron b/straper/db/public/cron/cron.d/anacron
new file mode 100644
index 0000000..57b33c5
--- /dev/null
+++ b/straper/db/public/cron/cron.d/anacron
@@ -0,0 +1,6 @@
+# /etc/cron.d/anacron: crontab entries for the anacron package
+
+SHELL=/bin/sh
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+30 7-23 * * * root if [ -x /etc/init.d/anacron ] && ! [ -d /run/systemd/system ]; then exec /usr/sbin/invoke-rc.d anacron start >/dev/null; fi
diff --git a/straper/db/public/cron/cron.d/certbot b/straper/db/public/cron/cron.d/certbot
new file mode 100644
index 0000000..cac009f
--- /dev/null
+++ b/straper/db/public/cron/cron.d/certbot
@@ -0,0 +1,17 @@
+# /etc/cron.d/certbot: crontab entries for the certbot package
+#
+# Upstream recommends attempting renewal twice a day
+#
+# Eventually, this will be an opportunity to validate certificates
+# haven't been revoked, etc. Renewal will only occur if expiration
+# is within 30 days.
+#
+# Important Note! This cronjob will NOT be executed if you are
+# running systemd as your init system. If you are running systemd,
+# the cronjob.timer function takes precedence over this cronjob. For
+# more details, see the systemd.timer manpage, or use systemctl show
+# certbot.timer.
+SHELL=/bin/sh
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew --no-random-sleep-on-renew
diff --git a/straper/db/public/cron/cron.d/e2scrub_all b/straper/db/public/cron/cron.d/e2scrub_all
new file mode 100644
index 0000000..7af25f1
--- /dev/null
+++ b/straper/db/public/cron/cron.d/e2scrub_all
@@ -0,0 +1,2 @@
+30 3 * * 0 root test -e /run/systemd/system || SERVICE_MODE=1 /usr/libexec/e2fsprogs/e2scrub_all_cron
+10 3 * * * root test -e /run/systemd/system || SERVICE_MODE=1 /sbin/e2scrub_all -A -r
diff --git a/straper/db/public/cron/cron.d/zfs-auto-snapshot b/straper/db/public/cron/cron.d/zfs-auto-snapshot
new file mode 100644
index 0000000..613afc9
--- /dev/null
+++ b/straper/db/public/cron/cron.d/zfs-auto-snapshot
@@ -0,0 +1,3 @@
+PATH="/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
+
+*/15 * * * * root which zfs-auto-snapshot > /dev/null || exit 0 ; zfs-auto-snapshot --quiet --syslog --label=frequent --keep=4 //
diff --git a/straper/db/public/cron/cron.d/zfsutils-linux b/straper/db/public/cron/cron.d/zfsutils-linux
new file mode 100644
index 0000000..4c0d373
--- /dev/null
+++ b/straper/db/public/cron/cron.d/zfsutils-linux
@@ -0,0 +1,7 @@
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+# TRIM the first Sunday of every month.
+24 0 1-7 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/trim ]; then /usr/lib/zfs-linux/trim; fi
+
+# Scrub the second Sunday of every month.
+24 0 8-14 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/scrub ]; then /usr/lib/zfs-linux/scrub; fi
diff --git a/straper/db/public/cron/cron.daily/.placeholder b/straper/db/public/cron/cron.daily/.placeholder
new file mode 100644
index 0000000..76cb8d0
--- /dev/null
+++ b/straper/db/public/cron/cron.daily/.placeholder
@@ -0,0 +1,2 @@
+# DO NOT EDIT OR REMOVE
+# This file is a simple placeholder to keep dpkg from removing this directory
diff --git a/straper/db/public/cron/cron.daily/0anacron b/straper/db/public/cron/cron.daily/0anacron
new file mode 100755
index 0000000..262530a
--- /dev/null
+++ b/straper/db/public/cron/cron.daily/0anacron
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# anacron's cron script
+#
+# This script updates anacron time stamps. It is called through run-parts
+# either by anacron itself or by cron.
+#
+# The script is called "0anacron" to assure that it will be executed
+# _before_ all other scripts.
+
+test -x /usr/sbin/anacron || exit 0
+anacron -u cron.daily
diff --git a/straper/db/public/cron/cron.daily/apt-compat b/straper/db/public/cron/cron.daily/apt-compat
new file mode 100755
index 0000000..bde3237
--- /dev/null
+++ b/straper/db/public/cron/cron.daily/apt-compat
@@ -0,0 +1,55 @@
+#!/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
diff --git a/straper/db/public/cron/cron.daily/disk-alert b/straper/db/public/cron/cron.daily/disk-alert
new file mode 100755
index 0000000..ea987a3
--- /dev/null
+++ b/straper/db/public/cron/cron.daily/disk-alert
@@ -0,0 +1,4 @@
+#!/bin/sh
+df -hP | awk '$5+0 >= 90 {print}' | \
+mail -s "Disk usage warning on $(hostname)" root
+
diff --git a/straper/db/public/cron/cron.daily/dpkg b/straper/db/public/cron/cron.daily/dpkg
new file mode 100755
index 0000000..899572d
--- /dev/null
+++ b/straper/db/public/cron/cron.daily/dpkg
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# Skip if systemd is running.
+if [ -d /run/systemd/system ]; then
+ exit 0
+fi
+
+/usr/libexec/dpkg/dpkg-db-backup
diff --git a/straper/db/public/cron/cron.daily/logrotate b/straper/db/public/cron/cron.daily/logrotate
new file mode 100755
index 0000000..1ac1570
--- /dev/null
+++ b/straper/db/public/cron/cron.daily/logrotate
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# skip in favour of systemd timer
+if [ -d /run/systemd/system ]; then
+ exit 0
+fi
+
+# this cronjob persists removals (but not purges)
+if [ ! -x /usr/sbin/logrotate ]; then
+ exit 0
+fi
+
+/usr/sbin/logrotate /etc/logrotate.conf
+EXITVALUE=$?
+if [ $EXITVALUE != 0 ]; then
+ /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
+fi
+exit $EXITVALUE
diff --git a/straper/db/public/cron/cron.daily/man-db b/straper/db/public/cron/cron.daily/man-db
new file mode 100755
index 0000000..4dd8ae0
--- /dev/null
+++ b/straper/db/public/cron/cron.daily/man-db
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# man-db cron daily
+
+set -e
+
+if [ -d /run/systemd/system ]; then
+ # Skip in favour of systemd timer.
+ exit 0
+fi
+
+# This should be set by cron, but apparently isn't always; see
+# https://bugs.debian.org/209185. Add fallbacks so that start-stop-daemon
+# can be found.
+export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"
+
+iosched_idle=
+# Don't try to change I/O priority in a vserver or OpenVZ.
+if ! grep -Eq '(envID|VxID):.*[1-9]' /proc/self/status && \
+ { [ ! -d /proc/vz ] || [ -d /proc/bc ]; }; then
+ iosched_idle='--iosched idle'
+fi
+
+if ! [ -d /var/cache/man ]; then
+ # Recover from deletion, per FHS.
+ install -d -o man -g man -m 0755 /var/cache/man
+fi
+
+# expunge old catman pages which have not been read in a week
+if [ -d /var/cache/man ]; then
+ cd /
+ # shellcheck disable=SC2086
+ start-stop-daemon --start --pidfile /dev/null --startas /bin/sh \
+ --oknodo --chuid man $iosched_idle -- -c \
+ "find /var/cache/man -type f -name '*.gz' -atime +6 -print0 | \
+ xargs -r0 rm -f"
+fi
+
+# regenerate man database
+if [ -x /usr/bin/mandb ]; then
+ # --pidfile /dev/null so it always starts; mandb isn't really a daemon,
+ # but we want to start it like one.
+ # shellcheck disable=SC2086
+ start-stop-daemon --start --pidfile /dev/null \
+ --startas /usr/bin/mandb --oknodo --chuid man \
+ $iosched_idle \
+ -- --no-purge --quiet
+fi
+
+exit 0
diff --git a/straper/db/public/cron/cron.daily/plocate b/straper/db/public/cron/cron.daily/plocate
new file mode 100755
index 0000000..e3b6c42
--- /dev/null
+++ b/straper/db/public/cron/cron.daily/plocate
@@ -0,0 +1,35 @@
+#! /bin/sh
+
+set -e
+
+UPDATEDB=/usr/sbin/updatedb.plocate
+
+# Skip if systemd timer is available.
+if [ -d /run/systemd/system ]; then
+ exit 0
+fi
+
+[ -x $UPDATEDB ] || exit 0
+
+if which on_ac_power >/dev/null 2>&1; then
+ ON_BATTERY=0
+ on_ac_power >/dev/null 2>&1 || ON_BATTERY=$?
+ if [ "$ON_BATTERY" -eq 1 ]; then
+ exit 0
+ fi
+fi
+
+# See ionice(1).
+IONICE=
+if [ -x /usr/bin/ionice ] &&
+ /usr/bin/ionice -c3 true 2>/dev/null; then
+ IONICE="/usr/bin/ionice -c3"
+fi
+
+# See nocache(1).
+NOCACHE=
+if [ -x /usr/bin/nocache ]; then
+ NOCACHE="/usr/bin/nocache"
+fi
+
+flock --nonblock /run/plocate.daily.lock $NOCACHE $IONICE nice $UPDATEDB
diff --git a/straper/db/public/cron/cron.daily/zfs-auto-snapshot b/straper/db/public/cron/cron.daily/zfs-auto-snapshot
new file mode 100755
index 0000000..14fe006
--- /dev/null
+++ b/straper/db/public/cron/cron.daily/zfs-auto-snapshot
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Only call zfs-auto-snapshot if it's available
+which zfs-auto-snapshot > /dev/null || exit 0
+
+exec zfs-auto-snapshot --quiet --syslog --label=daily --keep=31 //
diff --git a/straper/db/public/cron/cron.monthly/.placeholder b/straper/db/public/cron/cron.monthly/.placeholder
new file mode 100644
index 0000000..76cb8d0
--- /dev/null
+++ b/straper/db/public/cron/cron.monthly/.placeholder
@@ -0,0 +1,2 @@
+# DO NOT EDIT OR REMOVE
+# This file is a simple placeholder to keep dpkg from removing this directory
diff --git a/straper/db/public/cron/cron.monthly/0anacron b/straper/db/public/cron/cron.monthly/0anacron
new file mode 100755
index 0000000..1b094c0
--- /dev/null
+++ b/straper/db/public/cron/cron.monthly/0anacron
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# anacron's cron script
+#
+# This script updates anacron time stamps. It is called through run-parts
+# either by anacron itself or by cron.
+#
+# The script is called "0anacron" to assure that it will be executed
+# _before_ all other scripts.
+
+test -x /usr/sbin/anacron || exit 0
+anacron -u cron.monthly
diff --git a/straper/db/public/cron/cron.monthly/zfs-auto-snapshot b/straper/db/public/cron/cron.monthly/zfs-auto-snapshot
new file mode 100755
index 0000000..2ab823f
--- /dev/null
+++ b/straper/db/public/cron/cron.monthly/zfs-auto-snapshot
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Only call zfs-auto-snapshot if it's available
+which zfs-auto-snapshot > /dev/null || exit 0
+
+exec zfs-auto-snapshot --quiet --syslog --label=monthly --keep=12 //
diff --git a/straper/db/public/cron/cron.weekly/.placeholder b/straper/db/public/cron/cron.weekly/.placeholder
new file mode 100644
index 0000000..76cb8d0
--- /dev/null
+++ b/straper/db/public/cron/cron.weekly/.placeholder
@@ -0,0 +1,2 @@
+# DO NOT EDIT OR REMOVE
+# This file is a simple placeholder to keep dpkg from removing this directory
diff --git a/straper/db/public/cron/cron.weekly/0anacron b/straper/db/public/cron/cron.weekly/0anacron
new file mode 100755
index 0000000..d53cde3
--- /dev/null
+++ b/straper/db/public/cron/cron.weekly/0anacron
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# anacron's cron script
+#
+# This script updates anacron time stamps. It is called through run-parts
+# either by anacron itself or by cron.
+#
+# The script is called "0anacron" to assure that it will be executed
+# _before_ all other scripts.
+
+test -x /usr/sbin/anacron || exit 0
+anacron -u cron.weekly
diff --git a/straper/db/public/cron/cron.weekly/man-db b/straper/db/public/cron/cron.weekly/man-db
new file mode 100755
index 0000000..c2a55cb
--- /dev/null
+++ b/straper/db/public/cron/cron.weekly/man-db
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# man-db cron weekly
+
+set -e
+
+if [ -d /run/systemd/system ]; then
+ # Skip in favour of systemd timer.
+ exit 0
+fi
+
+# This should be set by cron, but apparently isn't always; see
+# https://bugs.debian.org/209185. Add fallbacks so that start-stop-daemon
+# can be found.
+export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin"
+
+iosched_idle=
+# Don't try to change I/O priority in a vserver or OpenVZ.
+if ! grep -Eq '(envID|VxID):.*[1-9]' /proc/self/status && \
+ { [ ! -d /proc/vz ] || [ -d /proc/bc ]; }; then
+ iosched_idle='--iosched idle'
+fi
+
+if ! [ -d /var/cache/man ]; then
+ # Recover from deletion, per FHS.
+ install -d -o man -g man -m 0755 /var/cache/man
+fi
+
+# regenerate man database
+if [ -x /usr/bin/mandb ]; then
+ # --pidfile /dev/null so it always starts; mandb isn't really a daemon,
+ # but we want to start it like one.
+ # shellcheck disable=SC2086
+ start-stop-daemon --start --pidfile /dev/null \
+ --startas /usr/bin/mandb --oknodo --chuid man \
+ $iosched_idle \
+ -- --quiet
+fi
+
+exit 0
diff --git a/straper/db/public/cron/cron.weekly/tor b/straper/db/public/cron/cron.weekly/tor
new file mode 100755
index 0000000..c30381b
--- /dev/null
+++ b/straper/db/public/cron/cron.weekly/tor
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+set -u
+
+DEFAULTSFILE=/etc/default/tor
+
+if [ -f $DEFAULTSFILE ] ; then
+ . $DEFAULTSFILE
+fi
+
+if [ "${CLEANUP_OLD_COREFILES:-}" = "y" ] ; then
+ if [ -d /var/lib/tor ] ; then
+ find /var/lib/tor -mindepth 1 -maxdepth 1 -type f -mtime +21 -user debian-tor -regex '.*/core\(\.[0-9]+\)?' -exec rm '{}' +
+ fi
+fi
diff --git a/straper/db/public/cron/cron.weekly/zfs-auto-snapshot b/straper/db/public/cron/cron.weekly/zfs-auto-snapshot
new file mode 100755
index 0000000..3aa977a
--- /dev/null
+++ b/straper/db/public/cron/cron.weekly/zfs-auto-snapshot
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Only call zfs-auto-snapshot if it's available
+which zfs-auto-snapshot > /dev/null || exit 0
+
+exec zfs-auto-snapshot --quiet --syslog --label=weekly --keep=8 //
diff --git a/straper/db/public/cron/crontab b/straper/db/public/cron/crontab
new file mode 100644
index 0000000..2551a00
--- /dev/null
+++ b/straper/db/public/cron/crontab
@@ -0,0 +1,22 @@
+# /etc/crontab: system-wide crontab
+# Unlike any other crontab you don't have to run the `crontab'
+# command to install the new version when you edit this file
+# and files in /etc/cron.d. These files also have username fields,
+# that none of the other crontabs do.
+
+SHELL=/bin/sh
+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+
+# Example of job definition:
+# .---------------- minute (0 - 59)
+# | .------------- hour (0 - 23)
+# | | .---------- day of month (1 - 31)
+# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
+# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
+# | | | | |
+# * * * * * user-name command to be executed
+17 * * * * root cd / && run-parts --report /etc/cron.hourly
+25 6 * * * root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.daily; }
+47 6 * * 7 root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.weekly; }
+52 6 1 * * root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.monthly; }
+#