]>
git.proxmox.com Git - mirror_zfs.git/blob - scripts/zfs-helpers.sh
3 # This script is designed to facilitate in-tree development and testing
4 # by installing symlinks on your system which refer to in-tree helper
5 # utilities. These helper utilities must be installed to in order to
6 # exercise all ZFS functionality. By using symbolic links and keeping
7 # the scripts in-tree during development they can be easily modified
8 # and those changes tracked.
10 # Use the following configuration option to override the installation
11 # paths for these scripts. The correct path is automatically set for
12 # most distributions but you can optionally set it for your environment.
14 # --with-mounthelperdir=DIR install mount.zfs in dir [/sbin]
15 # --with-udevdir=DIR install udev helpers [default=check]
16 # --with-udevruledir=DIR install udev rules [default=UDEVDIR/rules.d]
17 # --sysconfdir=DIR install zfs configuration files [PREFIX/etc]
20 BASE_DIR
=$
(dirname "$0")
21 SCRIPT_COMMON
=common.sh
22 if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then
23 .
"${BASE_DIR}/${SCRIPT_COMMON}"
25 echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
35 echo "${PROG}: $1" >&2
40 if [ "$VERBOSE" = "yes" ]; then
51 Install/remove the ZFS helper utilities.
56 -i Install the helper utilities
57 -r Remove the helper utilities
66 while getopts 'hdirv' OPTION
; do
91 if [ "$INSTALL" = "yes" ] && [ "$REMOVE" = "yes" ]; then
92 fail
"Specify -i or -r but not both"
95 if [ "$INSTALL" = "no" ] && [ "$REMOVE" = "no" ]; then
96 fail
"Either -i or -r must be specified"
99 if [ "$(id -u)" != "0" ]; then
100 fail
"Must run as root"
103 if [ "$INTREE" != "yes" ]; then
104 fail
"Must be run in-tree"
107 if [ "$VERBOSE" = "yes" ]; then
108 echo "--- Configuration ---"
109 echo "udevdir: $INSTALL_UDEV_DIR"
110 echo "udevruledir: $INSTALL_UDEV_RULE_DIR"
111 echo "mounthelperdir: $INSTALL_MOUNT_HELPER_DIR"
112 echo "sysconfdir: $INSTALL_SYSCONF_DIR"
113 echo "dryrun: $DRYRUN"
121 if [ -h "$dst" ]; then
122 echo "Symlink exists: $dst"
123 elif [ -e "$dst" ]; then
124 echo "File exists: $dst"
125 elif [ ! -e "$src" ]; then
126 echo "Source missing: $src"
128 msg
"ln -s $src $dst"
130 if [ "$DRYRUN" = "no" ]; then
131 DIR
=$
(dirname "$dst")
132 mkdir
-p "$DIR" >/dev
/null
2>&1
141 if [ -h "$dst" ]; then
144 DIR
=$
(dirname "$dst")
145 rmdir "$DIR" >/dev
/null
2>&1
146 elif [ -e "$dst" ]; then
147 echo "Expected symlink: $dst"
151 if [ "${INSTALL}" = "yes" ]; then
152 install "$CMD_DIR/mount_zfs/mount.zfs" \
153 "$INSTALL_MOUNT_HELPER_DIR/mount.zfs"
154 install "$CMD_DIR/fsck_zfs/fsck.zfs" \
155 "$INSTALL_MOUNT_HELPER_DIR/fsck.zfs"
156 install "$CMD_DIR/zvol_id/zvol_id" \
157 "$INSTALL_UDEV_DIR/zvol_id"
158 install "$CMD_DIR/vdev_id/vdev_id" \
159 "$INSTALL_UDEV_DIR/vdev_id"
160 install "$UDEV_RULE_DIR/60-zvol.rules" \
161 "$INSTALL_UDEV_RULE_DIR/60-zvol.rules"
162 install "$UDEV_RULE_DIR/69-vdev.rules" \
163 "$INSTALL_UDEV_RULE_DIR/69-vdev.rules"
164 install "$UDEV_RULE_DIR/90-zfs.rules" \
165 "$INSTALL_UDEV_RULE_DIR/90-zfs.rules"
166 install "$CMD_DIR/zpool/zpool.d" \
167 "$INSTALL_SYSCONF_DIR/zfs/zpool.d"
169 remove
"$INSTALL_MOUNT_HELPER_DIR/mount.zfs"
170 remove
"$INSTALL_MOUNT_HELPER_DIR/fsck.zfs"
171 remove
"$INSTALL_UDEV_DIR/zvol_id"
172 remove
"$INSTALL_UDEV_DIR/vdev_id"
173 remove
"$INSTALL_UDEV_RULE_DIR/60-zvol.rules"
174 remove
"$INSTALL_UDEV_RULE_DIR/69-vdev.rules"
175 remove
"$INSTALL_UDEV_RULE_DIR/90-zfs.rules"
176 remove
"$INSTALL_SYSCONF_DIR/zfs/zpool.d"