#!/bin/sh

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

daemon="/usr/local/sbin/keyctl"
daemon_user="_keyctl"
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/keyctl
rcctl enable keyctl
rcctl set keyctl flags server

mkdir /var/keyctl
groupadd _keyctl
useradd -d /var/keyctl -s /sbin/nologin -g _keyctl _keyctl
chown _keyctl:_keyctl /var/keyctl

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

then run: rcctl start keyctl
EOF
