#!/bin/bash

### BEGIN INIT INFO
# Provides:	  udisks-glue
# Required-Start: $local_fs 
# Required-Stop: $local_fs
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: udisks-glue automounter 
# Description: Automounts removable media 
### END INIT INFO

. /lib/lsb/init-functions

NAME=udisks-glue
PIDFILE=/var/run/udisks.pid
DAEMON="/usr/bin/udisks-glue"
DAEMON_OPTS="-c /etc/udisks-glue.conf"

case "$1" in
	start)
		log_daemon_msg "Starting Automounter" "$NAME"
		start-stop-daemon --start --exec $DAEMON -- $DAEMON_OPTS -p $PIDFILE
		log_end_msg $?
		;;
	stop)
		log_daemon_msg "Stopping Automounter" "$NAME"
		start-stop-daemon --stop --exec $DAEMON
		log_end_msg $?
		rm -f $PIDFILE
		;;
	restart | force-reload)
		$0 stop && sleep 2 && $0 start
		;;
	try-restart)
		if $0 status >/dev/null; then
			$0 restart
		else
			exit 0
		fi
		;;
	reload)
		exit 3
		;;
	status)
		status_of_proc $DAEMON "udisks-glue"
		;;
	*)
		echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
		exit 2
	;;
esac