]> oss.titaniummirror.com Git - ovzbpc.git/blobdiff - esata
esata: new known state partitioned
[ovzbpc.git] / esata
diff --git a/esata b/esata
index 130eb803a45396e9ddd04cc8cb37e9acc2123ae4..f95995aee2f8ed1e653c21d585754d64e32bab63 100755 (executable)
--- a/esata
+++ b/esata
@@ -1,12 +1,20 @@
 #!/bin/bash
+#
+# esata
+# Version: __appVersion__
+#
+# Add, remove, mount, and unmount external SATA drives
 
-DEV=/dev/sdb2
+BASEDEV=/dev/sdc
+PARTITION=2
 MNT=/media/esata
+SCSIDEV=3 # This can change based on OS, bus enumeration, etc.
+# ----
+DEV=${BASEDEV}${PARTITION}
 DELAY=5
-SCSIDEV=1 # This can change based on OS, etc.
 
 registered() {
-    if [ -b "$DEV" ]; then
+    if [ -b "$BASEDEV" ]; then
        [ -n "$VERBOSE" ] && echo "registered"
        return 0
     else
@@ -15,6 +23,16 @@ registered() {
     fi
 }
 
+partitioned() {
+    if [ -b "$DEV" ]; then
+       [ -n "$VERBOSE" ] && echo "partitioned"
+       return 0
+    else
+       [ -n "$VERBOSE" ] && echo "not partitioned"
+       return 1
+    fi
+}
+
 mounted() {
     if mount | grep -q "$MNT"; then
        [ -n "$VERBOSE" ] && echo "mounted"
@@ -38,6 +56,7 @@ doregister() {
 domount() {
     mounted && return 0
     doregister || return 1
+    partitioned || return 1
     [ -n "$VERBOSE" ] && echo "mount SATA $DEV"
     mkdir -p "$MNT" || return 1
     mount "$DEV" "$MNT" || return 1
@@ -89,7 +108,8 @@ elif [ "$1" = "umount" -o "$1" = "unmount" ]; then
     fi
 elif [ "$1" = "register" ]; then
     if doregister; then
-       echo "esata registered as $DEV"
+       echo "esata drive registered as $BASEDEV"
+       partitioned || echo "WARNING: drive is not partitioned"
     else
        echo "$0: cannot register esata" >&2
        exit 1
@@ -98,7 +118,8 @@ elif [ "$1" = "status" ]; then
     if mounted; then
        echo "esata mounted on $MNT"
     elif registered; then
-       echo "esata registered as $DEV but not mounted"
+       echo "esata registered as $BASEDEV but not mounted"
+       partitioned || echo "WARNING: drive is not partitioned"
     else
        echo "esata is unregistered"
     fi