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 "pythonsitedir: $INSTALL_PYTHON_DIR"
114 echo "dryrun: $DRYRUN"
122 if [ -h "$dst" ]; then
123 echo "Symlink exists: $dst"
124 elif [ -e "$dst" ]; then
125 echo "File exists: $dst"
126 elif [ ! -e "$src" ]; then
127 echo "Source missing: $src"
129 msg
"ln -s $src $dst"
131 if [ "$DRYRUN" = "no" ]; then
132 DIR
=$
(dirname "$dst")
133 mkdir
-p "$DIR" >/dev
/null
2>&1
142 if [ -h "$dst" ]; then
145 DIR
=$
(dirname "$dst")
146 rmdir "$DIR" >/dev
/null
2>&1
147 elif [ -e "$dst" ]; then
148 echo "Expected symlink: $dst"
152 if [ "${INSTALL}" = "yes" ]; then
153 install "$CMD_DIR/mount_zfs/mount.zfs" \
154 "$INSTALL_MOUNT_HELPER_DIR/mount.zfs"
155 install "$CMD_DIR/fsck_zfs/fsck.zfs" \
156 "$INSTALL_MOUNT_HELPER_DIR/fsck.zfs"
157 install "$CMD_DIR/zvol_id/zvol_id" \
158 "$INSTALL_UDEV_DIR/zvol_id"
159 install "$CMD_DIR/vdev_id/vdev_id" \
160 "$INSTALL_UDEV_DIR/vdev_id"
161 install "$UDEV_RULE_DIR/60-zvol.rules" \
162 "$INSTALL_UDEV_RULE_DIR/60-zvol.rules"
163 install "$UDEV_RULE_DIR/69-vdev.rules" \
164 "$INSTALL_UDEV_RULE_DIR/69-vdev.rules"
165 install "$UDEV_RULE_DIR/90-zfs.rules" \
166 "$INSTALL_UDEV_RULE_DIR/90-zfs.rules"
167 install "$CMD_DIR/zpool/zpool.d" \
168 "$INSTALL_SYSCONF_DIR/zfs/zpool.d"
169 install "$SYSCONF_DIR/zfs/draid.d" \
170 "$INSTALL_SYSCONF_DIR/zfs/draid.d"
171 install "$CONTRIB_DIR/pyzfs/libzfs_core" \
172 "$INSTALL_PYTHON_DIR/libzfs_core"
173 # Ideally we would install these in the configured ${libdir}, which is
174 # by default "/usr/local/lib and unfortunately not included in the
175 # dynamic linker search path.
176 install "$(find "$LIB_DIR/libzfs_core
" -type f -name 'libzfs_core.so*')" \
177 "/lib/libzfs_core.so"
178 install "$(find "$LIB_DIR/libnvpair
" -type f -name 'libnvpair.so*')" \
182 remove
"$INSTALL_MOUNT_HELPER_DIR/mount.zfs"
183 remove
"$INSTALL_MOUNT_HELPER_DIR/fsck.zfs"
184 remove
"$INSTALL_UDEV_DIR/zvol_id"
185 remove
"$INSTALL_UDEV_DIR/vdev_id"
186 remove
"$INSTALL_UDEV_RULE_DIR/60-zvol.rules"
187 remove
"$INSTALL_UDEV_RULE_DIR/69-vdev.rules"
188 remove
"$INSTALL_UDEV_RULE_DIR/90-zfs.rules"
189 remove
"$INSTALL_SYSCONF_DIR/zfs/zpool.d"
190 remove
"$INSTALL_SYSCONF_DIR/zfs/draid.d"
191 remove
"$INSTALL_PYTHON_DIR/libzfs_core"
192 remove
"/lib/libzfs_core.so"
193 remove
"/lib/libnvpair.so"