Release new version 0.6.1
[grml-udev-config.git] / scripts / grml-udev-rebuildfstab
index c0371cf..3e64e1b 100755 (executable)
@@ -32,7 +32,7 @@ echo "$$" > /var/run/rebuildfstab.pid
 umask 022
 
 
-[ -e /etc/grml/autconfig ] && . /etc/grml/autoconfig
+[ -e /etc/grml/autoconfig ] && . /etc/grml/autoconfig
 
 if ! [ -w "$(dirname $MNTFILE)" ] ; then
    echo "$0: can not write to $MNTFILE">&2
@@ -165,7 +165,7 @@ if "$LABEL" && [ -n "$ID_FS_LABEL_ENC" ] ; then
   # see check_for_label() in scanpartitions for details
   case $ID_FS_LABEL_ENC in
     *\x*)
-      addinfo=" # special char in label ($ID_FS_LABEL_ENC) not supported"
+      logit "special char in label ($ID_FS_LABEL_ENC) not supported, skipping label for $DEVNAME"
       break ;;
     *)
       echo "LABEL=$ID_FS_LABEL_ENC"
@@ -276,12 +276,20 @@ ntfs|vfat|msdos)
         ;;
 esac
 
+# when we don't use labels then write the label information into the comment
+if ! "$LABEL" && [ -n "$ID_FS_LABEL_ENC" ] ; then
+  addinfo="# LABEL=$ID_FS_LABEL_ENC"
+  devinfo=""
+else # otherwise (when using labels) write the device name into the comment
+  devinfo="# $DEVNAME"
+fi
+
 case $ACTION in
 add|change)
 (
     flock -x 200
     echo "$ADDEDBYGRML $DEVNAME" >> /etc/fstab
-    echo "$device $mountpoint $ID_FS_TYPE $options 0 0 $addinfo # $DEVNAME" >> /etc/fstab
+    echo "$device $mountpoint $ID_FS_TYPE $options 0 0 ${addinfo}${devinfo}" >> /etc/fstab
 ) 200>/var/run/rebuildfstab.lock
 
 
@@ -317,6 +325,12 @@ if [ -r "$MNTFILE" ] ; then
    cat $TMPFILE > $MNTFILE
 fi
 
+# ensure systemd uses recent fstab configuration
+if [ -d /run/systemd/system ]; then
+  logit 'Reloading systemd manager configuration to use current fstab'
+  systemctl daemon-reload
+fi
+
 bailout 0
 
 ## END OF FILE #################################################################