X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Fgrml-udev-rebuildfstab;h=3e64e1b5bcc8ecb1ac66e64a153f28b33673a77e;hb=refs%2Fheads%2Fmaster;hp=e652e3d36362eb88a22aae1889bcc714693abf46;hpb=cc5cfdb35bc51b29b5bdb116ee4a02a6c5859497;p=grml-udev-config.git diff --git a/scripts/grml-udev-rebuildfstab b/scripts/grml-udev-rebuildfstab index e652e3d..3e64e1b 100755 --- a/scripts/grml-udev-rebuildfstab +++ b/scripts/grml-udev-rebuildfstab @@ -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 @@ -53,10 +53,6 @@ if grep -q " nofstab" /proc/cmdline ; then bailout 0 fi -grep -q 'nolabel' /proc/cmdline && NOLABEL='TRUE' || LABEL='TRUE' - - - if [ "$CONFIG_FSTAB" = "no" ] ; then bailout 0 fi @@ -67,6 +63,26 @@ if grep -q ' $MOUNTPOINT_PREFIX ' /proc/mounts ; then bailout 1 fi +LABEL=true # by default use labels + +if [ -r /etc/grml/rebuildfstab.conf ] ; then + logit 'Reading /etc/grml/rebuildfstab.conf' + . /etc/grml/rebuildfstab.conf + + if [ "$LABEL" = "false" ] ; then + logit 'Disabling LABEL=... in /etc/fstab as requested via LABEL=false' + fi +fi + +# support overriding via boot option +if grep -q ' nolabel' /proc/cmdline ; then + LABEL=false +fi + +if grep -q ' label' /proc/cmdline ; then + LABEL=true +fi + # default directories {{{ if [ -d "$MOUNTPOINT_PREFIX" ] ; then [ -d "$MOUNTPOINT_PREFIX/floppy" ] || mkdir "$MOUNTPOINT_PREFIX/floppy" @@ -145,11 +161,11 @@ iso9660) break; ;; *) -if [ -n "$LABEL" ] && [ -n "$ID_FS_LABEL_ENC" ] ; then +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" @@ -241,10 +257,10 @@ fi options=noauto,user,dev,suid,exec case $ID_FS_TYPE in ntfs) - options=$options,umask=000 + options=$options,dmask=000,fmask=111 ;; vfat|msdos) - options=$options,umask=000 + options=$options,dmask=000,fmask=111 ;; ufs) options=$options,ro @@ -260,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 @@ -301,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 #################################################################