#!/bin/sh

cat <<'EOF'> /etc/rc.d/mailgo
#!/bin/ksh

daemon="/usr/local/sbin/mailgo"
daemon_user="_mailgo"
daemon_logger="daemon.info"

. /etc/rc.d/rc.subr

pexp=".*${daemon}.*"
rc_bg=YES
rc_reload=NO

rc_cmd $1
EOF
chmod 555 /etc/rc.d/mailgo
rcctl enable mailgo
rcctl set mailgo flags -addr "127.0.0.1:2525" -domain "example.com" -listen "127.0.0.1:7979"

groupadd _mailgo
useradd -d /var/empty -s /sbin/nologin -g _mailgo _mailgo

cat <<EOF
copy your mailgo binary to /usr/local/sbin/mailgo

then run: rcctl start mailgo
EOF
