aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/zfs-helpers.sh
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2017-08-15 17:26:38 -0700
committerGitHub <[email protected]>2017-08-15 17:26:38 -0700
commitc8f9061fc714696a53cf4d14a4567f0a83dbf862 (patch)
tree42e8a39488899046384f9bb5e350032f438a3ae4 /scripts/zfs-helpers.sh
parent70322be8dc160f003fa95e034462ad625b325568 (diff)
Retire legacy test infrastructure
* Removed zpios kmod, utility, headers and man page. * Removed unused scripts zpios-profile/*, zpios-test/*, zpool-config/*, smb.sh, zpios-sanity.sh, zpios-survey.sh, zpios.sh, and zpool-create.sh. * Removed zfs-script-config.sh.in. When building 'make' generates a common.sh with in-tree path information from the common.sh.in template. This file and sourced by the test scripts and used for in-tree testing, it is not included in the packages. When building packages 'make install' uses the same template to create a new common.sh which is appropriate for the packaging. * Removed unused functions/variables from scripts/common.sh.in. Only minimal path information and configuration environment variables remain. * Removed unused scripts from scripts/ directory. * Remaining shell scripts in the scripts directory updated to cleanly pass shellcheck and added to checked scripts. * Renamed tests/test-runner/cmd/ to tests/test-runner/bin/ to match install location name. * Removed last traces of the --enable-debug-dmu-tx configure options which was retired some time ago. Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #6509
Diffstat (limited to 'scripts/zfs-helpers.sh')
-rwxr-xr-xscripts/zfs-helpers.sh132
1 files changed, 78 insertions, 54 deletions
diff --git a/scripts/zfs-helpers.sh b/scripts/zfs-helpers.sh
index d2da575f4..3fbe64a52 100755
--- a/scripts/zfs-helpers.sh
+++ b/scripts/zfs-helpers.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# This script is designed to facilitate in-tree development and testing
# by installing symlinks on your system which refer to in-tree helper
@@ -17,20 +17,30 @@
# --sysconfdir=DIR install zfs configuration files [PREFIX/etc]
#
-basedir="$(dirname $0)"
-
+BASE_DIR=$(dirname "$0")
SCRIPT_COMMON=common.sh
-if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
-. "${basedir}/${SCRIPT_COMMON}"
+if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then
+ . "${BASE_DIR}/${SCRIPT_COMMON}"
else
-echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
+ echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
fi
PROG=zfs-helpers.sh
-DRYRUN=
-INSTALL=
-REMOVE=
-VERBOSE=
+DRYRUN="no"
+INSTALL="no"
+REMOVE="no"
+VERBOSE="no"
+
+fail() {
+ echo "${PROG}: $1" >&2
+ exit 1
+}
+
+msg() {
+ if [ "$VERBOSE" = "yes" ]; then
+ echo "$@"
+ fi
+}
usage() {
cat << EOF
@@ -60,16 +70,16 @@ while getopts 'hdirv' OPTION; do
exit 1
;;
d)
- DRYRUN=1
+ DRYRUN="yes"
;;
i)
- INSTALL=1
+ INSTALL="yes"
;;
r)
- REMOVE=1
+ REMOVE="yes"
;;
v)
- VERBOSE=1
+ VERBOSE="yes"
;;
?)
usage
@@ -78,27 +88,29 @@ while getopts 'hdirv' OPTION; do
esac
done
-if [ "${INSTALL}" -a "${REMOVE}" ]; then
- usage
- die "Specify -i or -r but not both"
+if [ "$INSTALL" = "yes" -a "$REMOVE" = "yes" ]; then
+ fail "Specify -i or -r but not both"
+fi
+
+if [ "$INSTALL" = "no" -a "$REMOVE" = "no" ]; then
+ fail "Either -i or -r must be specified"
fi
-if [ ! "${INSTALL}" -a ! "${REMOVE}" ]; then
- usage
- die "Either -i or -r must be specified"
+if [ "$(id -u)" != "0" ]; then
+ fail "Must run as root"
fi
-if [ $(id -u) != 0 ]; then
- die "Must run as root"
+if [ "$INTREE" != "yes" ]; then
+ fail "Must be run in-tree"
fi
-if [ "$VERBOSE" ]; then
+if [ "$VERBOSE" = "yes" ]; then
echo "--- Configuration ---"
- echo "udevdir: $udevdir"
- echo "udevruledir: $udevruledir"
- echo "mounthelperdir: $mounthelperdir"
- echo "sysconfdir: $sysconfdir"
- echo "DRYRUN: $DRYRUN"
+ echo "udevdir: $INSTALL_UDEV_DIR"
+ echo "udevruledir: $INSTALL_UDEV_RULE_DIR"
+ echo "mounthelperdir: $INSTALL_MOUNT_HELPER_DIR"
+ echo "sysconfdir: $INSTALL_SYSCONF_DIR"
+ echo "dryrun: $DRYRUN"
echo
fi
@@ -106,18 +118,19 @@ install() {
local src=$1
local dst=$2
- if [ -h $dst ]; then
+ if [ -h "$dst" ]; then
echo "Symlink exists: $dst"
- elif [ -e $dst ]; then
+ elif [ -e "$dst" ]; then
echo "File exists: $dst"
- elif [ ! -e $src ]; then
+ elif [ ! -e "$src" ]; then
echo "Source missing: $src"
else
msg "ln -s $src $dst"
- if [ ! "$DRYRUN" ]; then
- mkdir -p $(dirname $dst) &>/dev/null
- ln -s $src $dst
+ if [ "$DRYRUN" = "no" ]; then
+ DIR=$(dirname "$dst")
+ mkdir -p "$DIR" >/dev/null 2>&1
+ ln -s "$src" "$dst"
fi
fi
}
@@ -125,31 +138,42 @@ install() {
remove() {
local dst=$1
- if [ -h $dst ]; then
+ if [ -h "$dst" ]; then
msg "rm $dst"
- rm $dst
- rmdir $(dirname $dst) &>/dev/null
+ rm "$dst"
+ DIR=$(dirname "$dst")
+ rmdir "$DIR" >/dev/null 2>&1
+ elif [ -e "$dst" ]; then
+ echo "Expected symlink: $dst"
fi
}
-if [ ${INSTALL} ]; then
- install $CMDDIR/mount_zfs/mount.zfs $mounthelperdir/mount.zfs
- install $CMDDIR/fsck_zfs/fsck.zfs $mounthelperdir/fsck.zfs
- install $CMDDIR/zvol_id/zvol_id $udevdir/zvol_id
- install $CMDDIR/vdev_id/vdev_id $udevdir/vdev_id
- install $UDEVRULEDIR/60-zvol.rules $udevruledir/60-zvol.rules
- install $UDEVRULEDIR/69-vdev.rules $udevruledir/69-vdev.rules
- install $UDEVRULEDIR/90-zfs.rules $udevruledir/90-zfs.rules
- install $CMDDIR/zpool/zpool.d $sysconfdir/zfs/zpool.d
+if [ "${INSTALL}" = "yes" ]; then
+ install "$CMD_DIR/mount_zfs/mount.zfs" \
+ "$INSTALL_MOUNT_HELPER_DIR/mount.zfs"
+ install "$CMD_DIR/fsck_zfs/fsck.zfs" \
+ "$INSTALL_MOUNT_HELPER_DIR/fsck.zfs"
+ install "$CMD_DIR/zvol_id/zvol_id" \
+ "$INSTALL_UDEV_DIR/zvol_id"
+ install "$CMD_DIR/vdev_id/vdev_id" \
+ "$INSTALL_UDEV_DIR/vdev_id"
+ install "$UDEV_RULE_DIR/60-zvol.rules" \
+ "$INSTALL_UDEV_RULE_DIR/60-zvol.rules"
+ install "$UDEV_RULE_DIR/69-vdev.rules" \
+ "$INSTALL_UDEV_RULE_DIR/69-vdev.rules"
+ install "$UDEV_RULE_DIR/90-zfs.rules" \
+ "$INSTALL_UDEV_RULE_DIR/90-zfs.rules"
+ install "$CMD_DIR/zpool/zpool.d" \
+ "$INSTALL_SYSCONF_DIR/zfs/zpool.d"
else
- remove $mounthelperdir/mount.zfs
- remove $mounthelperdir/fsck.zfs
- remove $udevdir/zvol_id
- remove $udevdir/vdev_id
- remove $udevruledir/60-zvol.rules
- remove $udevruledir/69-vdev.rules
- remove $udevruledir/90-zfs.rules
- remove $sysconfdir/zfs/zpool.d
+ remove "$INSTALL_MOUNT_HELPER_DIR/mount.zfs"
+ remove "$INSTALL_MOUNT_HELPER_DIR/fsck.zfs"
+ remove "$INSTALL_UDEV_DIR/zvol_id"
+ remove "$INSTALL_UDEV_DIR/vdev_id"
+ remove "$INSTALL_UDEV_RULE_DIR/60-zvol.rules"
+ remove "$INSTALL_UDEV_RULE_DIR/69-vdev.rules"
+ remove "$INSTALL_UDEV_RULE_DIR/90-zfs.rules"
+ remove "$INSTALL_SYSCONF_DIR/zfs/zpool.d"
fi
exit 0