DSL Ideas and Suggestions :: dsl-functions



The following patch fixes a couple of minor annoyances with /etc/init.d/dsl-functions:

* find_mountpoint greps mtab and fstab to find where the mountpoint for a given device should be. If the fstab contains two lines like these:

Code Sample
#/dev/hda1 /some/mountpoint ...
/dev/hda1 /some/other/mountpoint ...


then find_mountpoint will return both mountpoints when it should just return the uncommented one. This can be fixed by using ^ in the regular expression to match from beginning of the line.

* Send output of mount/umount commands to /dev/null when autoscaning for backup.tar.gz. This prevents the following error messages being shown on bootup:

mount: no medium found
umount: /mnt/auto/cdrom is not mounted

Code Sample
--- ../original/dsl-1.5/source/etc/init.d/dsl-functions 2005-07-15 21:25:48.000000000 +0100
+++ source/etc/init.d/dsl-functions     2005-10-04 18:26:56.000000000 +0100
@@ -82,13 +82,13 @@
 MOUNTED="no"
 DEVICE="$1"
 D2="/dev/$DEVICE\>"
- MOUNTPOINT="$(grep -i $D2   /etc/mtab|awk '{print $2}')"
+ MOUNTPOINT="$(grep -i ^$D2   /etc/mtab|awk '{print $2}')"
 if [ -n "$MOUNTPOINT" ]; then
   MOUNTED="yes"
   return
 fi

- MOUNTPOINT="$(grep -i $D2   /etc/fstab|awk '{print $2}')"
+ MOUNTPOINT="$(grep -i ^$D2   /etc/fstab|awk '{print $2}')"
}

get_mountpoint() {
@@ -109,13 +109,13 @@
   get_mountpoint $DEVICE
   if [ -n "$MOUNTPOINT" ]; then
     if [ "$MOUNTED" == "no" ]; then
-       mount "$MOUNTPOINT"
+       mount "$MOUNTPOINT">/dev/null 2>&1
     fi
     if [ -f "$MOUNTPOINT"/$1 ]; then
       FOUND="yes"
     fi
     if [ "$MOUNTED" == "no" ]; then
-       umount "$MOUNTPOINT"
+       umount "$MOUNTPOINT">/dev/null 2>&1
     fi
     if [ -n "$FOUND" ]; then
       echo "$DEVICE"

Thanks, friedgold. Agreed. Will be in next release.

original here.