#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

. /usr/share/runit/scripts/runit-functions.sh
. /etc/runit/config/system.conf

SERVICE1=cleanup

load_service(){
    install -m0664 -o root -g utmp /dev/null /run/utmp
    if [ ! -e /var/log/wtmp ]; then
        install -m0664 -o root -g utmp /dev/null /var/log/wtmp
    fi
    if [ ! -e /var/log/btmp ]; then
        install -m0600 -o root -g utmp /dev/null /var/log/btmp
    fi

    rm -f /etc/nologin /forcefsck /forcequotacheck /fastboot

    [ "$CLEANTMP" = y ] && rm -rf /tmp/*
}

unload_service(){
	halt -w
}

# MAIN START
stat_busy "Starting $SERVICE1"
load_service || stat_die $SERVICE1
add_daemon $SERVICE1
stat_done $SERVICE1


#~ # MAIN STOP
#~ stat_busy "Stopping $SERVICE1"
#~ unload_service || stat_die $SERVICE1
#~ rm_daemon $SERVICE1
#~ stat_done $SERVICE1
