File pbbuttonsd-0.8.1a-udev.diff of Package pbbuttonsd
Index: pbbuttonsd-0.8.1a/scripts/scripts.d/laptopmode.sh
===================================================================
--- pbbuttonsd-0.8.1a.orig/scripts/scripts.d/laptopmode.sh
+++ pbbuttonsd-0.8.1a/scripts/scripts.d/laptopmode.sh
@@ -13,6 +13,8 @@
#
# Original Linux 2.4 version by: Jens Axboe
+shopt -s extglob
+
# Remove an option (the first parameter) of the form option=<number> from
# a mount options string (the rest of the parameters).
parse_mount_opts () {
@@ -63,7 +65,16 @@ parse_yesno_opts_wfstab () {
PARSEDOPTS1="$(parse_nonumber_mount_opts $OPT $L_OPTS)"
PARSEDOPTS1="$(parse_nonumber_mount_opts no$OPT $PARSEDOPTS1)"
# Watch for a default atime in fstab
- FSTAB_OPTS="$(cat /etc/fstab | tr -s "[:blank:]" " " | grep ^\ *"$L_DEV " | awk '{ print $4 }')"
+ #FSTAB_OPTS="$(cat /etc/fstab | tr -s "[:blank:]" " " | grep ^\ *"$L_DEV " | awk '{ print $4 }')"
+ # take care of persitant device names
+ if [ -f /sbin/udevadm ] ; then
+ PATT="${L_DEV#/dev/} $(/sbin/udevadm info -q symlink -n $L_DEV)"
+ PATT=${PATT// /|}
+ else
+ PATT="${L_DEV#/dev/}"
+ fi
+
+ FSTAB_OPTS=$(cat /etc/fstab | while read d f f f i; do if [[ $d == /dev/@($PATT)* ]]; then echo $f ; fi ; done)
if [ -z "$(echo "$FSTAB_OPTS" | grep "$OPT")" ] ; then
# option not specified in fstab -- choose the default.
echo "$PARSEDOPTS1,$DEF_OPT"
@@ -99,7 +110,16 @@ parse_mount_opts_wfstab () {
PARSEDOPTS1="$(parse_mount_opts $OPT $L_OPTS)"
# Watch for a default commit in fstab
- FSTAB_OPTS="$(cat /etc/fstab | sed 's/ / /g' | grep ^\ *"$L_DEV " | awk '{ print $4 }')"
+ #FSTAB_OPTS="$(cat /etc/fstab | sed 's/ / /g' | grep ^\ *"$L_DEV " | awk '{ print $4 }')"
+ # take care of persitant device names
+ if [ -f /sbin/udevadm ] ; then
+ PATT="${L_DEV#/dev/} $(/sbin/udevadm info -q symlink -n $L_DEV)"
+ PATT=${PATT// /|}
+ else
+ PATT="${L_DEV#/dev/}"
+ fi
+
+ FSTAB_OPTS=$(cat /etc/fstab | while read d f f f i; do if [[ $d == /dev/@($PATT)* ]]; then echo $f ; fi ; done)
if [ -z "$(echo "$FSTAB_OPTS" | grep "$OPT=")" ] ; then
# option not specified in fstab: set it to 0
echo "$PARSEDOPTS1,$OPT=0"