aboutsummaryrefslogtreecommitdiff
path: root/src/infrastructure/scripts/check.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/infrastructure/scripts/check.sh')
-rwxr-xr-xsrc/infrastructure/scripts/check.sh79
1 files changed, 79 insertions, 0 deletions
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