#!/bin/sh
# chargement d'un peripherique de stockage usb
#

if [ -f /etc/init.d/ntp ]; then
    if [ -f /var/run/ntp_delta ]; then
        current_date=$(date -n +"%Y/%m/%d %X")
    else
        current_date=$(date +"%j ------ %X")
    fi
else
    current_date=$(date +"%j %X")
fi

case $ACTION in
        add)
        	echo "add storage device"
        	/etc/init.d/usb_storage mount_all
		
		#to be replaced by aleksa's magic MBUS plugin
		/etc/init.d/upnpav start
		/etc/init.d/samba start
		/etc/init.d/pureftp start	
		
		if test -e /usr/bin/setdefvusr; then
		    /usr/bin/setdefvusr
		fi
            	;;
        remove)
        	echo "remove storage device"
		/etc/init.d/pureftp stop		
		/etc/init.d/upnpav stop
        	/etc/init.d/samba stop
		echo "unmounting all usb mass storage devices"
        	/etc/init.d/usb_storage restart
            	;;
esac
