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

. /etc_ro_fs/init.d/common
readconf /etc/firm.conf UPDATE_DECT_START_RESCUE_ON_USB_KEY


if [ -f /usr/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"
		echo "$current_date  USB STORAGE add" >> /root/adsld.log
		/usr/etc/init.d/usb_storage mount_all
		/usr/etc/init.d/samba update
		[ "$UPDATE_DECT_START_RESCUE_ON_USB_KEY" = "y" ] && loader_manager loader_rescue_from_usbkey
		;;
	remove)
		echo "remove storage device"
		/usr/etc/init.d/samba stop
		echo "$current_date  USB STORAGE remove" >> /root/adsld.log
		/usr/etc/init.d/usb_storage restart
		/usr/etc/init.d/samba start
		;;
esac	

