aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-03-15 14:44:08 -0300
committerEuAndreh <eu@euandre.org>2023-03-15 14:45:05 -0300
commitcef4a6eb0dcac1ad5ce919c61edea25d50b1db1d (patch)
tree09ad8589c316f2aeb1216e93ab44c866cd7830b4 /src
parentsystem.scm: Fix duplicate NS entry in reverse IP zones (diff)
downloadtoph-cef4a6eb0dcac1ad5ce919c61edea25d50b1db1d.tar.gz
toph-cef4a6eb0dcac1ad5ce919c61edea25d50b1db1d.tar.xz
system.scm: Add daily cronjob for system checks
check.sh: sends emails to important RFC aliases, so that one verifies it daily.
Notes
See CI logs with: git notes --ref=refs/notes/ci-logs show cef4a6eb0dcac1ad5ce919c61edea25d50b1db1d git notes --ref=refs/notes/ci-data show cef4a6eb0dcac1ad5ce919c61edea25d50b1db1d Exit status: 0 Duration: 20
Diffstat (limited to 'src')
-rw-r--r--src/infrastructure/guix/system.scm2
-rwxr-xr-xsrc/infrastructure/scripts/check.sh79
2 files changed, 81 insertions, 0 deletions
diff --git a/src/infrastructure/guix/system.scm b/src/infrastructure/guix/system.scm
index 501c136..d744624 100644
--- a/src/infrastructure/guix/system.scm
+++ b/src/infrastructure/guix/system.scm
@@ -312,6 +312,7 @@
(list
(script "r" (file "src/infrastructure/scripts/r.sh"))
(script "gc" (file "src/infrastructure/scripts/gc.sh"))
+ (script "check" (file "src/infrastructure/scripts/check.sh"))
(script "backup" (file "src/infrastructure/scripts/backup.sh"))
(script "deploy" (file "src/infrastructure/scripts/deploy.sh"))
(script "report" (file "src/infrastructure/scripts/report.sh"))
@@ -347,6 +348,7 @@
(mcron-configuration
(jobs
(list
+ #~(job "0 0 * * *" "cronjob check")
#~(job "0 1 * * *" "cronjob env BORG_REPO=/mnt/backup/borg backup -q cron")
#~(job "0 2 * * *" "cronjob backup -q cron")
#~(job "0 3 * * 0" "cronjob gc")
diff --git a/src/infrastructure/scripts/check.sh b/src/infrastructure/scripts/check.sh
new file mode 100755
index 0000000..53d088c
--- /dev/null
+++ b/src/infrastructure/scripts/check.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ check
+ check -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+
+ Options:
+ -h, --help show this message
+
+
+ Run system sanity checks, such as email reachability, alarms
+ reachability, etc.
+
+
+ Examples:
+
+ Just run it
+
+ $ check
+ EOF
+}
+
+
+for flag in "$@"; do
+ case "$flag" in
+ --)
+ break
+ ;;
+ --help)
+ usage
+ help
+ exit
+ ;;
+ *)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
+if [ "$(id -un)" != 'root' ]; then
+ printf 'This script must be run as root.\n\n' >&2
+ usage >&2
+ exit 2
+fi
+
+
+uuid() {
+ od -xN20 /dev/urandom |
+ head -n1 |
+ awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}'
+}
+
+for alias in abuse admin postmaster hostmaster; do
+ uuid | mail -s "\"$alias\" alias test" "$alias@$(hostname)"
+done