mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +03:00
d/zfsutils.zfs.init derivatives: shellcheck, fix header
Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12042
This commit is contained in:
+20
-30
@@ -5,10 +5,8 @@
|
||||
#
|
||||
# Released under the 2-clause BSD license.
|
||||
#
|
||||
# The original script that acted as a template for this script came from
|
||||
# the Debian GNU/Linux kFreeBSD ZFS packages (which did not include a
|
||||
# licensing stansa) in the commit dated Mar 24, 2011:
|
||||
# https://github.com/zfsonlinux/pkg-zfs/commit/80a3ae582b59c0250d7912ba794dca9e669e605a
|
||||
# This script is based on debian/zfsutils.zfs.init from the
|
||||
# Debian GNU/kFreeBSD zfsutils 8.1-3 package, written by Aurelien Jarno.
|
||||
|
||||
PATH=/sbin:/bin:/usr/bin:/usr/sbin
|
||||
|
||||
@@ -20,7 +18,7 @@ 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 derivatives
|
||||
# LSB, Debian, and derivatives
|
||||
. /lib/lsb/init-functions
|
||||
fi
|
||||
|
||||
@@ -63,7 +61,7 @@ elif type success > /dev/null 2>&1 ; then
|
||||
echo
|
||||
zfs_set_ifs "$TMP_IFS"
|
||||
}
|
||||
zfs_log_progress_msg() { echo -n $"$1"; }
|
||||
zfs_log_progress_msg() { echo -n "$""$1"; }
|
||||
elif type einfo > /dev/null 2>&1 ; then
|
||||
# Gentoo functions
|
||||
zfs_log_begin_msg() { ebegin "$1"; }
|
||||
@@ -146,11 +144,11 @@ zfs_daemon_start()
|
||||
start-stop-daemon --start --quiet --exec "$DAEMON_BIN" -- \
|
||||
$DAEMON_ARGS || return 2
|
||||
|
||||
# On Debian GNU/Linux, there's a 'sendsigs' script that will
|
||||
# On Debian, there's a 'sendsigs' script that will
|
||||
# kill basically everything quite early and zed is stopped
|
||||
# much later than that. We don't want zed to be among them,
|
||||
# so add the zed pid to list of pids to ignore.
|
||||
if [ -f "$PIDFILE" -a -d /run/sendsigs.omit.d ]
|
||||
if [ -f "$PIDFILE" ] && [ -d /run/sendsigs.omit.d ]
|
||||
then
|
||||
ln -sf "$PIDFILE" /run/sendsigs.omit.d/zed
|
||||
fi
|
||||
@@ -363,7 +361,7 @@ read_mtab()
|
||||
fs=$(printf '%b\n' "$fs")
|
||||
|
||||
# Set the variable.
|
||||
eval export MTAB_$mntpnt=\"$fs\"
|
||||
eval export "MTAB_$mntpnt=\"$fs\""
|
||||
fi
|
||||
done < /proc/self/mounts
|
||||
}
|
||||
@@ -376,7 +374,7 @@ in_mtab()
|
||||
-e 's,-,,g' -e 's,\.,,g' -e 's, ,,g')
|
||||
local var
|
||||
|
||||
var="$(eval echo MTAB_$mntpnt)"
|
||||
var="$(eval echo "MTAB_$mntpnt")"
|
||||
[ "$(eval echo "$""$var")" != "" ]
|
||||
return "$?"
|
||||
}
|
||||
@@ -385,21 +383,21 @@ in_mtab()
|
||||
read_fstab()
|
||||
{
|
||||
local match="$1"
|
||||
local i var TMPFILE
|
||||
local i var
|
||||
|
||||
# Unset all FSTAB_* variables
|
||||
unset $(env | grep ^FSTAB_ | sed 's,=.*,,')
|
||||
|
||||
i=0
|
||||
while read -r fs mntpnt fstype opts; do
|
||||
echo "$fs" | egrep -qE '^#|^$' && continue
|
||||
echo "$mntpnt" | egrep -qE '^none|^swap' && continue
|
||||
echo "$fstype" | egrep -qE '^swap' && continue
|
||||
echo "$fs" | grep -qE '^#|^$' && continue
|
||||
echo "$mntpnt" | grep -qE '^none|^swap' && continue
|
||||
echo "$fstype" | grep -qE '^swap' && continue
|
||||
|
||||
if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then
|
||||
eval export FSTAB_dev_$i="$fs"
|
||||
eval export "FSTAB_dev_$i=$fs"
|
||||
fs=$(printf '%b\n' "$fs" | sed 's,/,_,g')
|
||||
eval export FSTAB_$i="$mntpnt"
|
||||
eval export "FSTAB_$i=$mntpnt"
|
||||
|
||||
i=$((i + 1))
|
||||
fi
|
||||
@@ -410,7 +408,7 @@ in_fstab()
|
||||
{
|
||||
local var
|
||||
|
||||
var="$(eval echo FSTAB_$1)"
|
||||
var="$(eval echo "FSTAB_$1")"
|
||||
[ "${var}" != "" ]
|
||||
return $?
|
||||
}
|
||||
@@ -418,19 +416,11 @@ in_fstab()
|
||||
is_mounted()
|
||||
{
|
||||
local mntpt="$1"
|
||||
local line
|
||||
local mp
|
||||
|
||||
mount | \
|
||||
while read line; do
|
||||
if echo "$line" | grep -q " on $mntpt "; then
|
||||
# returns:
|
||||
# 0 on unsuccessful match
|
||||
# 1 on a successful match
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
while read -r _ mp _; do
|
||||
[ "$mp" = "$mntpt" ] && return 0
|
||||
done < /proc/self/mounts
|
||||
|
||||
# The negation will flip the subshell return result where the default
|
||||
# return value is 0 when a match is not found.
|
||||
return $(( !$? ))
|
||||
return 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user