diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-09-10 21:02:02 -0700 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-11 18:33:34 -0700 |
| commit | c9194b12185dc0be68184376fb2935d82b6cf6ae (patch) | |
| tree | 40f509b7d37938dfe835ec414b19e7fa8fafca55 /scripts/setup.sh | |
| parent | Initial Commit (diff) | |
| download | site-server-images-c9194b12185dc0be68184376fb2935d82b6cf6ae.zip | |
Add afterboot vm initialization setup script and makefile
Diffstat (limited to 'scripts/setup.sh')
| -rwxr-xr-x | scripts/setup.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 0000000..e4dc169 --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,25 @@ +#!/bin/sh +set -e + +: "${ADMIN_USER:?ADMIN_USER must be set}" + +main() { + # Ensure the time in the VM is in sync. If it is not, things like upgrading + # the system packages via pkg_add -u fail. + rdate -n pool.ntp.org + pkg_add -u + + fw_update + install_system_maintenance_cron_jobs + usermod -G _shutdown "$ADMIN_USER" # Allow the admin user to shutdown the system without root. +} + +install_system_maintenance_cron_jobs() { + ( + echo "MAILTO=$ADMIN_USER" # Send mail about root cron jobs to the admin user. + crontab -l 2>/dev/null # Print existing cron file; redirect stderr if empty cron file error. + echo "10 12 * * * /usr/sbin/syspatch -c" # Install any outstanding patches everyday at 12:10 + ) | crontab - +} + +main "$@" |