#! /bin/sh
### BEGIN INIT INFO
# Provides:          getcred-fuse
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs $network
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Getgred using fuse
# Description:       Starts fuse daemon that allows transpartent invokation of libxos_getcred
### END INIT INFO



PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/getcred-fuse
NAME=getcred-fuse
DESC="getcred-fuse"
MOUNT_POINT=/home/user/.xosgetcred
DAEMON_OPTS=$MOUNT_POINT
USER=user
GROUP=users

test -x $DAEMON || exit 0


set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	mkdir $MOUNT_POINT 2>/dev/null || true
	chown $USER.$GROUP $MOUNT_POINT 
        
        uname -a |grep Nokia-N8 > /dev/null && NOKIA=yes
        if [ -n "$NOKIA" ]
        then
          HOME=/home/user
          . /etc/osso-af-init/af-defines.sh
          . /etc/osso-af-init/osso-gtk.defs
        fi
	start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	mount |grep $MOUNT_POINT && fusermount -u $MOUNT_POINT

	echo "$NAME."
	;;
  #reload)
	#
	#	If the daemon can reload its config files on the fly
	#	for example by sending it SIGHUP, do it here.
	#
	#	If the daemon responds to changes in its config file
	#	directly anyway, make this a do-nothing entry.
	#
	# echo "Reloading $DESC configuration files."
	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
	#	/var/run/$NAME.pid --exec $DAEMON
  #;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $N {start|stop}" >&2
	exit 1
	;;
esac

exit 0
