]> oss.titaniummirror.com Git - ovzbpc.git/blobdiff - esata
Make the scsi host the esata script attempts to add a variable defined at the
[ovzbpc.git] / esata
diff --git a/esata b/esata
index 34398eb57e94a063290937473e9c080c171e186b..2f30b76cbecf2d0df7b51077c9ba677f3c2760f4 100755 (executable)
--- a/esata
+++ b/esata
@@ -3,6 +3,7 @@
 DEV=/dev/sdb2
 MNT=/media/esata
 DELAY=3
+ESATA_HOST=1
 
 registered() {
     if [ -b "$DEV" ]; then
@@ -27,7 +28,7 @@ mounted() {
 doregister() {
     registered && return 0
     [ -n "$VERBOSE" ] && echo "register SATA device"
-    scsiadd -a 1 0 0 0 >/dev/null || return 1
+    scsiadd -a $ESATA_HOST 0 0 0 >/dev/null || return 1
     sleep $DELAY
     registered || return 1
     [ -n "$VERBOSE" ] && echo "register ok"
@@ -47,7 +48,7 @@ domount() {
 dounregister() {
     registered || return 0
     [ -n "$VERBOSE" ] && echo "unregister SATA device"
-    scsiadd -r 1 0 0 0 >/dev/null || return 1
+    scsiadd -r $ESATA_HOST 0 0 0 >/dev/null || return 1
     sleep $DELAY
     registered && return 1
     [ -n "$VERBOSE" ] && echo "unregister ok"
@@ -55,11 +56,12 @@ dounregister() {
 }
 
 doumount() {
-    mounted || return 0
-    [ -n "$VERBOSE" ] && echo "unmount SATA $DEV"
-    umount "$MNT" || return 1
-    mounted && return 1
-    [ -n "$VERBOSE" ] && echo "unmount ok"
+    if mounted; then
+       [ -n "$VERBOSE" ] && echo "unmount SATA $DEV"
+       umount "$MNT" || return 1
+       mounted && return 1
+       [ -n "$VERBOSE" ] && echo "unmount ok"
+    fi
     dounregister || return 1
     return 0
 }
@@ -94,14 +96,14 @@ elif [ "$1" = "register" ]; then
     fi
 elif [ "$1" = "status" ]; then
     if mounted; then
-       echo "esata mounted on $DEV"
+       echo "esata mounted on $MNT"
     elif registered; then
        echo "esata registered as $DEV but not mounted"
     else
        echo "esata is unregistered"
     fi
     #mount | grep "$DEV"
-    #scsiadd -p | grep "scsi1"
+    #scsiadd -p | grep "scsi$ESATA_HOST"
 else
     echo "usage: $0 [-v] <mount|umount|register|status>"
 fi