#!/bin/sh
### BEGIN INIT INFO
# Provides:          epoptes-client
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Epoptes client LTSP helper
# Description:       Helper sysvinit script that launches epoptes-client on
#                    LTSP clients, as they don't receive an if-up event.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/epoptes-client
NAME=epoptes-client
DESC="Epoptes client LTSP helper"

test -x "$DAEMON" || exit 0

# ltsp-build-client in LTSP versions prior to 5.3 used an RC_WHITELIST which
# resulted in the network service being deleted, and the clients not getting
# an if-up event.
# So we only need to run on LTSP chroots earlier than 5.3.
test -f /etc/ltsp_chroot || exit 0
grep -qs "init=/sbin/init-ltsp" /proc/cmdline && exit 0

case "$1" in
    start|restart|force-reload)
        "$DAEMON" &
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|force-reload}" >&2
        exit 1
    ;;
esac
