aboutsummaryrefslogtreecommitdiff
path: root/straper/db/public/cron/cron.daily
diff options
context:
space:
mode:
Diffstat (limited to 'straper/db/public/cron/cron.daily')
-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
9 files changed, 190 insertions, 0 deletions
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 //