#!/bin/bash if [[ -e @PRG_USER_HOME@/.usbwatch/prog.prefs ]] ; then source @PRG_USER_HOME@/.usbwatch/prog.prefs elif [[ -e /etc/X11/usbwatch/prog.prefs ]] ; then source /etc/X11/usbwatch/prog.prefs fi if [[ "$1" = "Remove" ]] ; then PARTS=`ls /var/run/usb/@DEVICE_NAME@* |grep -v menu |grep -v .ctl` for part in $PARTS ; do mpoint=`echo $part |rev |cut -f 1 -d_ |rev` su -c "echo 'Unmounting /mnt/usbwatch/$mpoint'" >> /var/log/usbwatch su -c "umount /mnt/usbwatch/$mpoint" rm -f @PRG_USER_HOME@/.usbwatch/$mpoint.lnk cp /var/run/usb/$mpoint-unmounted.lnk @PRG_USER_HOME@/.usbwatch/$mpoint.lnk # sleep .5 done su - @PRG_USER@ -c "kill -2 `pgrep -u @PRG_USER@ usbwatch`" DISPLAY=$DISPLAY /usr/X11R6/bin/xmessage 'Device can now be removed' & elif [[ "$1" = "MountAll" ]] ; then PARTS=`ls /var/run/usb/@DEVICE_NAME@* |grep -v menu |grep -v .ctl` for part in $PARTS ; do mpoint=`echo $part |rev |cut -f 1 -d_ |rev` su -c "echo 'Mounting /mnt/usbwatch/$mpoint'" >> /var/log/usbwatch #su -c "umount /mnt/usbwatch/$part" su -c "mount -t @PART_TYPE@ -o @MOUNT_OPTIONS@ @disk@ @BASE_MOUNT_POINT@/@part@" rm -f @PRG_USER_HOME@/.usbwatch/$mpoint.lnk cp /var/run/usb/$mpoint-mounted.lnk @PRG_USER_HOME@/.usbwatch/$mpoint.lnk done su - @PRG_USER@ -c "kill -2 `pgrep -u @PRG_USER@ usbwatch`" DISPLAY=$DISPLAY /usr/X11R6/bin/xmessage -buttons '' -timeout 1 'All partitions have been mounted' & elif [[ "$1" = "UnmountAll" ]] ; then PARTS=`ls /var/run/usb/@DEVICE_NAME@* |grep -v menu |grep -v .ctl` for part in $PARTS ; do mpoint=`echo $part |rev |cut -f 1 -d_ |rev` su -c "echo 'Unmounting /mnt/usbwatch/$mpoint'" >> /var/log/usbwatch su -c "umount /mnt/usbwatch/$mpoint" rm -f @PRG_USER_HOME@/.usbwatch/$mpoint.lnk cp /var/run/usb/$mpoint-unmounted.lnk @PRG_USER_HOME@/.usbwatch/$mpoint.lnk # sleep .5 done su - @PRG_USER@ -c "kill -2 `pgrep -u @PRG_USER@ usbwatch`" DISPLAY=$DISPLAY /usr/X11R6/bin/xmessage -buttons '' -timeout 1 "All partitions have been unmounted" & elif [[ "$1" = "Quit" ]] ; then pkill -9 -u @PRG_USER@ Xusb-hotmount pkill -9 -u @PRG_USER@ usbwatch fi