#!/bin/sh # Mount and view device # License : GNU GPL # (c) Eko M. Budi, 2004 # (c) Vector Linux, 2004 DEVICES="$*" [ -z "$DEVICES" ] && DEVICES="/dev/cdwriter /dev/dvd /dev/cdrom" for DEV in $DEVICES; do # Find entry in /etc/fstab echo Trying $DEV ... LINE=`grep -e "^\s*$DEV" /etc/fstab` if [ $? = 0 ]; then # Get the mount point MNT=`echo $LINE | cut -f2 -d ' '` # Test if mount point has being mounted df | grep "$MNT" > /dev/null if [ $? = 0 ]; then echo "$MNT has being mounted" DEV="" else echo "Going to mount it at $MNT" if ! mount $MNT; then continue; fi # Give time to settle sleep 3 fi # explore it explorer $MNT # unmount if necessary if [ "$DEV" ]; then umount $MNT if [ ! $? = 0 ]; then echo "WARNING" "Could not unmount $DEV." fi fi exit 0 fi done message "ERROR" "Could not find any device: " "$DEVICES" exit 1