mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 01:51:00 +03:00
scripts: zfs.sh: make usage make sense
We don't pass the arguments as arguments Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13274
This commit is contained in:
parent
f6f505c4d6
commit
d18da59d30
@ -3,7 +3,7 @@
|
|||||||
# A simple script to load/unload the ZFS module stack.
|
# A simple script to load/unload the ZFS module stack.
|
||||||
#
|
#
|
||||||
|
|
||||||
BASE_DIR=$(dirname "$0")
|
BASE_DIR=${0%/*}
|
||||||
SCRIPT_COMMON=common.sh
|
SCRIPT_COMMON=common.sh
|
||||||
if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then
|
if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then
|
||||||
. "${BASE_DIR}/${SCRIPT_COMMON}"
|
. "${BASE_DIR}/${SCRIPT_COMMON}"
|
||||||
@ -11,7 +11,6 @@ else
|
|||||||
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
|
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PROG=zfs.sh
|
|
||||||
VERBOSE="no"
|
VERBOSE="no"
|
||||||
UNLOAD="no"
|
UNLOAD="no"
|
||||||
LOAD="yes"
|
LOAD="yes"
|
||||||
@ -28,28 +27,25 @@ KMOD_FREEBSD=${KMOD_FREEBSD:-openzfs}
|
|||||||
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
USAGE:
|
USAGE:
|
||||||
$0 [hvudS] [module-options]
|
$0 [hvudS]
|
||||||
|
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
Load/unload the ZFS module stack.
|
Load/unload the ZFS module stack.
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-h Show this message
|
-h Show this message
|
||||||
-v Verbose
|
-v Verbose
|
||||||
-r Reload modules
|
-r Reload modules
|
||||||
-u Unload modules
|
-u Unload modules
|
||||||
-S Enable kernel stack tracer
|
-S Enable kernel stack tracer
|
||||||
EOF
|
EOF
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts 'hvruS' OPTION; do
|
while getopts 'hvruS' OPTION; do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
h)
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
v)
|
v)
|
||||||
VERBOSE="yes"
|
VERBOSE="yes"
|
||||||
;;
|
;;
|
||||||
@ -64,14 +60,13 @@ while getopts 'hvruS' OPTION; do
|
|||||||
S)
|
S)
|
||||||
STACK_TRACER="yes"
|
STACK_TRACER="yes"
|
||||||
;;
|
;;
|
||||||
?)
|
|
||||||
usage
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
|
usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
shift $(( OPTIND - 1 ))
|
||||||
|
[ $# -eq 0 ] || usage
|
||||||
|
|
||||||
kill_zed() {
|
kill_zed() {
|
||||||
if [ -f "$ZED_PIDFILE" ]; then
|
if [ -f "$ZED_PIDFILE" ]; then
|
||||||
@ -98,7 +93,7 @@ check_modules_linux() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$LOADED_MODULES" ]; then
|
if [ -n "$LOADED_MODULES" ]; then
|
||||||
printf "Unload the kernel modules by running '%s -u':\n" "$PROG"
|
printf "Unload the kernel modules by running '%s -u':\n" "$0"
|
||||||
printf "%b" "$LOADED_MODULES"
|
printf "%b" "$LOADED_MODULES"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -115,10 +110,10 @@ check_modules_linux() {
|
|||||||
load_module_linux() {
|
load_module_linux() {
|
||||||
KMOD=$1
|
KMOD=$1
|
||||||
|
|
||||||
FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}')
|
|
||||||
VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}')
|
|
||||||
|
|
||||||
if [ "$VERBOSE" = "yes" ]; then
|
if [ "$VERBOSE" = "yes" ]; then
|
||||||
|
FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}')
|
||||||
|
VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}')
|
||||||
|
|
||||||
echo "Loading: $FILE ($VERSION)"
|
echo "Loading: $FILE ($VERSION)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -167,11 +162,12 @@ unload_module_linux() {
|
|||||||
|
|
||||||
NAME="${KMOD##*/}"
|
NAME="${KMOD##*/}"
|
||||||
NAME="${NAME%.ko}"
|
NAME="${NAME%.ko}"
|
||||||
FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}')
|
|
||||||
VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}')
|
|
||||||
|
|
||||||
if [ "$VERBOSE" = "yes" ]; then
|
if [ "$VERBOSE" = "yes" ]; then
|
||||||
echo "Unloading: $KMOD ($VERSION)"
|
FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}')
|
||||||
|
VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}')
|
||||||
|
|
||||||
|
echo "Unloading: $FILE ($VERSION)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rmmod "$NAME" || echo "Failed to unload $NAME"
|
rmmod "$NAME" || echo "Failed to unload $NAME"
|
||||||
@ -255,15 +251,15 @@ if [ "$UNLOAD" = "yes" ]; then
|
|||||||
umount -t zfs -a
|
umount -t zfs -a
|
||||||
case $UNAME in
|
case $UNAME in
|
||||||
FreeBSD)
|
FreeBSD)
|
||||||
unload_modules_freebsd
|
unload_modules_freebsd
|
||||||
;;
|
;;
|
||||||
Linux)
|
Linux)
|
||||||
stack_check_linux
|
stack_check_linux
|
||||||
unload_modules_linux
|
unload_modules_linux
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "unknown system: $UNAME" >&2
|
echo "unknown system: $UNAME" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
@ -275,13 +271,13 @@ if [ "$LOAD" = "yes" ]; then
|
|||||||
Linux)
|
Linux)
|
||||||
stack_clear_linux
|
stack_clear_linux
|
||||||
check_modules_linux
|
check_modules_linux
|
||||||
load_modules_linux "$@"
|
load_modules_linux
|
||||||
udevadm trigger
|
udevadm trigger
|
||||||
udevadm settle
|
udevadm settle
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "unknown system: $UNAME" >&2
|
echo "unknown system: $UNAME" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user