mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 01:51:00 +03:00
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 and dots in dataset name in read_mtab(). * Get rid of 'awk' entirely. This is usually in /usr, which might not be availible. * Get rid of the 'find /dev/disk/by-*' (find is on /usr, which might not be availible). Instead use echo in a for loop. * Rebuild scripts if any of the *.in files changed. * Move the sed part that filters out duplicates inside the check fo valid variable. Signed-off-by: Turbo Fredriksson turbo@bayour.com Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #3463 Closes #3457
This commit is contained in:
parent
2a34db1bdb
commit
4f38c25910
@ -15,7 +15,7 @@ EXTRA_DIST = \
|
|||||||
$(top_srcdir)/etc/init.d/zfs-zed.in \
|
$(top_srcdir)/etc/init.d/zfs-zed.in \
|
||||||
$(top_srcdir)/etc/init.d/zfs.in
|
$(top_srcdir)/etc/init.d/zfs.in
|
||||||
|
|
||||||
$(init_SCRIPTS) $(initconf_SCRIPTS) $(initcommon_SCRIPTS):
|
$(init_SCRIPTS) $(initconf_SCRIPTS) $(initcommon_SCRIPTS): $(EXTRA_DIST)
|
||||||
-(if [ -e /etc/debian_version ]; then \
|
-(if [ -e /etc/debian_version ]; then \
|
||||||
NFS_SRV=nfs-kernel-server; \
|
NFS_SRV=nfs-kernel-server; \
|
||||||
else \
|
else \
|
||||||
|
@ -13,15 +13,15 @@
|
|||||||
PATH=/sbin:/bin:/usr/bin:/usr/sbin
|
PATH=/sbin:/bin:/usr/bin:/usr/sbin
|
||||||
|
|
||||||
# Source function library
|
# Source function library
|
||||||
if [ -f /lib/lsb/init-functions ]; then
|
if [ -f /etc/rc.d/init.d/functions ]; then
|
||||||
# LSB, Debian GNU/Linux and derivates
|
|
||||||
. /lib/lsb/init-functions
|
|
||||||
elif [ -f /etc/rc.d/init.d/functions ]; then
|
|
||||||
# RedHat and derivates
|
# RedHat and derivates
|
||||||
. /etc/rc.d/init.d/functions
|
. /etc/rc.d/init.d/functions
|
||||||
elif [ -L /etc/init.d/functions.sh ]; then
|
elif [ -L /etc/init.d/functions.sh ]; then
|
||||||
# Gentoo
|
# Gentoo
|
||||||
. /etc/init.d/functions.sh
|
. /etc/init.d/functions.sh
|
||||||
|
elif [ -f /lib/lsb/init-functions ]; then
|
||||||
|
# LSB, Debian GNU/Linux and derivates
|
||||||
|
. /lib/lsb/init-functions
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Of course the functions we need are called differently
|
# Of course the functions we need are called differently
|
||||||
@ -373,7 +373,8 @@ read_mtab()
|
|||||||
|
|
||||||
while read -r fs mntpnt fstype opts rest; do
|
while read -r fs mntpnt fstype opts rest; do
|
||||||
if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then
|
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' -e 's,\.,_,g')
|
||||||
eval export MTAB_$mntpnt="$fs"
|
eval export MTAB_$mntpnt="$fs"
|
||||||
fi
|
fi
|
||||||
done < /proc/mounts
|
done < /proc/mounts
|
||||||
|
@ -88,13 +88,13 @@ do_import()
|
|||||||
# make sure we're able to actually import it/them later.
|
# make sure we're able to actually import it/them later.
|
||||||
USE_DISK_BY_ID='yes'
|
USE_DISK_BY_ID='yes'
|
||||||
|
|
||||||
# Filter out duplicates (pools found with the simpl
|
|
||||||
# "zpool import" but which is also found with the
|
|
||||||
# "zpool import -d ...").
|
|
||||||
npools=$(echo "$npools" | sed "s,$available_pools,,")
|
|
||||||
|
|
||||||
if [ -n "$available_pools" ]
|
if [ -n "$available_pools" ]
|
||||||
then
|
then
|
||||||
|
# Filter out duplicates (pools found with the simpl
|
||||||
|
# "zpool import" but which is also found with the
|
||||||
|
# "zpool import -d ...").
|
||||||
|
npools=$(echo "$npools" | sed "s,$available_pools,,")
|
||||||
|
|
||||||
# Add the list to the existing list of
|
# Add the list to the existing list of
|
||||||
# available pools
|
# available pools
|
||||||
available_pools="$available_pools;$npools"
|
available_pools="$available_pools;$npools"
|
||||||
@ -141,14 +141,22 @@ do_import()
|
|||||||
if [ -n "$USE_DISK_BY_ID" -a -z "$ZPOOL_IMPORT_PATH" ]
|
if [ -n "$USE_DISK_BY_ID" -a -z "$ZPOOL_IMPORT_PATH" ]
|
||||||
then
|
then
|
||||||
local dirs
|
local dirs
|
||||||
dirs="$(find /dev/disk/by-* -maxdepth 0 -type d | \
|
dirs="$(for dir in $(echo /dev/disk/by-*)
|
||||||
grep -v by-vdev)"
|
do
|
||||||
dirs="$(echo "$dirs" | sed 's, ,:,g')"
|
# Ignore by-vdev here - we wan't it first!
|
||||||
|
echo "$dir" | grep -q /by-vdev && continue
|
||||||
|
[ ! -d "$dir" ] && continue
|
||||||
|
|
||||||
|
echo -n "$dir:"
|
||||||
|
done | sed 's,:$,,g')"
|
||||||
|
|
||||||
if [ -d "/dev/disk/by-vdev" ]
|
if [ -d "/dev/disk/by-vdev" ]
|
||||||
then
|
then
|
||||||
# Add by-vdev at the beginning.
|
# Add by-vdev at the beginning.
|
||||||
ZPOOL_IMPORT_PATH="/dev/disk/by-vdev:"
|
ZPOOL_IMPORT_PATH="/dev/disk/by-vdev:"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ... and /dev at the very end, just for good measure.
|
||||||
ZPOOL_IMPORT_PATH="$ZPOOL_IMPORT_PATH$dirs:/dev"
|
ZPOOL_IMPORT_PATH="$ZPOOL_IMPORT_PATH$dirs:/dev"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -33,6 +33,17 @@
|
|||||||
|
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
|
|
||||||
|
chkroot() {
|
||||||
|
while read line; do
|
||||||
|
set -- $line
|
||||||
|
if [ "$2" = "/" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done < /etc/mtab
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
do_depend()
|
do_depend()
|
||||||
{
|
{
|
||||||
after procfs zfs-import sysfs procps
|
after procfs zfs-import sysfs procps
|
||||||
@ -166,9 +177,7 @@ do_start()
|
|||||||
|
|
||||||
# Ensure / exists in /etc/mtab, if not update mtab accordingly.
|
# Ensure / exists in /etc/mtab, if not update mtab accordingly.
|
||||||
# This should be handled by rc.sysinit but lets be paranoid.
|
# This should be handled by rc.sysinit but lets be paranoid.
|
||||||
awk '$2 = "/" { exit 1 }' /etc/mtab
|
if ! chkroot
|
||||||
RETVAL=$?
|
|
||||||
if [ "$RETVAL" -eq 0 ]
|
|
||||||
then
|
then
|
||||||
mount -f /
|
mount -f /
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user