#!/bin/sh set -e : "${ADMIN_USER:?ADMIN_USER must be set}" main() { # 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. 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 "$@"