From 146865f1900cb9826fb5e09a63082a42ebb01e2f Mon Sep 17 00:00:00 2001 From: Turbo Fredriksson Date: Tue, 2 Jun 2015 16:02:31 +0200 Subject: [PATCH] SYSV init script fixes. * Change the order of the function library check/load. Redhat based system _can_ have a /lib/lsb/init-functions file (from the redhat-lsb-core package), but it's only partially what we can use. Instead, look for that file last, giving the script a chance to catch the 'real' distribution file. * Filter out dashes in dataset name in read_mtab(). * If find/awk doesn't exist but 'busybox' do, create a wrapper function. Signed-off-by: Turbo Fredriksson turbo@bayour.com Closes #3463 Closes #3457 --- etc/init.d/zfs-functions.in | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/etc/init.d/zfs-functions.in b/etc/init.d/zfs-functions.in index 17805ebec295..943db4d5fe5f 100644 --- a/etc/init.d/zfs-functions.in +++ b/etc/init.d/zfs-functions.in @@ -13,15 +13,15 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin # Source function library -if [ -f /lib/lsb/init-functions ]; then - # LSB, Debian GNU/Linux and derivates - . /lib/lsb/init-functions -elif [ -f /etc/rc.d/init.d/functions ]; then +if [ -f /etc/rc.d/init.d/functions ]; then # RedHat and derivates . /etc/rc.d/init.d/functions elif [ -L /etc/init.d/functions.sh ]; then # Gentoo . /etc/init.d/functions.sh +elif [ -f /lib/lsb/init-functions ]; then + # LSB, Debian GNU/Linux and derivates + . /lib/lsb/init-functions fi # Of course the functions we need are called differently @@ -87,6 +87,22 @@ else zfs_log_progress_msg() { echo -n "$1"; } fi +if ! type find > /dev/null 2>&1 ; then + # 'find' is needed by zfs-import. + if type busybox > /dev/null 2>&1 ; then + # No find, but we have busybox. + find() { busybox find "$@"; } + fi +fi + +if ! type awk > /dev/null 2>&1 ; then + # 'awk' is needed by zfs-mount. + if type busybox > /dev/null 2>&1 ; then + # No awk, but we have busybox. + awk() { busybox awk "$@"; } + fi +fi + # Paths to what we need ZFS="@sbindir@/zfs" ZED="@sbindir@/zed" @@ -373,7 +389,8 @@ read_mtab() while read -r fs mntpnt fstype opts rest; do if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then - mntpnt=$(printf '%b\n' "$mntpnt" | sed 's,/,_,g') + mntpnt=$(printf '%b\n' "$mntpnt" | sed -e 's,/,_,g' \ + -e 's,-,_,g') eval export MTAB_$mntpnt="$fs" fi done < /proc/mounts