]> 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 dbff012bf55376b9072445e2e32d4e00caf6073e..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
 }
@@ -101,7 +103,7 @@ elif [ "$1" = "status" ]; then
        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