From 4853ac3d530e821f948f18f6bedacf9e3857ef2b Mon Sep 17 00:00:00 2001 From: "Ricardo M. Correia" Date: Tue, 9 Mar 2010 14:50:15 -0800 Subject: [PATCH 1/2] Fix scripts to work when invoked from other directories. --- scripts/common.sh | 6 ++++-- scripts/zconfig.sh | 6 ++++-- scripts/zfs.sh | 6 ++++-- scripts/zpool-create.sh | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/common.sh b/scripts/common.sh index c8b1ba3176..3c6e8a5ec7 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -5,9 +5,11 @@ # utilities will be used. If no .script-config can be found then the # installed kernel modules and utilities will be used. +basedir="$(dirname $0)" + SCRIPT_CONFIG=.script-config -if [ -f ../${SCRIPT_CONFIG} ]; then -. ../${SCRIPT_CONFIG} +if [ -f "${basedir}/../${SCRIPT_CONFIG}" ]; then +. "${basedir}/../${SCRIPT_CONFIG}" else MODULES=(zlib_deflate spl zavl znvpair zunicode zcommon zfs) fi diff --git a/scripts/zconfig.sh b/scripts/zconfig.sh index 2968ad8dc0..52dfc6897a 100755 --- a/scripts/zconfig.sh +++ b/scripts/zconfig.sh @@ -2,9 +2,11 @@ # # ZFS/ZPOOL configuration test script. +basedir="$(dirname $0)" + SCRIPT_COMMON=common.sh -if [ -f ./${SCRIPT_COMMON} ]; then -. ./${SCRIPT_COMMON} +if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then +. "${basedir}/${SCRIPT_COMMON}" elif [ -f /usr/libexec/zfs/${SCRIPT_COMMON} ]; then . /usr/libexec/zfs/${SCRIPT_COMMON} else diff --git a/scripts/zfs.sh b/scripts/zfs.sh index 2906a54cf9..a342aad4dc 100755 --- a/scripts/zfs.sh +++ b/scripts/zfs.sh @@ -2,9 +2,11 @@ # # A simple script to simply the loading/unloading the ZFS module stack. +basedir="$(dirname $0)" + SCRIPT_COMMON=common.sh -if [ -f ./${SCRIPT_COMMON} ]; then -. ./${SCRIPT_COMMON} +if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then +. "${basedir}/${SCRIPT_COMMON}" elif [ -f /usr/libexec/zfs/${SCRIPT_COMMON} ]; then . /usr/libexec/zfs/${SCRIPT_COMMON} else diff --git a/scripts/zpool-create.sh b/scripts/zpool-create.sh index 2853f7d4e2..ac7ab9ad9a 100755 --- a/scripts/zpool-create.sh +++ b/scripts/zpool-create.sh @@ -1,8 +1,10 @@ #!/bin/bash +basedir="$(dirname $0)" + SCRIPT_COMMON=common.sh -if [ -f ./${SCRIPT_COMMON} ]; then -. ./${SCRIPT_COMMON} +if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then +. "${basedir}/${SCRIPT_COMMON}" elif [ -f /usr/libexec/zfs/${SCRIPT_COMMON} ]; then . /usr/libexec/zfs/${SCRIPT_COMMON} else From 17c732321154571cdaf0d157dd9f91a9ed48e98e Mon Sep 17 00:00:00 2001 From: "Ricardo M. Correia" Date: Tue, 9 Mar 2010 14:51:49 -0800 Subject: [PATCH 2/2] Fix scripts to work when invoked from other directories. --- scripts/zpios-sanity.sh | 6 ++++-- scripts/zpios-survey.sh | 6 ++++-- scripts/zpios.sh | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/zpios-sanity.sh b/scripts/zpios-sanity.sh index d27a5b8ca6..7b38a883ec 100755 --- a/scripts/zpios-sanity.sh +++ b/scripts/zpios-sanity.sh @@ -2,9 +2,11 @@ # # ZFS/ZPOOL configuration test script. +basedir="$(dirname $0)" + SCRIPT_COMMON=common.sh -if [ -f ./${SCRIPT_COMMON} ]; then -. ./${SCRIPT_COMMON} +if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then +. "${basedir}/${SCRIPT_COMMON}" elif [ -f /usr/libexec/zfs/${SCRIPT_COMMON} ]; then . /usr/libexec/zfs/${SCRIPT_COMMON} else diff --git a/scripts/zpios-survey.sh b/scripts/zpios-survey.sh index 0b16d1bb82..c82f7312bc 100755 --- a/scripts/zpios-survey.sh +++ b/scripts/zpios-survey.sh @@ -3,9 +3,11 @@ # Wrapper script for easily running a survey of zpios based tests # +basedir="$(dirname $0)" + SCRIPT_COMMON=common.sh -if [ -f ./${SCRIPT_COMMON} ]; then -. ./${SCRIPT_COMMON} +if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then +. "${basedir}/${SCRIPT_COMMON}" elif [ -f /usr/libexec/zfs/${SCRIPT_COMMON} ]; then . /usr/libexec/zfs/${SCRIPT_COMMON} else diff --git a/scripts/zpios.sh b/scripts/zpios.sh index 6e9b3f50d5..e0b806cecf 100755 --- a/scripts/zpios.sh +++ b/scripts/zpios.sh @@ -3,9 +3,11 @@ # Wrapper script for easily running zpios based tests # +basedir="$(dirname $0)" + SCRIPT_COMMON=common.sh -if [ -f ./${SCRIPT_COMMON} ]; then -. ./${SCRIPT_COMMON} +if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then +. "${basedir}/${SCRIPT_COMMON}" elif [ -f /usr/libexec/zfs/${SCRIPT_COMMON} ]; then . /usr/libexec/zfs/${SCRIPT_COMMON} else