hal/tools/callouts fstab-update.sh,1.8,1.9

Joe Shaw joe at pdx.freedesktop.org
Mon May 17 14:55:52 PDT 2004


Update of /cvs/hal/hal/tools/callouts
In directory pdx:/tmp/cvs-serv4603/tools/callouts

Modified Files:
	fstab-update.sh 
Log Message:
2004-05-17  Joe Shaw  <joeshaw at novell.com>

	* tools/callouts/fstab-update.sh: Guard against the script being
	killed mid-execution by doing all the updates in a copy and then
	moving it over later on add.  Patch from Martin Waitz
	<tali at admingilde.org>.

Index: fstab-update.sh
===================================================================
RCS file: /cvs/hal/hal/tools/callouts/fstab-update.sh,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- a/fstab-update.sh	8 May 2004 19:00:32 -0000	1.8
+++ b/fstab-update.sh	17 May 2004 21:55:50 -0000	1.9
@@ -73,28 +73,34 @@
     # Add the device to fstab if it's not already there.
     grep "^$HAL_PROP_BLOCK_DEVICE" /etc/fstab > /dev/null
     if [ $? -ne 0 ]; then
-	echo -ne "$HAL_PROP_BLOCK_DEVICE\t" >> /etc/fstab
-	echo -ne "$MOUNTPOINT\t" >> /etc/fstab
+        cp /etc/fstab /etc/fstab-hal
+	echo -ne "$HAL_PROP_BLOCK_DEVICE\t" >> /etc/fstab-hal
+	echo -ne "$MOUNTPOINT\t" >> /etc/fstab-hal
 	# HAL might have autodetected the filesystem type for us - in that
         # case use it...
 	if test $HAL_PROP_VOLUME_FSTYPE; then
 	    if test $HAL_PROP_VOLUME_FSTYPE = "msdos"; then
-		echo -ne "vfat\t" >> /etc/fstab
+		echo -ne "vfat\t" >> /etc/fstab-hal
 	    else
-		echo -ne "$HAL_PROP_VOLUME_FSTYPE\t" >> /etc/fstab
+		echo -ne "$HAL_PROP_VOLUME_FSTYPE\t" >> /etc/fstab-hal
 	    fi
 	else
-	    echo -ne "auto\t" >> /etc/fstab
+	    echo -ne "auto\t" >> /etc/fstab-hal
 	fi
-	echo -e  "noauto,user,exec 0 0" >> /etc/fstab
+	echo -e  "noauto,user,exec 0 0" >> /etc/fstab-hal
+
+        # Make sure it's here
+        if [ -f /etc/fstab-hal -a -s /etc/fstab-hal ]; then
+            mv -f /etc/fstab-hal /etc/fstab
+        fi
     fi
 
 elif test "$1" = "remove"; then
-    grep -v "$MOUNTPOINT" /etc/fstab > /etc/fstab-tmp
+    grep -v "$MOUNTPOINT" /etc/fstab > /etc/fstab-hal
 
     # Make sure it's here
-    if [ -f /etc/fstab-tmp -a -s /etc/fstab-tmp ]; then
-	mv -f /etc/fstab-tmp /etc/fstab
+    if [ -f /etc/fstab-hal -a -s /etc/fstab-hal ]; then
+	mv -f /etc/fstab-hal /etc/fstab
     fi
 
     if [ -d $MOUNTPOINT ]; then





More information about the hal-commit mailing list