#!/bin/sh
# /etc/init.d/slim: Start, stop and restart Slim deamon on SliTaz, at boot
# time or with the command line.
#
# To start daemon at boot time, just put the right name in the $RUN_DAEMONS
# variable of /etc/rcS.conf and configure options with /etc/slim.conf.
#
. /etc/init.d/rc.functions

NAME=SLiM
DESC="Simple login manager"
DAEMON=/usr/bin/slim
OPTION="-d"
LOCK_FILE=/var/lock/slim.lock

case "$1" in
  start)
    if active_pidfile $LOCK_FILE slim ; then
      echo "$NAME already running."
      exit 1
    fi
    echo -n "Starting $DESC: $NAME... "
    $DAEMON $OPTION
    status
    ;;
  stop)
    if ! active_pidfile $LOCK_FILE slim ; then
      echo "$NAME is not running."
      exit 1
    fi
    echo -n "Stopping $DESC: $NAME... "
    killall slim
    rm $LOCK_FILE
    status
    ;;
  restart)
    if ! active_pidfile $LOCK_FILE slim ; then
      echo "$NAME is not running."
      exit 1
    fi
    echo -n "Restarting $DESC: $NAME... "
    killall slim
    rm $LOCK_FILE
    sleep 2
    $DAEMON $OPTION
    status
    ;;
  *)
    echo ""
    echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
    echo ""
    exit 1
    ;;
esac

exit 0
