Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F87593276
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
62 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/config/deb.am b/config/deb.am
index acde650ced1a..648417b2adc6 100644
--- a/config/deb.am
+++ b/config/deb.am
@@ -1,45 +1,48 @@
deb-local:
@(if test "${HAVE_DPKGBUILD}" = "no"; then \
echo -e "\n" \
"*** Required util ${DPKGBUILD} missing. Please install the\n" \
"*** package for your distribution which provides ${DPKGBUILD},\n" \
"*** re-run configure, and try again.\n"; \
exit 1; \
fi; \
if test "${HAVE_ALIEN}" = "no"; then \
echo -e "\n" \
"*** Required util ${ALIEN} missing. Please install the\n" \
"*** package for your distribution which provides ${ALIEN},\n" \
"*** re-run configure, and try again.\n"; \
exit 1; \
fi)
deb-kmod: deb-local rpm-kmod
if CONFIG_KERNEL
name=${PACKAGE}; \
version=${VERSION}-${RELEASE}; \
arch=`$(RPM) -qp $${name}-kmod-$${version}.src.rpm --qf %{arch} | tail -1`; \
pkg1=kmod-$${name}*$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --bump=0 --scripts --to-deb $$pkg1; \
$(RM) $$pkg1
endif
deb-utils: deb-local rpm-utils
if CONFIG_USER
name=${PACKAGE}; \
version=${VERSION}-${RELEASE}; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
pkg1=$${name}-$${version}.$${arch}.rpm; \
pkg2=libnvpair1-$${version}.$${arch}.rpm; \
pkg3=libuutil1-$${version}.$${arch}.rpm; \
pkg4=libzfs2-$${version}.$${arch}.rpm; \
pkg5=libzpool2-$${version}.$${arch}.rpm; \
pkg6=libzfs2-devel-$${version}.$${arch}.rpm; \
pkg7=$${name}-test-$${version}.$${arch}.rpm; \
pkg8=$${name}-dracut-$${version}.$${arch}.rpm; \
+ pkg9=$${name}-initramfs-$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --bump=0 --scripts --to-deb \
- $$pkg1 $$pkg2 $$pkg3 $$pkg4 $$pkg5 $$pkg6 $$pkg7 $$pkg8; \
- $(RM) $$pkg1 $$pkg2 $$pkg3 $$pkg4 $$pkg5 $$pkg6 $$pkg7 $$pkg8;
+ $$pkg1 $$pkg2 $$pkg3 $$pkg4 $$pkg5 $$pkg6 $$pkg7 \
+ $$pkg8 $$pkg9;
+ $(RM) $$pkg1 $$pkg2 $$pkg3 $$pkg4 $$pkg5 $$pkg6 $$pkg7 \
+ $$pkg8 $$pkg9;
endif
deb: deb-kmod deb-utils
diff --git a/contrib/initramfs/hooks/zfs b/contrib/initramfs/hooks/zfs
index c4f4332cb5ef..53e876d33ab9 100755
--- a/contrib/initramfs/hooks/zfs
+++ b/contrib/initramfs/hooks/zfs
@@ -1,103 +1,103 @@
#!/bin/sh
#
# Add ZoL filesystem capabilities to an initrd, usually for a native ZFS root.
#
# This hook installs udev rules for ZoL.
PREREQ="zdev"
# These prerequisites are provided by the zfsutils package. The zdb utility is
# not strictly required, but it can be useful at the initramfs recovery prompt.
COPY_EXEC_LIST="/sbin/zdb /sbin/zpool /sbin/zfs /sbin/mount.zfs"
-COPY_EXEC_LIST="$COPY_EXEC_LIST /usr/bin/dirname"
+COPY_EXEC_LIST="$COPY_EXEC_LIST /usr/bin/dirname /lib/udev/vdev_id"
COPY_FILE_LIST="/etc/hostid /etc/zfs/zpool.cache /etc/default/zfs"
COPY_FILE_LIST="$COPY_FILE_LIST /etc/zfs/zfs-functions /etc/zfs/vdev_id.conf"
COPY_FILE_LIST="$COPY_FILE_LIST /lib/udev/rules.d/69-vdev.rules"
# These prerequisites are provided by the base system.
COPY_EXEC_LIST="$COPY_EXEC_LIST /bin/hostname /sbin/blkid"
# Explicitly specify all kernel modules because automatic dependency resolution
# is unreliable on many systems.
BASE_MODULES="zlib_deflate spl zavl zcommon znvpair zunicode zfs"
CRPT_MODULES="sun-ccm sun-gcm sun-ctr"
MANUAL_ADD_MODULES_LIST="$BASE_MODULES"
# Generic result code.
RC=0
case $1 in
prereqs)
echo "$PREREQ"
exit 0
;;
esac
for ii in $COPY_EXEC_LIST
do
if [ ! -x "$ii" ]
then
echo "Error: $ii is not executable."
RC=2
fi
done
if [ "$RC" -ne 0 ]
then
exit "$RC"
fi
. /usr/share/initramfs-tools/hook-functions
mkdir -p "$DESTDIR/etc/"
# ZDB uses pthreads for some functions, but the library dependency is not
# automatically detected. The `find` utility and extended `cp` options are
# used here because libgcc_s.so could be in a subdirectory of /lib for
# multi-arch installations.
cp --target-directory="$DESTDIR" --parents $(find /lib -type f -name libgcc_s.so.1)
for ii in $COPY_EXEC_LIST
do
copy_exec "$ii"
done
for ii in $COPY_FILE_LIST
do
dir=$(dirname "$ii")
- [ -d "$dir" ] || mkdir -p "$dir"
+ [ -d "$dir" ] && mkdir -p "$DESTDIR/$dir"
[ -f "$ii" ] && cp -p "$ii" "$DESTDIR/$ii"
done
for ii in $MANUAL_ADD_MODULES_LIST
do
manual_add_modules "$ii"
done
if [ -f "/etc/hostname" ]
then
cp -p "/etc/hostname" "$DESTDIR/etc/"
else
hostname >"$DESTDIR/etc/hostname"
fi
for ii in zfs zfs.conf spl spl.conf
do
if [ -f "/etc/modprobe.d/$ii" ]; then
if [ ! -d "$DESTDIR/etc/modprobe.d" ]; then
mkdir -p $DESTDIR/etc/modprobe.d
fi
cp -p "/etc/modprobe.d/$ii" $DESTDIR/etc/modprobe.d/
fi
done
# With pull request #1476 (not yet merged) comes a verbose warning
# if /usr/bin/net doesn't exist or isn't executable. Just create
# a dummy...
[ ! -d "$DESTDIR/usr/bin" ] && mkdir -p "$DESTDIR/usr/bin"
if [ ! -x "$DESTDIR/usr/bin/net" ]; then
touch "$DESTDIR/usr/bin/net"
chmod +x "$DESTDIR/usr/bin/net"
fi
exit 0
diff --git a/contrib/initramfs/scripts/zfs b/contrib/initramfs/scripts/zfs
index 43107c4dc6fb..dc01db11ea7f 100644
--- a/contrib/initramfs/scripts/zfs
+++ b/contrib/initramfs/scripts/zfs
@@ -1,962 +1,962 @@
# ZFS boot stub for initramfs-tools.
#
# In the initramfs environment, the /init script sources this stub to
# override the default functions in the /scripts/local script.
#
# Enable this by passing boot=zfs on the kernel command line.
#
# Source the common init script
. /etc/zfs/zfs-functions
# Paths to what we need - in the initrd, these paths are hardcoded,
# so override the defines in zfs-functions.
ZFS="/sbin/zfs"
ZPOOL="/sbin/zpool"
ZPOOL_CACHE="/etc/zfs/zpool.cache"
export ZFS ZPOOL ZPOOL_CACHE
# This runs any scripts that should run before we start importing
# pools and mounting any filesystems.
pre_mountroot()
{
if type run_scripts > /dev/null 2>&1 && \
[ -f "/scripts/local-top" -o -d "/scripts/local-top" ]
then
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Running /scripts/local-top"
run_scripts /scripts/local-top
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
if type run_scripts > /dev/null 2>&1 && \
[ -f "/scripts/local-premount" -o -d "/scripts/local-premount" ]
then
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Running /scripts/local-premount"
run_scripts /scripts/local-premount
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
}
# If plymouth is availible, hide the splash image.
disable_plymouth()
{
if [ -x /bin/plymouth ] && /bin/plymouth --ping
then
/bin/plymouth hide-splash >/dev/null 2>&1
fi
}
# Get a ZFS filesystem property value.
get_fs_value()
{
local fs="$1"
local value=$2
"${ZFS}" get -H -ovalue $value "$fs" 2> /dev/null
}
# Find the 'bootfs' property on pool $1.
# If the property does not contain '/', then ignore this
# pool by exporting it again.
find_rootfs()
{
local pool="$1"
# If it's already specified, just keep it mounted and exit
# User (kernel command line) must be correct.
if [ -n "${ZFS_BOOTFS}" ]
then
POOL_IMPORTED=1
return 0
fi
# Not set, try to find it in the 'bootfs' property of the pool.
# NOTE: zpool does not support 'get -H -ovalue bootfs'...
ZFS_BOOTFS=$("${ZPOOL}" list -H -obootfs "$pool")
# Make sure it's not '-' and that it starts with /.
if [ "${ZFS_BOOTFS}" != "-" ] && \
$(get_fs_value "${ZFS_BOOTFS}" mountpoint | grep -q '^/$')
then
# Keep it mounted
POOL_IMPORTED=1
return 0
fi
# Not boot fs here, export it and later try again..
"${ZPOOL}" export "$pool"
return 1
}
# Support function to get a list of all pools, separated with ';'
find_pools()
{
local CMD="$*"
local pools
pools=$($CMD 2> /dev/null | \
grep -E "pool:|^[a-zA-Z0-9]" | \
sed 's@.*: @@' | \
sort | \
while read pool; do \
echo -n "$pool;"
done)
echo "${pools%%;}" # Return without the last ';'.
}
# Get a list of all availible pools
get_pools()
{
local available_pools npools
# Get the base list of availible pools.
available_pools=$(find_pools "$ZPOOL" import)
# Just in case - seen it happen (that a pool isn't visable/found
# with a simple "zpool import" but only when using the "-d"
# option or setting ZPOOL_IMPORT_PATH).
if [ -d "/dev/disk/by-id" ]
then
npools=$(find_pools "$ZPOOL" import -d /dev/disk/by-id)
if [ -n "$npools" ]
then
# Because we have found extra pool(s) here, which wasn't
# found 'normaly', we need to force USE_DISK_BY_ID to
# make sure we're able to actually import it/them later.
USE_DISK_BY_ID='yes'
if [ -n "$available_pools" ]
then
# Filter out duplicates (pools found with the simple
# "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
# available pools
available_pools="$available_pools;$npools"
else
available_pools="$npools"
fi
fi
fi
# Filter out any exceptions...
if [ -n "$ZFS_POOL_EXCEPTIONS" ]
then
local found=""
local apools=""
local pool exception
OLD_IFS="$IFS" ; IFS=";"
for pool in $available_pools
do
for exception in $ZFS_POOL_EXCEPTIONS
do
[ "$pool" = "$exception" ] && continue 2
found="$pool"
done
if [ -n "$found" ]
then
if [ -n "$apools" ]
then
apools="$apools;$pool"
else
apools="$pool"
fi
fi
done
IFS="$OLD_IFS"
available_pools="$apools"
fi
# Return list of availible pools.
echo "$available_pools"
}
# Import given pool $1
import_pool()
{
local pool="$1"
local dirs dir ZFS_CMD ZFS_STDERR ZFS_ERROR
# Verify that the pool isn't already imported
# Make as sure as we can to not require '-f' to import.
"${ZPOOL}" status "$pool" > /dev/null 2>&1 && return 0
# For backwards compability, make sure that ZPOOL_IMPORT_PATH is set
# to something we can use later with the real import(s). We want to
# make sure we find all by* dirs, BUT by-vdev should be first (if it
# exists).
if [ -n "$USE_DISK_BY_ID" -a -z "$ZPOOL_IMPORT_PATH" ]
then
dirs="$(for dir in $(echo /dev/disk/by-*)
do
# Ignore by-vdev here - we want 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" ]
then
# Add by-vdev at the beginning.
ZPOOL_IMPORT_PATH="/dev/disk/by-vdev:"
fi
# ... and /dev at the very end, just for good measure.
ZPOOL_IMPORT_PATH="$ZPOOL_IMPORT_PATH$dirs:/dev"
fi
# Needs to be exported for "zpool" to catch it.
[ -n "$ZPOOL_IMPORT_PATH" ] && export ZPOOL_IMPORT_PATH
[ "$quiet" != "y" ] && zfs_log_begin_msg \
"Importing pool '${pool}' using defaults"
ZFS_CMD="${ZPOOL} import -N ${ZPOOL_FORCE}"
ZFS_STDERR="$($ZFS_CMD "$pool" 2>&1)"
ZFS_ERROR="$?"
if [ "${ZFS_ERROR}" != 0 ]
then
[ "$quiet" != "y" ] && zfs_log_failure_msg "${ZFS_ERROR}"
[ "$quiet" != "y" ] && zfs_log_begin_msg \
"Importing pool '${pool}' using cachefile."
ZFS_CMD="${ZPOOL} import -c ${ZPOOL_CACHE} -N ${ZPOOL_FORCE}"
ZFS_STDERR="$($ZFS_CMD "$pool" 2>&1)"
ZFS_ERROR="$?"
if [ "${ZFS_ERROR}" != 0 ]
then
[ "$quiet" != "y" ] && zfs_log_failure_msg "${ZFS_ERROR}"
disable_plymouth
echo ""
echo "Command: ${ZFS_CMD} '$pool'"
echo "Message: $ZFS_STDERR"
echo "Error: $ZFS_ERROR"
echo ""
echo "Failed to import pool '$pool'."
echo "Manually import the pool and exit."
/bin/sh
fi
fi
[ "$quiet" != "y" ] && zfs_log_end_msg
return 0
}
# Load ZFS modules
# Loading a module in a initrd require a slightly different approach,
# with more logging etc.
load_module_initrd()
{
if [ "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP" > 0 ]
then
if [ "$quiet" != "y" ]; then
zfs_log_begin_msg "Sleeping for" \
"$ZFS_INITRD_PRE_MOUNTROOT_SLEEP seconds..."
fi
sleep "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP"
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
# Wait for all of the /dev/{hd,sd}[a-z] device nodes to appear.
if type wait_for_udev > /dev/null 2>&1 ; then
wait_for_udev 10
elif type wait_for_dev > /dev/null 2>&1 ; then
wait_for_dev
fi
# zpool import refuse to import without a valid mtab
[ ! -f /proc/mounts ] && mount proc /proc
[ ! -f /etc/mtab ] && cat /proc/mounts > /etc/mtab
# Load the module
- load_module || return 1
+ load_module "zfs" || return 1
if [ "$ZFS_INITRD_POST_MODPROBE_SLEEP" > 0 ]
then
if [ "$quiet" != "y" ]; then
zfs_log_begin_msg "Sleeping for" \
"$ZFS_INITRD_POST_MODPROBE_SLEEP seconds..."
fi
sleep "$ZFS_INITRD_POST_MODPROBE_SLEEP"
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
return 0
}
# Mount a given filesystem
mount_fs()
{
local fs="$1"
local mountpoint ZFS_CMD ZFS_STDERR ZFS_ERROR
# Need the _original_ datasets mountpoint!
mountpoint=$(get_fs_value "$fs" mountpoint)
if [ "$mountpoint" = "legacy" -o "$mountpoint" = "none" ]; then
# Can't use the mountpoint property. Might be one of our
# clones. Check the 'org.zol:mountpoint' property set in
# clone_snap() if that's usable.
mountpoint=$(get_fs_value "$fs" org.zol:mountpoint)
if [ "$mountpoint" = "legacy" -o \
"$mountpoint" = "none" -o \
"$mountpoint" = "-" ]
then
if [ "$fs" != "${ZFS_BOOTFS}" ]; then
# We don't have a proper mountpoint, this
# isn't the root fs. So extract the root fs
# value from the filesystem, and we should
# (hopefully!) have a mountpoint we can use.
mountpoint="${fs##$ZFS_BOOTFS}"
else
# Last hail-mary: Hope 'rootmnt' is set!
mountpoint=""
fi
fi
if [ "$mountpoint" = "legacy" ]; then
ZFS_CMD="mount -t zfs"
else
# If it's not a legacy filesystem, it can only be a
# native one...
ZFS_CMD="mount -o zfsutil -t zfs"
fi
else
ZFS_CMD="mount -o zfsutil -t zfs"
fi
# Possibly decrypt a filesystem using native encryption.
decrypt_fs "$fs"
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Mounting '${fs}' on '${rootmnt}/${mountpoint}'"
[ -n "${ZFS_DEBUG}" ] && \
zfs_log_begin_msg "CMD: '$ZFS_CMD ${fs} ${rootmnt}/${mountpoint}'"
ZFS_STDERR=$(${ZFS_CMD} "${fs}" "${rootmnt}/${mountpoint}" 2>&1)
ZFS_ERROR=$?
if [ "${ZFS_ERROR}" != 0 ]
then
[ "$quiet" != "y" ] && zfs_log_failure_msg "${ZFS_ERROR}"
disable_plymouth
echo ""
echo "Command: ${ZFS_CMD} ${fs} ${rootmnt}/${mountpoint}"
echo "Message: $ZFS_STDERR"
echo "Error: $ZFS_ERROR"
echo ""
echo "Failed to mount ${fs} on ${rootmnt}/${mountpoint}."
echo "Manually mount the filesystem and exit."
/bin/sh
else
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
return 0
}
# Unlock a ZFS native crypted filesystem.
decrypt_fs()
{
local fs="$1"
local ZFS_CMD ZFS_STDERR ZFS_ERROR
# If the 'zfs key' command isn't availible, exit right here.
"${ZFS}" 2>&1 | grep -q 'key -l ' || return 0
# Check if filesystem is encrypted. If not, exit right here.
[ "$(get_fs_value "$fs" encryption)" != "off" ] || return 0
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Loading crypto wrapper key for $fs"
# Just make sure that ALL crypto modules module is loaded.
# Simplest just to load all...
for mod in sun-ccm sun-gcm sun-ctr
do
[ "$quiet" != "y" ] && zfs_log_progress_msg "${mod} "
- ZFS_CMD="/sbin/modprobe $mod"
+ ZFS_CMD="load_module $mod"
ZFS_STDERR="$(${ZFS_CMD} 2>&1)"
ZFS_ERROR="$?"
if [ "${ZFS_ERROR}" != 0 ]
then
[ "$quiet" != "y" ] && zfs_log_failure_msg "${ZFS_ERROR}"
disable_plymouth
echo ""
echo "Command: $ZFS_CMD"
echo "Message: $ZFS_STDERR"
echo "Error: $ZFS_ERROR"
echo ""
echo "Failed to load $mod module."
echo "Please verify that it is availible on the initrd image"
echo "(without it it won't be possible to unlock the filesystem)"
echo "and rerun: $ZFS_CMD"
/bin/sh
else
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
done
# If the key isn't availible, then this will fail!
ZFS_CMD="${ZFS} key -l -r $fs"
ZFS_STDERR="$(${ZFS_CMD} 2>&1)"
ZFS_ERROR="$?"
if [ "${ZFS_ERROR}" != 0 ]
then
[ "$quiet" != "y" ] && zfs_log_failure_msg "${ZFS_ERROR}"
disable_plymouth
echo ""
echo "Command: $ZFS_CMD"
echo "Message: $ZFS_STDERR"
echo "Error: $ZFS_ERROR"
echo ""
echo "Failed to load zfs encryption wrapper key (s)."
echo "Please verify dataset property 'keysource' for datasets"
echo "and rerun: $ZFS_CMD"
/bin/sh
else
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
return 0
}
# Destroy a given filesystem.
destroy_fs()
{
local fs="$1"
local ZFS_CMD ZFS_STDERR ZFS_ERROR
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Destroying '$fs'"
ZFS_CMD="${ZFS} destroy $fs"
ZFS_STDERR="$(${ZFS_CMD} 2>&1)"
ZFS_ERROR="$?"
if [ "${ZFS_ERROR}" != 0 ]
then
[ "$quiet" != "y" ] && zfs_log_failure_msg "${ZFS_ERROR}"
disable_plymouth
echo ""
echo "Command: $ZFS_CMD"
echo "Message: $ZFS_STDERR"
echo "Error: $ZFS_ERROR"
echo ""
echo "Failed to destroy '$fs'. Please make sure that '$fs' is not availible."
echo "Hint: Try: zfs destroy -Rfn $fs"
echo "If this dryrun looks good, then remove the 'n' from '-Rfn' and try again."
/bin/sh
else
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
return 0
}
# Clone snapshot $1 to destination filesystem $2
# Set 'canmount=noauto' and 'mountpoint=none' so that we get to keep
# manual controll over it's mounting (i.e., make sure it's not automatically
# mounted with a 'zfs mount -a' in the init/systemd scripts).
clone_snap()
{
local snap="$1"
local destfs="$2"
local mountpoint="$3"
local ZFS_CMD ZFS_STDERR ZFS_ERROR
[ "$quiet" != "y" ] && zfs_log_begin_msg "Cloning '$snap' to '$destfs'"
# Clone the snapshot into a dataset we can boot from
# + We don't want this filesystem to be automatically mounted, we
# want controll over this here and nowhere else.
# + We don't need any mountpoint set for the same reason.
# We use the 'org.zol:mountpoint' property to remember the mountpoint.
ZFS_CMD="${ZFS} clone -o canmount=noauto -o mountpoint=none"
ZFS_CMD="${ZFS_CMD} -o org.zol:mountpoint=${mountpoint}"
ZFS_CMD="${ZFS_CMD} $snap $destfs"
ZFS_STDERR="$(${ZFS_CMD} 2>&1)"
ZFS_ERROR="$?"
if [ "${ZFS_ERROR}" != 0 ]
then
[ "$quiet" != "y" ] && zfs_log_failure_msg "${ZFS_ERROR}"
disable_plymouth
echo ""
echo "Command: $ZFS_CMD"
echo "Message: $ZFS_STDERR"
echo "Error: $ZFS_ERROR"
echo ""
echo "Failed to clone snapshot."
echo "Make sure that the any problems are corrected and then make sure"
echo "that the dataset '$destfs' exists and is bootable."
/bin/sh
else
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
return 0
}
# Rollback a given snapshot.
rollback_snap()
{
local snap="$1"
local ZFS_CMD ZFS_STDERR ZFS_ERROR
[ "$quiet" != "y" ] && zfs_log_begin_msg "Rollback $snap"
ZFS_CMD="${ZFS} rollback -Rf $snap"
ZFS_STDERR="$(${ZFS_CMD} 2>&1)"
ZFS_ERROR="$?"
if [ "${ZFS_ERROR}" != 0 ]
then
[ "$quiet" != "y" ] && zfs_log_failure_msg "${ZFS_ERROR}"
disable_plymouth
echo ""
echo "Command: $ZFS_CMD"
echo "Message: $ZFS_STDERR"
echo "Error: $ZFS_ERROR"
echo ""
echo "Failed to rollback snapshot."
/bin/sh
else
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
return 0
}
# Get a list of snapshots, give them as a numbered list
# to the user to choose from.
ask_user_snap()
{
local fs="$1"
local i=1
local SNAP snapnr snap debug
# We need to temporarily disable debugging. Set 'debug' so we
# remember to enabled it again.
if [ -n "${ZFS_DEBUG}" ]; then
unset ZFS_DEBUG
set +x
debug=1
fi
# Because we need the resulting snapshot, which is sent on
# stdout to the caller, we use stderr for our questions.
echo "What snapshot do you want to boot from?" > /dev/stderr
while read snap; do
echo " $i: ${snap}" > /dev/stderr
eval `echo SNAP_$i=$snap`
i=$((i + 1))
done <<EOT
$("${ZFS}" list -H -oname -tsnapshot "${fs}")
EOT
echo -n " Snap nr [0-$((i-1))]? " > /dev/stderr
read snapnr
# Reenable debugging.
if [ -n "${debug}" ]; then
ZFS_DEBUG=1
set -x
fi
echo "$(eval echo "$"SNAP_$snapnr)"
}
setup_snapshot_booting()
{
local snap="$1"
local s destfs subfs mountpoint retval=0 filesystems fs
# Make sure that the snapshot specified actually exist.
if [ ! $(get_fs_value "${snap}" type) ]
then
# Snapshot does not exist (...@<null> ?)
# ask the user for a snapshot to use.
snap="$(ask_user_snap "${snap%%@*}")"
fi
# Separate the full snapshot ('$snap') into it's filesystem and
# snapshot names. Would have been nice with a split() function..
rootfs="${snap%%@*}"
snapname="${snap##*@}"
ZFS_BOOTFS="${rootfs}_${snapname}"
if ! grep -qiE '(^|[^\\](\\\\)* )(rollback)=(on|yes|1)( |$)' /proc/cmdline
then
# If the destination dataset for the clone
# already exists, destroy it. Recursivly
if [ $(get_fs_value "${rootfs}_${snapname}" type) ]; then
filesystems=$("${ZFS}" list -oname -tfilesystem -H \
-r "${ZFS_BOOTFS}" | sort -r)
for fs in $filesystems; do
destroy_fs "${fs}"
done
fi
fi
# Get all snapshots, recursivly (might need to clone /usr, /var etc
# as well).
for s in $("${ZFS}" list -H -oname -tsnapshot -r "${rootfs}" | \
grep "${snapname}")
do
if grep -qiE '(^|[^\\](\\\\)* )(rollback)=(on|yes|1)( |$)' /proc/cmdline
then
# Rollback snapshot
rollback_snap "$s" || retval=$((retval + 1))
else
# Setup a destination filesystem name.
# Ex: Called with 'rpool/ROOT/debian@snap2'
# rpool/ROOT/debian@snap2 => rpool/ROOT/debian_snap2
# rpool/ROOT/debian/boot@snap2 => rpool/ROOT/debian_snap2/boot
# rpool/ROOT/debian/usr@snap2 => rpool/ROOT/debian_snap2/usr
# rpool/ROOT/debian/var@snap2 => rpool/ROOT/debian_snap2/var
subfs="${s##$rootfs}"
subfs="${subfs%%@$snapname}"
destfs="${rootfs}_${snapname}" # base fs.
[ -n "$subfs" ] && destfs="${destfs}$subfs" # + sub fs.
# Get the mountpoint of the filesystem, to be used
# with clone_snap(). If legacy or none, then use
# the sub fs value.
mountpoint=$(get_fs_value "${s%%@*}" mountpoint)
if [ "$mountpoint" = "legacy" -o \
"$mountpoint" = "none" ]
then
if [ -n "${subfs}" ]; then
mountpoint="${subfs}"
else
mountpoint="/"
fi
fi
# Clone the snapshot into its own
# filesystem
clone_snap "$s" "${destfs}" "${mountpoint}" || \
retval=$((retval + 1))
fi
done
# If we haven't return yet, we have a problem...
return "${retval}"
}
# ================================================================
# This is the main function.
mountroot()
{
local snaporig
local snapsub
local destfs
# ----------------------------------------------------------------
# I N I T I A L S E T U P
# ------------
# Run the pre-mount scripts from /scripts/local-top.
pre_mountroot
# ------------
# Source the default setup variables.
[ -r '/etc/default/zfs' ] && . /etc/default/zfs
# ------------
# Support debug option
if grep -qiE '(^|[^\\](\\\\)* )(zfs_debug|zfs\.debug|zfsdebug)=(on|yes|1)( |$)' /proc/cmdline
then
ZFS_DEBUG=1
mkdir /var/log
#exec 2> /var/log/boot.debug
set -x
fi
# ------------
# Load ZFS module etc.
if ! load_module_initrd; then
disable_plymouth
echo ""
echo "Failed to load ZFS modules."
echo "Manually load the modules and exit."
/bin/sh
fi
# ------------
# Look for the cache file (if any).
[ ! -f ${ZPOOL_CACHE} ] && unset ZPOOL_CACHE
# ------------
# Compatibility: 'ROOT' is for Debian GNU/Linux (etc),
# 'root' is for Redhat/Fedora (etc),
# 'REAL_ROOT' is for Gentoo
if [ -z "$ROOT" ]
then
[ -n "$root" ] && ROOT=${root}
[ -n "$REAL_ROOT" ] && ROOT=${REAL_ROOT}
fi
# ------------
# Where to mount the root fs in the initrd - set outside this script
# Compatibility: 'rootmnt' is for Debian GNU/Linux (etc),
# 'NEWROOT' is for RedHat/Fedora (etc),
# 'NEW_ROOT' is for Gentoo
if [ -z "$rootmnt" ]
then
[ -n "$NEWROOT" ] && rootmnt=${NEWROOT}
[ -n "$NEW_ROOT" ] && rootmnt=${NEW_ROOT}
fi
# ------------
# No longer set in the defaults file, but it could have been set in
# get_pools() in some circumstances. If it's something, but not 'yes',
# it's no good to us.
[ -n "$USE_DISK_BY_ID" -a "$USE_DISK_BY_ID" != 'yes' ] && \
unset USE_DISK_BY_ID
# ----------------------------------------------------------------
# P A R S E C O M M A N D L I N E O P T I O N S
# This part is the really ugly part - there's so many options and permutations
# 'out there', and if we should make this the 'primary' source for ZFS initrd
# scripting, we need/should support them all.
#
# Supports the following kernel command line argument combinations
# (in this order - first match win):
#
# rpool=<pool> (tries to finds bootfs automatically)
# bootfs=<pool>/<dataset> (uses this for rpool - first part)
# rpool=<pool> bootfs=<pool>/<dataset>
# -B zfs-bootfs=<pool>/<fs> (uses this for rpool - first part)
# rpool=rpool (default if none of the above is used)
# root=<pool>/<dataset> (uses this for rpool - first part)
# root=ZFS=<pool>/<dataset> (uses this for rpool - first part, without 'ZFS=')
# root=zfs:AUTO (tries to detect both pool and rootfs
# root=zfs:<pool>/<dataset> (uses this for rpool - first part, without 'zfs:')
#
# Option <dataset> could also be <snapshot>
# ------------
# Support force option
# In addition, setting one of zfs_force, zfs.force or zfsforce to
# 'yes', 'on' or '1' will make sure we force import the pool.
# This should (almost) never be needed, but it's here for
# completeness.
ZPOOL_FORCE=""
if grep -qiE '(^|[^\\](\\\\)* )(zfs_force|zfs\.force|zfsforce)=(on|yes|1)( |$)' /proc/cmdline
then
ZPOOL_FORCE="-f"
fi
# ------------
# Look for 'rpool' and 'bootfs' parameter
[ -n "$rpool" ] && ZFS_RPOOL="${rpool#rpool=}"
[ -n "$bootfs" ] && ZFS_BOOTFS="${bootfs#bootfs=}"
# ------------
# If we have 'ROOT' (see above), but not 'ZFS_BOOTFS', then use
# 'ROOT'
[ -n "$ROOT" -a -z "${ZFS_BOOTFS}" ] && ZFS_BOOTFS="$ROOT"
# ------------
# Check for the `-B zfs-bootfs=%s/%u,...` kind of parameter.
# NOTE: Only use the pool name and dataset. The rest is not
# supported by ZoL (whatever it's for).
if [ -z "$ZFS_RPOOL" ]
then
# The ${zfs-bootfs} variable is set at the kernel commmand
# line, usually by GRUB, but it cannot be referenced here
# directly because bourne variable names cannot contain a
# hyphen.
#
# Reassign the variable by dumping the environment and
# stripping the zfs-bootfs= prefix. Let the shell handle
# quoting through the eval command.
eval ZFS_RPOOL=$(set | sed -n -e 's,^zfs-bootfs=,,p')
fi
# ------------
# No root fs or pool specified - do auto detect.
if [ -z "$ZFS_RPOOL" -a -z "${ZFS_BOOTFS}" ]
then
# Do auto detect. Do this by 'cheating' - set 'root=zfs:AUTO'
# which will be caught later
ROOT=zfs:AUTO
fi
# ----------------------------------------------------------------
# F I N D A N D I M P O R T C O R R E C T P O O L
# ------------
if [ "$ROOT" = "zfs:AUTO" ]
then
# Try to detect both pool and root fs.
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Attempting to import additional pools."
# Get a list of pools available for import
if [ -n "$ZFS_RPOOL" ]
then
# We've specified a pool - check only that
POOLS=$ZFS_RPOOL
else
POOLS=$(get_pools)
fi
OLD_IFS="$IFS" ; IFS=";"
for pool in $POOLS
do
[ -z "$pool" ] && continue
import_pool "$pool"
find_rootfs "$pool"
done
IFS="$OLD_IFS"
[ "$quiet" != "y" ] && zfs_log_end_msg $ZFS_ERROR
else
# No auto - use value from the command line option.
# Strip 'zfs:' and 'ZFS='.
ZFS_BOOTFS="${ROOT#*[:=]}"
# Stip everything after the first slash.
ZFS_RPOOL="${ZFS_BOOTFS%%/*}"
fi
# Import the pool (if not already done so in the AUTO check above).
if [ -n "$ZFS_RPOOL" -a -z "${POOL_IMPORTED}" ]
then
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Importing ZFS root pool '$ZFS_RPOOL'"
import_pool "${ZFS_RPOOL}"
find_rootfs "${ZFS_RPOOL}"
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
if [ -z "${POOL_IMPORTED}" ]
then
# No pool imported, this is serious!
disable_plymouth
echo ""
echo "Command: $ZFS_CMD"
echo "Message: $ZFS_STDERR"
echo "Error: $ZFS_ERROR"
echo ""
echo "No pool imported. Manually import the root pool"
echo "at the command prompt and then exit."
echo "Hint: Try: zpool import -R ${rootmnt} -N ${ZFS_RPOOL}"
/bin/sh
fi
# ----------------------------------------------------------------
# P R E P A R E R O O T F I L E S Y S T E M
if [ -n "${ZFS_BOOTFS}" ]
then
# Booting from a snapshot?
# Will overwrite the ZFS_BOOTFS variable like so:
# rpool/ROOT/debian@snap2 => rpool/ROOT/debian_snap2
echo "${ZFS_BOOTFS}" | grep -q '@' && \
setup_snapshot_booting "${ZFS_BOOTFS}"
fi
if [ -z "${ZFS_BOOTFS}" ]
then
# Still nothing! Let the user sort this out.
disable_plymouth
echo ""
echo "Error: Unknown root filesystem - no 'bootfs' pool property and"
echo " not specified on the kernel command line."
echo ""
echo "Manually mount the root filesystem on $rootmnt and then exit."
echo "Hint: Try: mount -o zfsutil -t zfs ${ZFS_RPOOL-rpool}/ROOT/system $rootmnt"
/bin/sh
fi
# ----------------------------------------------------------------
# M O U N T F I L E S Y S T E M S
# * Ideally, the root filesystem would be mounted like this:
#
# zpool import -R "$rootmnt" -N "$ZFS_RPOOL"
# zfs mount -o mountpoint=/ "${ZFS_BOOTFS}"
#
# but the MOUNTPOINT prefix is preserved on descendent filesystem
# after the pivot into the regular root, which later breaks things
# like `zfs mount -a` and the /etc/mtab refresh.
#
# * Mount additional filesystems required
# Such as /usr, /var, /usr/local etc.
# NOTE: Mounted in the order specified in the
# ZFS_INITRD_ADDITIONAL_DATASETS variable so take care!
# Go through the complete list (recursivly) of all filesystems below
# the real root dataset
filesystems=$("${ZFS}" list -oname -tfilesystem -H -r "${ZFS_BOOTFS}")
for fs in $filesystems $ZFS_INITRD_ADDITIONAL_DATASETS
do
mount_fs "$fs"
done
# ------------
# Debugging information
if [ -n "${ZFS_DEBUG}" ]
then
#exec 2>&1-
echo "DEBUG: imported pools:"
"${ZPOOL}" list -H
echo
echo "DEBUG: mounted ZFS filesystems:"
mount | grep zfs
echo
echo "=> waiting for ENTER before continuing because of 'zfsdebug=1'. "
echo -n " 'c' for shell, 'r' for reboot, 'ENTER' to continue. "
read b
[ "$b" = "c" ] && /bin/sh
[ "$b" = "r" ] && reboot -f
set +x
fi
# ------------
# Run local bottom script
if type run_scripts > /dev/null 2>&1 && \
[ -f "/scripts/local-bottom" -o -d "/scripts/local-bottom" ]
then
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Running /scripts/local-bottom"
run_scripts /scripts/local-bottom
[ "$quiet" != "y" ] && zfs_log_end_msg
fi
}
diff --git a/etc/init.d/zfs-functions.in b/etc/init.d/zfs-functions.in
index a2204c157844..68cb1bb523a0 100644
--- a/etc/init.d/zfs-functions.in
+++ b/etc/init.d/zfs-functions.in
@@ -1,416 +1,420 @@
# This is a script with common functions etc used by zfs-import, zfs-mount,
# zfs-share and zfs-zed.
#
# It is _NOT_ to be called independently
#
# 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
PATH=/sbin:/bin:/usr/bin:/usr/sbin
# Source function library
if [ -f /etc/rc.d/init.d/functions ]; then
# RedHat and derivates
. /etc/rc.d/init.d/functions
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 derivates
. /lib/lsb/init-functions
fi
# Of course the functions we need are called differently
# on different distributions - it would be way too easy
# otherwise!!
if type log_failure_msg > /dev/null 2>&1 ; then
# LSB functions - fall through
zfs_log_begin_msg() { log_begin_msg "$1"; }
zfs_log_end_msg() { log_end_msg "$1"; }
zfs_log_failure_msg() { log_failure_msg "$1"; }
zfs_log_progress_msg() { log_progress_msg "$1"; }
elif type success > /dev/null 2>&1 ; then
# Fedora/RedHat functions
zfs_set_ifs() {
# For some reason, the init function library have a problem
# with a changed IFS, so this function goes around that.
local tIFS="$1"
if [ -n "$tIFS" ]
then
TMP_IFS="$IFS"
IFS="$tIFS"
fi
}
zfs_log_begin_msg() { echo -n "$1 "; }
zfs_log_end_msg() {
zfs_set_ifs "$OLD_IFS"
if [ "$1" -eq 0 ]; then
success
else
failure
fi
echo
zfs_set_ifs "$TMP_IFS"
}
zfs_log_failure_msg() {
zfs_set_ifs "$OLD_IFS"
failure
echo
zfs_set_ifs "$TMP_IFS"
}
zfs_log_progress_msg() { echo -n $"$1"; }
elif type einfo > /dev/null 2>&1 ; then
# Gentoo functions
zfs_log_begin_msg() { ebegin "$1"; }
zfs_log_end_msg() { eend "$1"; }
zfs_log_failure_msg() { eend "$1"; }
# zfs_log_progress_msg() { echo -n "$1"; }
zfs_log_progress_msg() { echo -n; }
else
# Unknown - simple substitues.
zfs_log_begin_msg() { echo -n "$1"; }
zfs_log_end_msg() {
ret=$1
if [ "$ret" -ge 1 ]; then
echo " failed!"
else
echo " success"
fi
return "$ret"
}
zfs_log_failure_msg() { echo "$1"; }
zfs_log_progress_msg() { echo -n "$1"; }
fi
# Paths to what we need
ZFS="@sbindir@/zfs"
ZED="@sbindir@/zed"
ZPOOL="@sbindir@/zpool"
ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
# Sensible defaults
ZFS_MOUNT='yes'
ZFS_UNMOUNT='yes'
export ZFS ZED ZPOOL ZPOOL_CACHE ZFS_MOUNT ZFS_UNMOUNT
# Source zfs configuration, overriding the defaults
if [ -f @initconfdir@/zfs ]; then
. @initconfdir@/zfs
fi
# ----------------------------------------------------
zfs_action()
{
local MSG="$1"; shift
local CMD="$*"
local ret
zfs_log_begin_msg "$MSG "
$CMD
ret=$?
if [ "$ret" -eq 0 ]; then
zfs_log_end_msg $ret
else
zfs_log_failure_msg $ret
fi
return $ret
}
# Returns
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
# 3 if unsupported
#
zfs_daemon_start()
{
local PIDFILE="$1"; shift
local DAEMON_BIN="$1"; shift
local DAEMON_ARGS="$*"
if type start-stop-daemon > /dev/null 2>&1 ; then
# LSB functions
start-stop-daemon --start --quiet --pidfile "$PIDFILE" \
--exec "$DAEMON_BIN" --test > /dev/null || return 1
start-stop-daemon --start --quiet --exec "$DAEMON_BIN" -- \
$DAEMON_ARGS || return 2
# On Debian GNU/Linux, 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 ]
then
ln -s "$PIDFILE" /run/sendsigs.omit.d/zed
fi
elif type daemon > /dev/null 2>&1 ; then
# Fedora/RedHat functions
daemon --pidfile "$PIDFILE" "$DAEMON_BIN" $DAEMON_ARGS
return $?
else
# Unsupported
return 3
fi
return 0
}
# Returns
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# 3 if unsupported
#
zfs_daemon_stop()
{
local PIDFILE="$1"
local DAEMON_BIN="$2"
local DAEMON_NAME="$3"
if type start-stop-daemon > /dev/null 2>&1 ; then
# LSB functions
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
--pidfile "$PIDFILE" --name "$DAEMON_NAME"
[ "$?" = 0 ] && rm -f "$PIDFILE"
return $?
elif type killproc > /dev/null 2>&1 ; then
# Fedora/RedHat functions
killproc -p "$PIDFILE" "$DAEMON_NAME"
[ "$?" = 0 ] && rm -f "$PIDFILE"
return $?
else
# Unsupported
return 3
fi
return 0
}
# Returns status
zfs_daemon_status()
{
local PIDFILE="$1"
local DAEMON_BIN="$2"
local DAEMON_NAME="$3"
if type status_of_proc > /dev/null 2>&1 ; then
# LSB functions
status_of_proc "$DAEMON_NAME" "$DAEMON_BIN"
return $?
elif type status > /dev/null 2>&1 ; then
# Fedora/RedHat functions
status -p "$PIDFILE" "$DAEMON_NAME"
return $?
else
# Unsupported
return 3
fi
return 0
}
zfs_daemon_reload()
{
local PIDFILE="$1"
local DAEMON_NAME="$2"
if type start-stop-daemon > /dev/null 2>&1 ; then
# LSB functions
start-stop-daemon --stop -signal 1 --quiet \
--pidfile "$PIDFILE" --name "$DAEMON_NAME"
return $?
elif type killproc > /dev/null 2>&1 ; then
# Fedora/RedHat functions
killproc -p "$PIDFILE" "$DAEMON_NAME" -HUP
return $?
else
# Unsupported
return 3
fi
return 0
}
zfs_installed()
{
if [ ! -x "$ZPOOL" ]; then
return 1
else
# Test if it works (will catch missing/broken libs etc)
"$ZPOOL" -? > /dev/null 2>&1
return $?
fi
if [ ! -x "$ZFS" ]; then
return 2
else
# Test if it works (will catch missing/broken libs etc)
"$ZFS" -? > /dev/null 2>&1
return $?
fi
return 0
}
# Trigger udev and wait for it to settle.
udev_trigger()
{
if [ -x /sbin/udevadm ]; then
/sbin/udevadm trigger --action=change --subsystem-match=block
/sbin/udevadm settle
elif [ -x /sbin/udevsettle ]; then
/sbin/udevtrigger
/sbin/udevsettle
fi
}
# Do a lot of checks to make sure it's 'safe' to continue with the import.
checksystem()
{
if grep -qiE '(^|[^\\](\\\\)* )zfs=(off|no|0)( |$)' /proc/cmdline;
then
# Called with zfs=(off|no|0) - bail because we don't
# want anything import, mounted or shared.
# HOWEVER, only do this if we're called at the boot up
# (from init), not if we're running interactivly (as in
# from the shell - we know what we're doing).
[ -n "$init" ] && exit 3
fi
# Check if ZFS is installed.
zfs_installed || return 5
# Just make sure that /dev/zfs is created.
udev_trigger
if ! [ "$(uname -m)" = "x86_64" ]; then
echo "Warning: You're not running 64bit. Currently native zfs in";
echo " Linux is only supported and tested on 64bit.";
# should we break here? People doing this should know what they
# do, thus i'm not breaking here.
fi
return 0
}
get_root_pool()
{
set -- $(mount | grep ' on / ')
[ "$5" = "zfs" ] && echo "${1%%/*}"
}
check_module_loaded()
{
- [ -r /sys/module/zfs/version ] && return 0 || return 1
+ module="$1"
+
+ [ -r "/sys/module/${module}/version" ] && return 0 || return 1
}
load_module()
{
+ module="$1"
+
# Load the zfs module stack
- if ! check_module_loaded; then
- if ! modprobe zfs; then
+ if ! check_module_loaded "$module"; then
+ if ! /sbin/modprobe "$module"; then
return 5
fi
fi
return 0
}
# first parameter is a regular expression that filters mtab
read_mtab()
{
local match="$1"
local fs mntpnt fstype opts rest TMPFILE
# Unset all MTAB_* variables
unset $(env | grep ^MTAB_ | sed 's,=.*,,')
while read -r fs mntpnt fstype opts rest; do
if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then
# * Fix problems (!?) in the mounts file. It will record
# 'rpool 1' as 'rpool\0401' instead of 'rpool\00401'
# which seems to be the correct (at least as far as
# 'printf' is concerned).
# * We need to use the external echo, because the
# internal one would interpret the backslash code
# (incorrectly), giving us a instead.
mntpnt=$(/bin/echo "$mntpnt" | sed "s,\\\0,\\\00,")
fs=$(/bin/echo "$fs" | sed "s,\\\0,\\\00,")
# Replace 'unwanted' characters with underscore.
mntpnt=$(printf '%b\n' "$mntpnt" | sed -e 's,/,_,g' \
-e 's,-,_,g' -e 's,\.,_,g' -e 's, ,_,g')
fs=$(printf '%b\n' "$fs")
# Set the variable.
eval export MTAB_$mntpnt=\"$fs\"
fi
done < /proc/mounts
}
in_mtab()
{
local fs="$(echo "$1" | sed 's,/,_,g')"
local var
var="$(eval echo MTAB_$fs)"
[ "$(eval echo "$""$var")" != "" ]
return "$?"
}
# first parameter is a regular expression that filters fstab
read_fstab()
{
local match="$1"
local i var TMPFILE
# 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
if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then
eval export FSTAB_dev_$i="$fs"
fs=$(printf '%b\n' "$fs" | sed 's,/,_,g')
eval export FSTAB_$i="$mntpnt"
i=$((i + 1))
fi
done < /etc/fstab
}
in_fstab()
{
local var
var="$(eval echo FSTAB_$1)"
[ "${var}" != "" ]
return $?
}
is_mounted()
{
local mntpt="$1"
local line
mount | \
while read line; do
if echo "$line" | grep -q " on $mntpt "; then
return 0
fi
done
return 1
}
diff --git a/etc/init.d/zfs-import.in b/etc/init.d/zfs-import.in
index fed364a606f7..b02d8a92cda1 100755
--- a/etc/init.d/zfs-import.in
+++ b/etc/init.d/zfs-import.in
@@ -1,355 +1,355 @@
#!@SHELL@
#
# zfs-import This script will import/export zfs pools.
#
# chkconfig: 2345 01 99
# description: This script will import/export zfs pools during system
# boot/shutdown.
# It is also responsible for all userspace zfs services.
# probe: true
#
### BEGIN INIT INFO
# Provides: zfs-import
# Required-Start: zfs-zed
# Required-Stop: zfs-zed
# Default-Start: S
# Default-Stop: 0 1 6
# X-Start-Before: checkfs
# X-Stop-After: zfs-mount
# Short-Description: Import ZFS pools
# Description: Run the `zpool import` or `zpool export` commands.
### END INIT INFO
#
# 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
# Source the common init script
. @sysconfdir@/zfs/zfs-functions
# ----------------------------------------------------
do_depend()
{
after sysfs udev zfs-zed
keyword -lxc -openvz -prefix -vserver
}
# Support function to get a list of all pools, separated with ';'
find_pools()
{
local CMD="$*"
local pools
pools=$($CMD 2> /dev/null | \
grep -E "pool:|^[a-zA-Z0-9]" | \
sed 's@.*: @@' | \
sort | \
while read pool; do \
echo -n "$pool;"
done)
echo "${pools%%;}" # Return without the last ';'.
}
# Import all pools
do_import()
{
local already_imported available_pools pool npools
local exception dir ZPOOL_IMPORT_PATH RET=0 r=1
# In case not shutdown cleanly.
[ -n "$init" ] && rm -f /etc/dfs/sharetab
# Just simplify code later on.
if [ -n "$USE_DISK_BY_ID" -a "$USE_DISK_BY_ID" != 'yes' ]
then
# It's something, but not 'yes' so it's no good to us.
unset USE_DISK_BY_ID
fi
# Find list of already imported pools.
already_imported=$(find_pools "$ZPOOL" list -H -oname)
available_pools=$(find_pools "$ZPOOL" import)
# Just in case - seen it happen (that a pool isn't visable/found
# with a simple "zpool import" but only when using the "-d"
# option or setting ZPOOL_IMPORT_PATH).
if [ -d "/dev/disk/by-id" ]
then
npools=$(find_pools "$ZPOOL" import -d /dev/disk/by-id)
if [ -n "$npools" ]
then
# Because we have found extra pool(s) here, which wasn't
# found 'normaly', we need to force USE_DISK_BY_ID to
# make sure we're able to actually import it/them later.
USE_DISK_BY_ID='yes'
if [ -n "$available_pools" ]
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
# available pools
available_pools="$available_pools;$npools"
else
available_pools="$npools"
fi
fi
fi
# Filter out any exceptions...
if [ -n "$ZFS_POOL_EXCEPTIONS" ]
then
local found=""
local apools=""
OLD_IFS="$IFS" ; IFS=";"
for pool in $available_pools
do
for exception in $ZFS_POOL_EXCEPTIONS
do
[ "$pool" = "$exception" ] && continue 2
found="$pool"
done
if [ -n "$found" ]
then
if [ -n "$apools" ]
then
apools="$apools;$pool"
else
apools="$pool"
fi
fi
done
IFS="$OLD_IFS"
available_pools="$apools"
fi
# For backwards compability, make sure that ZPOOL_IMPORT_PATH is set
# to something we can use later with the real import(s). We want to
# make sure we find all by* dirs, BUT by-vdev should be first (if it
# exists).
if [ -n "$USE_DISK_BY_ID" -a -z "$ZPOOL_IMPORT_PATH" ]
then
local dirs
dirs="$(for dir in $(echo /dev/disk/by-*)
do
# 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" ]
then
# Add by-vdev at the beginning.
ZPOOL_IMPORT_PATH="/dev/disk/by-vdev:"
fi
# Help with getting LUKS partitions etc imported.
if [ -d "/dev/mapper" ]; then
if [ -n "$ZPOOL_IMPORT_PATH" ]; then
ZPOOL_IMPORT_PATH="$ZPOOL_IMPORT_PATH:/dev/mapper:"
else
ZPOOL_IMPORT_PATH="/dev/mapper:"
fi
fi
# ... and /dev at the very end, just for good measure.
ZPOOL_IMPORT_PATH="$ZPOOL_IMPORT_PATH$dirs:/dev"
fi
# Needs to be exported for "zpool" to catch it.
[ -n "$ZPOOL_IMPORT_PATH" ] && export ZPOOL_IMPORT_PATH
# Mount all availible pools (except those set in ZFS_POOL_EXCEPTIONS.
#
# If not interactive (run from init - variable init='/sbin/init')
# we get ONE line for all pools being imported, with just a dot
# as status for each pool.
# Example: Importing ZFS pool(s)... [OK]
#
# If it IS interactive (started from the shell manually), then we
# get one line per pool importing.
# Example: Importing ZFS pool pool1 [OK]
# Importing ZFS pool pool2 [OK]
# [etc]
[ -n "$init" ] && zfs_log_begin_msg "Importing ZFS pool(s)"
OLD_IFS="$IFS" ; IFS=";"
for pool in $available_pools
do
[ -z "$pool" ] && continue
# We have pools that haven't been imported - import them
if [ -n "$init" ]
then
# Not interactive - a dot for each pool.
# Except on Gentoo where this doesn't work.
zfs_log_progress_msg "."
else
# Interactive - one 'Importing ...' line per pool
zfs_log_begin_msg "Importing ZFS pool $pool"
fi
# Import by using ZPOOL_IMPORT_PATH (either set above or in
# the config file) _or_ with the 'built in' default search
# paths. This is the prefered way.
"$ZPOOL" import -N "$pool" 2> /dev/null
r="$?" ; RET=$((RET + r))
if [ "$r" -eq 0 ]
then
# Output success and process the next pool
[ -z "$init" ] && zfs_log_end_msg 0
continue
fi
# We don't want a fail msg here, we're going to try import
# using the cache file soon and that might succeed.
[ ! -f "$ZPOOL_CACHE" ] && zfs_log_end_msg "$RET"
if [ "$r" -gt 0 -a -f "$ZPOOL_CACHE" ]
then
# Failed to import without a cache file. Try WITH...
if [ -z "$init" -a "$VERBOSE_MOUNT" = 'yes' ]
then
# Interactive + Verbose = more information
zfs_log_progress_msg " using cache file"
fi
"$ZPOOL" import -c "$ZPOOL_CACHE" -N "$pool" 2> /dev/null
r="$?" ; RET=$((RET + r))
if [ "$r" -eq 0 ]
then
[ -z "$init" ] && zfs_log_end_msg 0
continue 3 # Next pool
fi
zfs_log_end_msg "$RET"
fi
done
[ -n "$init" ] && zfs_log_end_msg "$RET"
IFS="$OLD_IFS"
[ -n "$already_imported" -a -z "$available_pools" ] && return 0
return "$RET"
}
# Export all pools
do_export()
{
local pool root_pool RET r
RET=0
root_pool=$(get_root_pool)
[ -n "$init" ] && zfs_log_begin_msg "Exporting ZFS pool(s)"
TMPFILE=$(mktemp --tmpdir=/var/tmp zpool.XXXXX)
"$ZPOOL" list -H -oname > "$TMPFILE"
while read pool; do
[ "$pool" = "$root_pool" ] && continue
if [ -z "$init" ]
then
# Interactive - one 'Importing ...' line per pool
zfs_log_begin_msg "Exporting ZFS pool $pool"
else
# Not interactive - a dot for each pool.
zfs_log_progress_msg "."
fi
"$ZPOOL" export "$pool"
r="$?" ; RET=$((RET + r))
[ -z "$init" ] && zfs_log_end_msg "$r"
done < "$TMPFILE"
rm -f "$TMPFILE"
[ -n "$init" ] && zfs_log_end_msg "$RET"
}
# Output the status and list of pools
do_status()
{
- check_module_loaded || exit 0
+ check_module_loaded "zfs" || exit 0
"$ZPOOL" status && echo "" && "$ZPOOL" list
}
do_start()
{
if [ "$VERBOSE_MOUNT" = 'yes' ]
then
zfs_log_begin_msg "Checking if ZFS userspace tools present"
fi
if checksystem
then
[ "$VERBOSE_MOUNT" = 'yes' ] && zfs_log_end_msg 0
if [ "$VERBOSE_MOUNT" = 'yes' ]
then
zfs_log_begin_msg "Loading kernel ZFS infrastructure"
fi
- if ! load_module
+ if ! load_module "zfs"
then
[ "$VERBOSE_MOUNT" = 'yes' ] && zfs_log_end_msg 1
return 5
fi
[ "$VERBOSE_MOUNT" = 'yes' ] && zfs_log_end_msg 0
do_import && udev_trigger # just to make sure we get zvols.
return 0
else
return 1
fi
}
do_stop()
{
# Check to see if the module is even loaded.
- check_module_loaded || exit 0
+ check_module_loaded "zfs" || exit 0
do_export
}
# ----------------------------------------------------
if [ ! -e /etc/gentoo-release ]
then
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
status)
do_status
;;
force-reload|condrestart|reload|restart)
# no-op
;;
*)
[ -n "$1" ] && echo "Error: Unknown command $1."
echo "Usage: $0 {start|stop|status}"
exit 3
;;
esac
exit $?
else
# Create wrapper functions since Gentoo don't use the case part.
depend() { do_depend; }
start() { do_start; }
stop() { do_stop; }
status() { do_status; }
fi
diff --git a/etc/init.d/zfs-mount.in b/etc/init.d/zfs-mount.in
index e26813d901d4..3be3d7b1369f 100755
--- a/etc/init.d/zfs-mount.in
+++ b/etc/init.d/zfs-mount.in
@@ -1,224 +1,224 @@
#!@SHELL@
#
# zfs-mount This script will mount/umount the zfs filesystems.
#
# chkconfig: 2345 06 99
# description: This script will mount/umount the zfs filesystems during
# system boot/shutdown. Configuration of which filesystems
# should be mounted is handled by the zfs 'mountpoint' and
# 'canmount' properties. See the zfs(8) man page for details.
# It is also responsible for all userspace zfs services.
# probe: true
#
### BEGIN INIT INFO
# Provides: zfs-mount
# Required-Start: $local_fs zfs-import
# Required-Stop: $local_fs zfs-import
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Stop-After: zfs-share
# Short-Description: Mount ZFS filesystems and volumes
# Description: Run the `zfs mount -a` or `zfs umount -a` commands.
### END INIT INFO
#
# 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
# Source the common init script
. @sysconfdir@/zfs/zfs-functions
# ----------------------------------------------------
chkroot() {
while read line; do
set -- $line
if [ "$2" = "/" ]; then
return 0
fi
done < /etc/mtab
return 1
}
do_depend()
{
after procfs zfs-import sysfs procps
use mtab
keyword -lxc -openvz -prefix -vserver
}
# Mount all datasets/filesystems
do_mount()
{
local verbose overlay i mntpt val
[ "$VERBOSE_MOUNT" = 'yes' ] && verbose=v
[ "$OVERLAY_MOUNTS" = 'yes' ] && overlay=O
zfs_action "Mounting ZFS filesystem(s)" \
"$ZFS" mount -a$verbose$overlay "$MOUNT_EXTRA_OPTIONS"
# Require each volume/filesytem to have 'noauto' and no fsck
# option. This shouldn't really be necessary, as long as one
# can get zfs-import to run sufficiently early on in the boot
# process - before local mounts. This is just here in case/if
# this isn't possible.
[ "$VERBOSE_MOUNT" = 'yes' ] && \
zfs_log_begin_msg "Mounting volumes and filesystems registered in fstab"
read_mtab "^/dev/(zd|zvol)"
read_fstab "^/dev/(zd|zvol)"
i=0; var=$(eval echo FSTAB_$i)
while [ -n "$(eval echo "$""$var")" ]
do
mntpt=$(eval echo "$""$var")
dev=$(eval echo "$"FSTAB_dev_$i)
if ! in_mtab "$mntpt" && ! is_mounted "$mntpt" && [ -e "$dev" ]
then
[ "$VERBOSE_MOUNT" = 'yes' ] && \
zfs_log_progress_msg "$mntpt "
fsck "$dev" && mount "$mntpt"
fi
i=$((i + 1))
var=$(eval echo FSTAB_$i)
done
read_mtab "[[:space:]]zfs[[:space:]]"
read_fstab "[[:space:]]zfs[[:space:]]"
i=0; var=$(eval echo FSTAB_$i)
while [ -n "$(eval echo "$""$var")" ]
do
mntpt=$(eval echo "$""$var")
if ! in_mtab "$mntpt" && ! is_mounted "$mntpt"
then
[ "$VERBOSE_MOUNT" = 'yes' ] && \
zfs_log_progress_msg "$mntpt "
mount "$mntpt"
fi
i=$((i + 1))
var=$(eval echo FSTAB_$i)
done
[ "$VERBOSE_MOUNT" = 'yes' ] && zfs_log_end_msg 0
return 0
}
# Unmount all filesystems
do_unmount()
{
local i var mntpt
# This shouldn't really be necessary, as long as one can get
# zfs-import to run sufficiently late in the shutdown/reboot process
# - after unmounting local filesystems. This is just here in case/if
# this isn't possible.
zfs_action "Unmounting ZFS filesystems" "$ZFS" unmount -a
[ "$VERBOSE_MOUNT" = 'yes' ] && \
zfs_log_begin_msg "Unmounting volumes and filesystems registered in fstab"
read_mtab "^/dev/(zd|zvol)"
read_fstab "^/dev/(zd|zvol)"
i=0; var=$(eval echo FSTAB_$i)
while [ -n "$(eval echo "$""$var")" ]
do
mntpt=$(eval echo "$""$var")
dev=$(eval echo "$"FSTAB_dev_$i)
if in_mtab "$mntpt"
then
[ "$VERBOSE_MOUNT" = 'yes' ] && \
zfs_log_progress_msg "$mntpt "
umount "$mntpt"
fi
i=$((i + 1))
var=$(eval echo FSTAB_$i)
done
read_mtab "[[:space:]]zfs[[:space:]]"
read_fstab "[[:space:]]zfs[[:space:]]"
i=0; var=$(eval echo FSTAB_$i)
while [ -n "$(eval echo "$""$var")" ]
do
mntpt=$(eval echo "$""$var")
if in_mtab "$mntpt"; then
[ "$VERBOSE_MOUNT" = 'yes' ] && \
zfs_log_progress_msg "$mntpt "
umount "$mntpt"
fi
i=$((i + 1))
var=$(eval echo FSTAB_$i)
done
[ "$VERBOSE_MOUNT" = 'yes' ] && zfs_log_end_msg 0
return 0
}
do_start()
{
- check_module_loaded || exit 0
+ check_module_loaded "zfs" || exit 0
case "$ZFS_MOUNT" in
[Oo][Ff][Ff]|[Nn][Oo]|''|0)
exit 3
;;
esac
# Ensure / exists in /etc/mtab, if not update mtab accordingly.
# This should be handled by rc.sysinit but lets be paranoid.
if ! chkroot
then
mount -f /
fi
do_mount
}
do_stop()
{
case "$ZFS_UNMOUNT" in
[Oo][Ff][Ff]|[Nn][Oo]|''|0)
exit 0
;;
esac
- check_module_loaded || exit 0
+ check_module_loaded "zfs" || exit 0
do_unmount
}
# ----------------------------------------------------
if [ ! -e /etc/gentoo-release ]
then
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
force-reload|condrestart|reload|restart|status)
# no-op
;;
*)
[ -n "$1" ] && echo "Error: Unknown command $1."
echo "Usage: $0 {start|stop}"
exit 3
;;
esac
exit $?
else
# Create wrapper functions since Gentoo don't use the case part.
depend() { do_depend; }
start() { do_start; }
stop() { do_stop; }
fi
diff --git a/etc/init.d/zfs-share.in b/etc/init.d/zfs-share.in
index 70439151b37e..b2f8e773e6b1 100755
--- a/etc/init.d/zfs-share.in
+++ b/etc/init.d/zfs-share.in
@@ -1,93 +1,93 @@
#!@SHELL@
#
# zfs-share This script will network share zfs filesystems and volumes.
#
# chkconfig: 2345 30 99
# description: Run the `zfs share -a` or `zfs unshare -a` commands
# for controlling iSCSI, NFS, or CIFS network shares.
# probe: true
#
### BEGIN INIT INFO
# Provides: zfs-share
# Required-Start: $local_fs $network $remote_fs zfs-mount
# Required-Stop: $local_fs $network $remote_fs zfs-mount
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Should-Start: iscsi iscsitarget istgt scst @NFS_SRV@ samba samba4 zfs-mount
# Should-Stop: iscsi iscsitarget istgt scst @NFS_SRV@ samba samba4 zfs-mount
# Short-Description: Network share ZFS datasets and volumes.
# Description: Run the `zfs share -a` or `zfs unshare -a` commands
# for controlling iSCSI, NFS, or CIFS network shares.
### END INIT INFO
#
# 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
# Source the common init script
. @sysconfdir@/zfs/zfs-functions
# ----------------------------------------------------
do_depend()
{
after sysfs zfs-mount
keyword -lxc -openvz -prefix -vserver
}
do_start()
{
case "$ZFS_SHARE" in
[Oo][Ff][Ff]|[Nn][Oo]|''|0)
exit 0
;;
esac
- check_module_loaded || exit 0
+ check_module_loaded "zfs" || exit 0
zfs_action "Sharing ZFS filesystems" "$ZFS" share -a
}
do_stop()
{
case "$ZFS_UNSHARE" in
[Oo][Ff][Ff]|[Nn][Oo]|''|0)
exit 0
;;
esac
- check_module_loaded || exit 0
+ check_module_loaded "zfs" || exit 0
zfs_action "Unsharing ZFS filesystems" "$ZFS" unshare -a
}
# ----------------------------------------------------
if [ ! -e /etc/gentoo-release ]; then
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
force-reload|reload|restart|status)
# no-op
;;
*)
[ -n "$1" ] && echo "Error: Unknown command $1."
echo "Usage: $0 {start|stop}"
exit 3
;;
esac
exit $?
else
# Create wrapper functions since Gentoo don't use the case part.
depend() { do_depend; }
start() { do_start; }
stop() { do_stop; }
fi
diff --git a/etc/init.d/zfs-zed.in b/etc/init.d/zfs-zed.in
index 1458387f5110..9fa243f8f29c 100755
--- a/etc/init.d/zfs-zed.in
+++ b/etc/init.d/zfs-zed.in
@@ -1,148 +1,148 @@
#!@SHELL@
#
# zfs-zed
#
# chkconfig: 2345 01 99
# description: This script will start and stop the ZFS Event Daemon.
# probe: true
#
### BEGIN INIT INFO
# Provides: zfs-zed
# Required-Start: mtab
# Required-Stop: $local_fs mtab
# Default-Start: S
# Default-Stop: 0 1 6
# X-Start-Before: checkfs
# X-Stop-After: zfs-import
# Short-Description: ZFS Event Daemon
# Description: zed monitors ZFS events. When a zevent is posted, zed
# will run any scripts that have been enabled for the
# corresponding zevent class.
### END INIT INFO
#
# NOTE: Not having '$local_fs' on Required-Start but only on Required-Stop
# is on purpose. If we have '$local_fs' in both (and X-Start-Before=checkfs)
# we get conflicts - zed and import needs to be started extremely early,
# but not stopped too late.
#
# 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
# Source the common init script
. @sysconfdir@/zfs/zfs-functions
ZED_NAME="zed"
ZED_PIDFILE="@runstatedir@/$ZED_NAME.pid"
# Exit if the package is not installed
[ -x "$ZED" ] || exit 0
# ----------------------------------------------------
do_depend()
{
# Try to allow people to mix and match fstab with ZFS in a way that makes sense.
if [ "$(mountinfo -s /)" = 'zfs' ]
then
before localmount
else
after localmount
fi
# bootmisc will log to /var which may be a different zfs than root.
before bootmisc logger zfs-import
after sysfs
}
do_start()
{
- check_module_loaded || exit 0
+ check_module_loaded "zfs" || exit 0
ZED_ARGS="$ZED_ARGS -p $ZED_PIDFILE"
zfs_action "Starting ZFS Event Daemon" zfs_daemon_start \
"$ZED_PIDFILE" "$ZED" "$ZED_ARGS"
return "$?"
}
do_stop()
{
local pools RET
- check_module_loaded || exit 0
+ check_module_loaded "zfs" || exit 0
zfs_action "Stopping ZFS Event Daemon" zfs_daemon_stop \
"$ZED_PIDFILE" "$ZED" "$ZED_NAME"
if [ "$?" -eq "0" ]
then
# Let's see if we have any pools imported
pools=$("$ZPOOL" list -H -oname)
if [ -z "$pools" ]
then
# No pools imported, it is/should be safe/possible to
# unload modules.
zfs_action "Unloading modules" rmmod zfs zunicode \
zavl zcommon znvpair spl
return "$?"
fi
else
return "$?"
fi
}
do_status()
{
- check_module_loaded || exit 0
+ check_module_loaded "zfs" || exit 0
zfs_daemon_status "$ZED_PIDFILE" "$ZED" "$ZED_NAME"
return "$?"
}
do_reload()
{
- check_module_loaded || exit 0
+ check_module_loaded "zfs" || exit 0
zfs_action "Reloading ZFS Event Daemon" zfs_daemon_reload \
"$ZED_PIDFILE" "$ZED_NAME"
return "$?"
}
# ----------------------------------------------------
if [ ! -e /etc/gentoo-release ]; then
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
status)
do_status
;;
reload|force-reload)
do_reload
;;
restart)
do_stop
do_start
;;
*)
[ -n "$1" ] && echo "Error: Unknown command $1."
echo "Usage: $0 {start|stop|status|reload|restart}"
exit 1
;;
esac
exit $?
else
# Create wrapper functions since Gentoo don't use the case part.
depend() { do_depend; }
start() { do_start; }
stop() { do_stop; }
status() { do_status; }
reload() { do_reload; }
fi
File Metadata
Details
Attached
Mime Type
application/octet-stream
Expires
Sun, Jul 7, 2:39 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
10332017
Default Alt Text
(62 KB)
Attached To
Mode
rG FreeBSD src repository
Attached
Detach File
Event Timeline
Log In to Comment