#!/bin/bash

# chkconfig: 345 99 15
# description: depmod userlink.o for ppxp and insmod

MOD=/lib/modules/misc/userlink.o

case "$1" in
  start)
	echo -n "Starting userlink: "
	if [ ! -f $MOD ] ; then
	  echo can\'t fine $MOD
	else
	  echo -n "depmod "
	  /sbin/depmod $MOD > /dev/null
	  echo -n "modprobe "
	  /sbin/modprobe $MOD > /dev/null
	  if /sbin/lsmod | /bin/grep -q userlink ; then
	    echo : success.
          else
            echo : failed.
	    echo Please rebuild userlink package!
            /bin/sleep 5
          fi
	fi
	;;
  stop)
	echo -n "Stopping userlink: "
	echo -n "ppxpd "
	/usr/bin/killall ppxpd > /dev/null
	/bin/sleep 1
	echo -n "userlink "
	/sbin/rmmod userlink > /dev/null
	echo
	;;
  restart)
	$0 stop
        $0 start
	;;
  *)
	echo "Usage: ppxp {start|stop|restart}"
	exit 1
	;;
esac

exit 0
