#!/bin/sh # Provision a FreeBSD 15.1 host for the rChat relay (run as root). set -eu # Service user: no login shell, home /var/db/rchat (created below), the same # as install.sh. if ! pw usershow rchat >/dev/null 2>&1; then pw useradd rchat -c "rChat relay" -d /var/db/rchat -s /usr/sbin/nologin fi RCHAT_UID=$(id -u rchat) install -d -o root -g rchat -m 0750 /usr/local/etc/rchat install -d -o rchat -g rchat -m 0700 /var/db/rchat install -d -o rchat -g rchat -m 0750 /var/log/rchat # Let only the rchat user bind :443 (mac_portacl), nothing else unprivileged # may bind a low port. sysrc -f /boot/loader.conf mac_portacl_load="YES" >/dev/null kldstat -q -m mac_portacl || kldload mac_portacl cat > /etc/sysctl.conf.local </dev/null # Logs rotated daily, 14 kept; daemon -H reopens on SIGHUP. mkdir -p /usr/local/etc/newsyslog.conf.d cat > /usr/local/etc/newsyslog.conf.d/rchat.conf </dev/null sysrc clear_tmp_enable=YES >/dev/null echo "provisioned (rchat uid ${RCHAT_UID})"