diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-09-18 18:12:59 -0700 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-11 18:33:34 -0700 |
| commit | f18cc4b8df624ed1a4911a597ba6830b264a5c26 (patch) | |
| tree | 26be39391ad7202c5fa9bf3e1710b020c492b3c3 | |
| parent | Use nopass in doas.conf (diff) | |
| download | site-server-images-f18cc4b8df624ed1a4911a597ba6830b264a5c26.zip | |
Refactor setup script
| -rwxr-xr-x | scripts/setup.sh | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/scripts/setup.sh b/scripts/setup.sh index 460e569..320d93d 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -4,22 +4,29 @@ set -e : "${ADMIN_USER:?ADMIN_USER must be set}" main() { + update_pkgs + install_system_maintenance_cron_jobs "$ADMIN_USER" + allow_user_non_root_shutdown "$ADMIN_USER" +} + +update_pkgs() { # Ensure the time 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. + echo "MAILTO=$1" # 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 - } +allow_user_non_root_shutdown() { + usermod -G _shutdown "$1" +} + main "$@" |