#!/bin/bash

PATH=/usr/bin:/usr/sbin

runlevel=default
for arg in $(cat /proc/cmdline); do
    if [ -d @RUNITDIR@/runsvdir/"$arg" ]; then
        echo "Runlevel detected: '$arg' (via kernel cmdline)"
        runlevel="$arg"
    fi
done

[ -x @RCDIR@/rc.local ] && @RCDIR@/rc.local
runsvchdir "${runlevel}"

ln -s @RUNSVDIR@/current @SERVICEDIR@

exec env - PATH=$PATH \
runsvdir -P @SERVICEDIR@ 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'
