#!/bin/sh

CMD="$1"

# For compatibility with other platforms that call rcS with no
# arguments at start
if [ $# -eq 0 ]; then
    CMD="start"
fi

rcS_start() {
    stty -F /dev/console sane
    exec > /dev/kmsg 2>&1
}

# This is called from systemd's sysvinit ExecStop rule
rcS_stop() {
    # Kill all processes
    #[ -x /usr/sbin/killall5 ] && /usr/sbin/killall5 -9

    # Call the platform shutdown script
    /etc/init.d/shutdown
}

case $CMD in
  start)
    rcS_start
    ;;
  stop)
    rcS_stop
    ;;
  *)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac

exit 0
