add debian packaging files for zfs
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
## /etc/dpkg/dpkg.cfg.d/zfs-doc
|
||||
##
|
||||
## DPKG overrides that prevent the installation of ZoL documentation.
|
||||
|
||||
## Enable this line to reduce installation size.
|
||||
#path-exclude /usr/share/doc/zfs-doc/*
|
||||
@@ -0,0 +1,2 @@
|
||||
# Force the inclusion of Busybox in the initramfs.
|
||||
BUSYBOX=y
|
||||
@@ -0,0 +1,75 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Add ZoL filesystem capabilities to an initrd, usually for a native OpenZFS 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"
|
||||
|
||||
# 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.
|
||||
MANUAL_ADD_MODULES_LIST="zlib_deflate spl zavl zcommon znvpair zunicode zfs"
|
||||
|
||||
# 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 $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
|
||||
|
||||
# ZoL 0.6.3 deprecated the hostid check.
|
||||
if [ -f /etc/hostid ]
|
||||
then
|
||||
cp -p /etc/hostid "$DESTDIR/etc/hostid"
|
||||
fi
|
||||
@@ -0,0 +1,163 @@
|
||||
# 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.
|
||||
#
|
||||
|
||||
|
||||
pre_mountroot()
|
||||
{
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top"
|
||||
run_scripts /scripts/local-top
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
if [ -r '/etc/default/zfs' ]
|
||||
then
|
||||
. '/etc/default/zfs'
|
||||
if [ "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP" -gt '0' ]
|
||||
then
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Sleeping for $ZFS_INITRD_PRE_MOUNTROOT_SLEEP seconds..."
|
||||
sleep "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP"
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Duplicates the functionality found under try_failure_hooks in functions
|
||||
# but invoking that would be inappropriate here.
|
||||
disable_plymouth()
|
||||
{
|
||||
if [ -x /bin/plymouth ] && /bin/plymouth --ping
|
||||
then
|
||||
/bin/plymouth hide-splash >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
mountroot()
|
||||
{
|
||||
pre_mountroot
|
||||
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
|
||||
run_scripts /scripts/local-premount
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
# Wait for all of the /dev/{hd,sd}[a-z] device nodes to appear.
|
||||
wait_for_udev
|
||||
|
||||
# Load the module now to get consistent automatic pool import behavior.
|
||||
modprobe zfs
|
||||
|
||||
# Check the kernel command line for overrides.
|
||||
ZFS_RPOOL="${rpool#rpool=}"
|
||||
ZFS_BOOTFS="${bootfs#bootfs=}"
|
||||
|
||||
if [ -z "$ZFS_RPOOL" ]
|
||||
then
|
||||
# Check for the `-B zfs-bootfs=%s/%u,...` kind of parameter.
|
||||
#
|
||||
# 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')
|
||||
|
||||
# Only the pool name is relevant because the ZFS filesystem on
|
||||
# Linux is extrinsic and the userland cannot resolve a ZFS
|
||||
# object number.
|
||||
#
|
||||
# Strip everything after the first slash character.
|
||||
ZFS_RPOOL=$(echo "$ZFS_RPOOL" | sed -e 's,/.*,,')
|
||||
fi
|
||||
|
||||
# Use "rpool" as the default, like on most Solaris systems.
|
||||
[ -z "$ZFS_RPOOL" ] && ZFS_RPOOL='rpool'
|
||||
|
||||
# @FIXME: Forcing the import should not be necessary.
|
||||
#
|
||||
# Consider inhibiting automatic zpool imports in the initramfs
|
||||
# environment and doing a full import in the regular system instead.
|
||||
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Importing ZFS root pool $ZFS_RPOOL"
|
||||
if [ -f /etc/zfs/zpool.cache ]
|
||||
then
|
||||
ZFS_STDERR=$(zpool list "$ZFS_RPOOL" 1>/dev/null 2>&1 \
|
||||
|| zpool import -f -N "$ZFS_RPOOL" 2>&1)
|
||||
ZFS_ERROR=$?
|
||||
else
|
||||
ZFS_STDERR=$(zpool import -f -N "$ZFS_RPOOL" 2>&1)
|
||||
ZFS_ERROR=$?
|
||||
fi
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
if [ "$ZFS_ERROR" -ne 0 ]
|
||||
then
|
||||
disable_plymouth
|
||||
echo "Command: zpool import -f -N $ZFS_RPOOL"
|
||||
echo "Message: $ZFS_STDERR"
|
||||
echo "Error: $ZFS_ERROR"
|
||||
echo ""
|
||||
echo "Manually import the root pool at the command prompt and then exit."
|
||||
echo "Hint: Try: zpool import -f -R / -N $ZFS_RPOOL"
|
||||
/bin/sh
|
||||
fi
|
||||
|
||||
if [ -z "$ZFS_BOOTFS" ]
|
||||
then
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Getting ZFS bootfs property"
|
||||
ZFS_BOOTFS=$(zpool list -H -o bootfs "$ZFS_RPOOL")
|
||||
ZFS_ERROR=$?
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
fi
|
||||
|
||||
if [ -z "$ZFS_BOOTFS" ]
|
||||
then
|
||||
disable_plymouth
|
||||
echo "Command: zpool list -H -o bootfs $ZFS_RPOOL"
|
||||
echo "Error: $ZFS_ERROR, unable to get the bootfs property."
|
||||
echo ""
|
||||
echo "Manually mount the root filesystem on $rootmnt and then exit."
|
||||
echo "Hint: Try: mount -t zfs -o zfsutil $ZFS_RPOOL/ROOT/system $rootmnt"
|
||||
/bin/sh
|
||||
fi
|
||||
|
||||
# Force the mountpoint to the only correct value for a root filesystem.
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Setting mountpoint=/ on ZFS filesystem $ZFS_BOOTFS"
|
||||
ZFS_STDERR=$(zfs set mountpoint=/ "$ZFS_BOOTFS" 2>&1)
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
# 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.
|
||||
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Mounting ZFS filesystem $ZFS_BOOTFS"
|
||||
ZFS_STDERR=$(mount -t zfs -o zfsutil "$ZFS_BOOTFS" "$rootmnt" 2>&1)
|
||||
ZFS_ERROR=$?
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
|
||||
if [ "$ZFS_ERROR" -ne 0 ]
|
||||
then
|
||||
disable_plymouth
|
||||
echo ""
|
||||
echo "Command: mount -t zfs -o zfsutil $ZFS_BOOTFS $rootmnt"
|
||||
echo "Message: $ZFS_STDERR"
|
||||
echo "Error: $ZFS_ERROR"
|
||||
echo ""
|
||||
echo "Manually mount the root filesystem on $rootmnt and then exit."
|
||||
/bin/sh
|
||||
fi
|
||||
|
||||
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
|
||||
run_scripts /scripts/local-bottom
|
||||
[ "$quiet" != "y" ] && log_end_msg
|
||||
}
|
||||
@@ -0,0 +1,391 @@
|
||||
# Copyright (c) 2013, Aneurin Price <aneurin.price@gmail.com>
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation
|
||||
# files (the "Software"), to deal in the Software without
|
||||
# restriction, including without limitation the rights to use,
|
||||
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following
|
||||
# conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
if [[ -w /dev/zfs ]]; then
|
||||
__ZFS_CMD="zfs"
|
||||
__ZPOOL_CMD="zpool"
|
||||
else
|
||||
__ZFS_CMD="sudo zfs"
|
||||
__ZPOOL_CMD="sudo zpool"
|
||||
fi
|
||||
|
||||
__zfs_get_commands()
|
||||
{
|
||||
$__ZFS_CMD 2>&1 | awk '/^\t[a-z]/ {print $1}' | cut -f1 -d '|' | uniq
|
||||
}
|
||||
|
||||
__zfs_get_properties()
|
||||
{
|
||||
$__ZFS_CMD get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all name space
|
||||
}
|
||||
|
||||
__zfs_get_editable_properties()
|
||||
{
|
||||
$__ZFS_CMD get 2>&1 | awk '$2 == "YES" {print $1"="}'
|
||||
}
|
||||
|
||||
__zfs_get_inheritable_properties()
|
||||
{
|
||||
$__ZFS_CMD get 2>&1 | awk '$3 == "YES" {print $1}'
|
||||
}
|
||||
|
||||
__zfs_list_datasets()
|
||||
{
|
||||
$__ZFS_CMD list -H -o name -t filesystem,volume
|
||||
}
|
||||
|
||||
__zfs_list_filesystems()
|
||||
{
|
||||
$__ZFS_CMD list -H -o name -t filesystem
|
||||
}
|
||||
|
||||
__zfs_match_snapshot()
|
||||
{
|
||||
local base_dataset=${cur%@*}
|
||||
if [[ $base_dataset != $cur ]]
|
||||
then
|
||||
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 $base_dataset
|
||||
else
|
||||
$__ZFS_CMD list -H -o name -t filesystem,volume | awk '{print $1"@"}'
|
||||
fi
|
||||
}
|
||||
|
||||
__zfs_match_explicit_snapshot()
|
||||
{
|
||||
local base_dataset=${cur%@*}
|
||||
if [[ $base_dataset != $cur ]]
|
||||
then
|
||||
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 $base_dataset
|
||||
fi
|
||||
}
|
||||
|
||||
__zfs_match_multiple_snapshots()
|
||||
{
|
||||
local existing_opts=$(expr "$cur" : '\(.*\)[%,]')
|
||||
if [[ $existing_opts ]]
|
||||
then
|
||||
local base_dataset=${cur%@*}
|
||||
if [[ $base_dataset != $cur ]]
|
||||
then
|
||||
local cur=${cur##*,}
|
||||
if [[ $cur =~ ^%|%.*% ]]
|
||||
then
|
||||
# correct range syntax is start%end
|
||||
return 1
|
||||
fi
|
||||
local range_start=$(expr "$cur" : '\(.*%\)')
|
||||
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 $base_dataset | sed 's$.*@$'$range_start'$g'
|
||||
fi
|
||||
else
|
||||
__zfs_match_explicit_snapshot; __zfs_list_datasets
|
||||
fi
|
||||
}
|
||||
|
||||
__zfs_list_volumes()
|
||||
{
|
||||
$__ZFS_CMD list -H -o name -t volume
|
||||
}
|
||||
|
||||
__zfs_argument_chosen()
|
||||
{
|
||||
local word property
|
||||
for word in $(seq $((COMP_CWORD-1)) -1 2)
|
||||
do
|
||||
local prev="${COMP_WORDS[$word]}"
|
||||
if [[ ${COMP_WORDS[$word-1]} != -[tos] ]]
|
||||
then
|
||||
if [[ "$prev" == [^,]*,* ]] || [[ "$prev" == *[@:]* ]]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
for property in $@
|
||||
do
|
||||
if [[ $prev == "$property" ]]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
__zfs_complete_ordered_arguments()
|
||||
{
|
||||
local list1=$1
|
||||
local list2=$2
|
||||
local cur=$3
|
||||
local extra=$4
|
||||
if __zfs_argument_chosen $list1
|
||||
then
|
||||
COMPREPLY=($(compgen -W "$list2 $extra" -- "$cur"))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "$list1 $extra" -- "$cur"))
|
||||
fi
|
||||
}
|
||||
|
||||
__zfs_complete_multiple_options()
|
||||
{
|
||||
local options=$1
|
||||
local cur=$2
|
||||
|
||||
COMPREPLY=($(compgen -W "$options" -- "${cur##*,}"))
|
||||
local existing_opts=$(expr "$cur" : '\(.*,\)')
|
||||
if [[ $existing_opts ]]
|
||||
then
|
||||
COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" )
|
||||
fi
|
||||
}
|
||||
|
||||
__zfs_complete_switch()
|
||||
{
|
||||
local options=$1
|
||||
if [[ ${cur:0:1} == - ]]
|
||||
then
|
||||
COMPREPLY=($(compgen -W "-{$options}" -- "$cur"))
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
__zfs_complete()
|
||||
{
|
||||
local cur prev cmd cmds
|
||||
COMPREPLY=()
|
||||
# Don't split on colon
|
||||
_get_comp_words_by_ref -n : -c cur -p prev -w COMP_WORDS -i COMP_CWORD
|
||||
cmd="${COMP_WORDS[1]}"
|
||||
|
||||
if [[ ${prev##*/} == zfs ]]
|
||||
then
|
||||
cmds=$(__zfs_get_commands)
|
||||
COMPREPLY=($(compgen -W "$cmds -?" -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
case "${cmd}" in
|
||||
clone)
|
||||
case "${prev}" in
|
||||
-o)
|
||||
COMPREPLY=($(compgen -W "$(__zfs_get_editable_properties)" -- "$cur"))
|
||||
;;
|
||||
*)
|
||||
if ! __zfs_complete_switch "o,p"
|
||||
then
|
||||
if __zfs_argument_chosen
|
||||
then
|
||||
COMPREPLY=($(compgen -W "$(__zfs_list_datasets)" -- "$cur"))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur"))
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
get)
|
||||
case "${prev}" in
|
||||
-d)
|
||||
COMPREPLY=($(compgen -W "" -- "$cur"))
|
||||
;;
|
||||
-t)
|
||||
__zfs_complete_multiple_options "filesystem volume snapshot all" "$cur"
|
||||
;;
|
||||
-s)
|
||||
__zfs_complete_multiple_options "local default inherited temporary none" "$cur"
|
||||
;;
|
||||
-o)
|
||||
__zfs_complete_multiple_options "name property value source received all" "$cur"
|
||||
;;
|
||||
*)
|
||||
if ! __zfs_complete_switch "H,r,p,d,o,t,s"
|
||||
then
|
||||
if __zfs_argument_chosen $(__zfs_get_properties)
|
||||
then
|
||||
COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur"))
|
||||
else
|
||||
__zfs_complete_multiple_options "$(__zfs_get_properties)" "$cur"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
inherit)
|
||||
if ! __zfs_complete_switch "r"
|
||||
then
|
||||
__zfs_complete_ordered_arguments "$(__zfs_get_inheritable_properties)" "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" $cur
|
||||
fi
|
||||
;;
|
||||
list)
|
||||
case "${prev}" in
|
||||
-d)
|
||||
COMPREPLY=($(compgen -W "" -- "$cur"))
|
||||
;;
|
||||
-t)
|
||||
__zfs_complete_multiple_options "filesystem volume snapshot all" "$cur"
|
||||
;;
|
||||
-o)
|
||||
__zfs_complete_multiple_options "$(__zfs_get_properties)" "$cur"
|
||||
;;
|
||||
-s|-S)
|
||||
COMPREPLY=($(compgen -W "$(__zfs_get_properties)" -- "$cur"))
|
||||
;;
|
||||
*)
|
||||
if ! __zfs_complete_switch "H,r,d,o,t,s,S"
|
||||
then
|
||||
COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur"))
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
promote)
|
||||
COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur"))
|
||||
;;
|
||||
rollback)
|
||||
if ! __zfs_complete_switch "r,R,f"
|
||||
then
|
||||
COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur"))
|
||||
fi
|
||||
;;
|
||||
send)
|
||||
if ! __zfs_complete_switch "d,n,P,p,R,v,i,I"
|
||||
then
|
||||
COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur"))
|
||||
fi
|
||||
;;
|
||||
snapshot)
|
||||
case "${prev}" in
|
||||
-o)
|
||||
COMPREPLY=($(compgen -W "$(__zfs_get_editable_properties)" -- "$cur"))
|
||||
;;
|
||||
*)
|
||||
if ! __zfs_complete_switch "o,r"
|
||||
then
|
||||
COMPREPLY=($(compgen -W "$(__zfs_list_datasets | awk '{print $1"@"}')" -- "$cur"))
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
set)
|
||||
__zfs_complete_ordered_arguments "$(__zfs_get_editable_properties)" "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" $cur
|
||||
;;
|
||||
upgrade)
|
||||
case "${prev}" in
|
||||
-a|-V|-v)
|
||||
COMPREPLY=($(compgen -W "" -- "$cur"))
|
||||
;;
|
||||
*)
|
||||
if ! __zfs_complete_switch "a,V,v,r"
|
||||
then
|
||||
COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur"))
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
destroy)
|
||||
if ! __zfs_complete_switch "d,f,n,p,R,r,v"
|
||||
then
|
||||
__zfs_complete_multiple_options "$(__zfs_match_multiple_snapshots)" $cur
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur"))
|
||||
;;
|
||||
esac
|
||||
__ltrim_colon_completions "$cur"
|
||||
return 0
|
||||
}
|
||||
|
||||
__zpool_get_commands()
|
||||
{
|
||||
$__ZPOOL_CMD 2>&1 | awk '/^\t[a-z]/ {print $1}' | uniq
|
||||
}
|
||||
|
||||
__zpool_get_properties()
|
||||
{
|
||||
$__ZPOOL_CMD get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all
|
||||
}
|
||||
|
||||
__zpool_get_editable_properties()
|
||||
{
|
||||
$__ZPOOL_CMD get 2>&1 | awk '$2 == "YES" {print $1"="}'
|
||||
}
|
||||
|
||||
__zpool_list_pools()
|
||||
{
|
||||
$__ZPOOL_CMD list -H -o name
|
||||
}
|
||||
|
||||
__zpool_complete()
|
||||
{
|
||||
local cur prev cmd cmds
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
cmd="${COMP_WORDS[1]}"
|
||||
|
||||
if [[ ${prev##*/} == zpool ]]
|
||||
then
|
||||
cmds=$(__zpool_get_commands)
|
||||
COMPREPLY=($(compgen -W "$cmds" -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
|
||||
case "${cmd}" in
|
||||
get)
|
||||
__zfs_complete_ordered_arguments "$(__zpool_get_properties)" "$(__zpool_list_pools)" $cur
|
||||
return 0
|
||||
;;
|
||||
import)
|
||||
if [[ $prev == -d ]]
|
||||
then
|
||||
_filedir -d
|
||||
else
|
||||
COMPREPLY=($(compgen -W "$(__zpool_list_pools) -d" -- "$cur"))
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
set)
|
||||
__zfs_complete_ordered_arguments "$(__zpool_get_editable_properties)" "$(__zpool_list_pools)" $cur
|
||||
return 0
|
||||
;;
|
||||
add|attach|clear|create|detach|offline|online|remove|replace)
|
||||
local pools="$(__zpool_list_pools)"
|
||||
if __zfs_argument_chosen $pools
|
||||
then
|
||||
_filedir
|
||||
else
|
||||
COMPREPLY=($(compgen -W "$pools" -- "$cur"))
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=($(compgen -W "$(__zpool_list_pools)" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
complete -F __zfs_complete zfs
|
||||
complete -F __zpool_complete zpool
|
||||
@@ -0,0 +1,28 @@
|
||||
## Allow read-only ZoL commands to be called through sudo
|
||||
## without a password. Remove the first '#' column to enable.
|
||||
##
|
||||
## CAUTION: Any syntax error introduced here will break sudo.
|
||||
##
|
||||
## Cmnd alias specification
|
||||
#Cmnd_Alias C_ZFS = \
|
||||
# /sbin/zfs "", /sbin/zfs help *, \
|
||||
# /sbin/zfs get, /sbin/zfs get *, \
|
||||
# /sbin/zfs list, /sbin/zfs list *, \
|
||||
# /sbin/zpool "", /sbin/zpool help *, \
|
||||
# /sbin/zpool iostat, /sbin/zpool iostat *, \
|
||||
# /sbin/zpool list, /sbin/zpool list *, \
|
||||
# /sbin/zpool status, /sbin/zpool status *, \
|
||||
# /sbin/zpool upgrade, /sbin/zpool upgrade -v
|
||||
#
|
||||
#Runas_Alias R_ROOT = root
|
||||
#
|
||||
## User privilege specification
|
||||
#root ALL=(ALL) ALL
|
||||
#
|
||||
## Members of the admin group may gain root privileges
|
||||
#%adm ALL=(ALL) ALL # linux
|
||||
#%admin ALL=(ALL) ALL # linux
|
||||
#%staff ALL=(ALL) ALL # solaris
|
||||
#
|
||||
## allow any user to use basic read-only ZFS commands
|
||||
#ALL ALL = (R_ROOT) NOPASSWD: C_ZFS
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
# Sub-test to exclude ZVOLs
|
||||
set -e
|
||||
partition="$1"
|
||||
|
||||
. /usr/share/os-prober/common.sh
|
||||
|
||||
if [ "$(stat -L -c %t "$partition")" = "e6" ] ; then
|
||||
debug "$1 is a ZVOL; skipping"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# No ZVOLs found
|
||||
exit 1
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Add udev rules for ZoL to the initrd.
|
||||
#
|
||||
|
||||
PREREQ="udev"
|
||||
PREREQ_UDEV_RULES="60-zvol.rules 69-vdev.rules"
|
||||
COPY_EXEC_LIST="/lib/udev/vdev_id /lib/udev/zvol_id"
|
||||
|
||||
# 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/lib/udev/rules.d/"
|
||||
for ii in $PREREQ_UDEV_RULES
|
||||
do
|
||||
if [ -e "/etc/udev/rules.d/$ii" ]
|
||||
then
|
||||
cp -p "/etc/udev/rules.d/$ii" "$DESTDIR/lib/udev/rules.d/"
|
||||
elif [ -e "/lib/udev/rules.d/$ii" ]
|
||||
then
|
||||
cp -p "/lib/udev/rules.d/$ii" "$DESTDIR/lib/udev/rules.d/"
|
||||
else
|
||||
echo "Error: Missing udev rule: $ii"
|
||||
echo " This file must be in the /etc/udev/rules.d or /lib/udev/rules.d directory."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
for ii in $COPY_EXEC_LIST
|
||||
do
|
||||
copy_exec "$ii"
|
||||
done
|
||||
|
||||
if [ -f '/etc/default/zfs' -a -r '/etc/default/zfs' ]
|
||||
then
|
||||
mkdir -p "$DESTDIR/etc/default"
|
||||
cp -a '/etc/default/zfs' "$DESTDIR/etc/default/"
|
||||
fi
|
||||
|
||||
if [ -d '/etc/zfs' -a -r '/etc/zfs' ]
|
||||
then
|
||||
mkdir -p "$DESTDIR/etc"
|
||||
cp -a '/etc/zfs' "$DESTDIR/etc/"
|
||||
fi
|
||||
Reference in New Issue
Block a user