diff options
author | EuAndreh <eu@euandre.org> | 2023-10-08 08:26:37 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-11-25 12:14:34 -0300 |
commit | e406d80377858f37ce683163b2b0ce45e59cfe9f (patch) | |
tree | ac2a4ba2543cc1b2507e8aa57acfc039e71cf3c8 /src/scripts/check.sh | |
parent | Initial empty commit (diff) | |
download | asami-e406d80377858f37ce683163b2b0ce45e59cfe9f.tar.gz asami-e406d80377858f37ce683163b2b0ce45e59cfe9f.tar.xz |
Init server infrastructure files
Diffstat (limited to 'src/scripts/check.sh')
-rwxr-xr-x | src/scripts/check.sh | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/scripts/check.sh b/src/scripts/check.sh new file mode 100755 index 0000000..5c63816 --- /dev/null +++ b/src/scripts/check.sh @@ -0,0 +1,92 @@ +#!/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, filesystem checks, 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 from $(id -un)@$(hostname)" "$alias@$(hostname)" +done + + +PARTITIONS=' +/dev/vda3 +/dev/vdb1 +/dev/vdc1 +' +set -x + +for part in $PARTITIONS; do + btrfs scrub start -B "$part" + btrfs check --force -p "$part" +done |