aboutsummaryrefslogtreecommitdiffstats
path: root/openbsd-image/scripts
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2026-09-22 17:00:53 -0700
committerEugene Triguba <hello@eugenetriguba.com>2026-10-11 18:33:35 -0700
commitc9cfdbf86f2bf620c986abb2f67dcaabf5b01047 (patch)
tree23be01d9eb5cee38e1919e83d633ceff977f8f78 /openbsd-image/scripts
parentRemove need for explicit memory var override (diff)
downloadsite-server-images-c9cfdbf86f2bf620c986abb2f67dcaabf5b01047.zip
Add support for hcloud openbsd image snapshot
Diffstat (limited to 'openbsd-image/scripts')
-rwxr-xr-xopenbsd-image/scripts/harden-root.sh12
-rwxr-xr-xopenbsd-image/scripts/setup.sh32
2 files changed, 44 insertions, 0 deletions
diff --git a/openbsd-image/scripts/harden-root.sh b/openbsd-image/scripts/harden-root.sh
new file mode 100755
index 0000000..c8e267a
--- /dev/null
+++ b/openbsd-image/scripts/harden-root.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+set -e
+
+main() {
+ chown root:wheel /etc/doas.conf
+ chmod 0640 /etc/doas.conf
+ usermod -p '*' root
+ sed -i 's/^PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
+ rcctl reload sshd
+}
+
+main "$@"
diff --git a/openbsd-image/scripts/setup.sh b/openbsd-image/scripts/setup.sh
new file mode 100755
index 0000000..320d93d
--- /dev/null
+++ b/openbsd-image/scripts/setup.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+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() {
+ (
+ 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 "$@"