aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Christian Pohle2021-03-24 18:54:21 +0100
committerMax Christian Pohle2021-03-24 18:54:21 +0100
commit9c4589ac2fd8c9db921c51e921a9fbfc5c3efa4f (patch)
treeab70844a272e314f9b7125a37197e60096069b9a
parentf1ab24e775479eabbad928d889f7c0cfe792d7c5 (diff)
downloadzfs-bash-tools-9c4589ac2fd8c9db921c51e921a9fbfc5c3efa4f.tar.bz2
zfs-bash-tools-9c4589ac2fd8c9db921c51e921a9fbfc5c3efa4f.zip
Made squash script FreeBSD compatible
-rwxr-xr-xzfs-squash-datasets.sh9
1 files changed, 5 insertions, 4 deletions
diff --git a/zfs-squash-datasets.sh b/zfs-squash-datasets.sh
index c61af40..d668c80 100755
--- a/zfs-squash-datasets.sh
+++ b/zfs-squash-datasets.sh
@@ -1,7 +1,8 @@
1#!/usr/local/bin/bash
1DATASET_ROOT=$1 2DATASET_ROOT=$1
2DATASET_TARGET=$2 3DATASET_TARGET=$2
3 4
4MOUNTPOINT_TARGET=$(zfs get -H mountpoint -o value $DATASET_TARGET) 5MOUNTPOINT_TARGET=$(zfs get -o value -H mountpoint $DATASET_TARGET)
5 6
6if ! test -d "$MOUNTPOINT_TARGET"; then 7if ! test -d "$MOUNTPOINT_TARGET"; then
7 echo "Please run this program with a source and a target dataset name as arguments" 8 echo "Please run this program with a source and a target dataset name as arguments"
@@ -13,8 +14,8 @@ fi
13trap exit INT 14trap exit INT
14 15
15# recursively contains all snapshot names (the part after the @) from root on, sorted and only once 16# recursively contains all snapshot names (the part after the @) from root on, sorted and only once
16SNAPSHOTS=$(zfs list -H -r $DATASET_ROOT -oname -tsnap | cut -d@ -f2 | sort | uniq) 17SNAPSHOTS=$(zfs list -H -oname -tsnap -r $DATASET_ROOT| cut -d@ -f2 | sort | uniq)
17DATASETS=$(zfs list -H -r $DATASET_ROOT -oname -t filesystem) 18DATASETS=$(zfs list -H -oname -t filesystem -r $DATASET_ROOT)
18 19
19echo "We are going to flatten the hierachy of this dataset:" 20echo "We are going to flatten the hierachy of this dataset:"
20printf " %s\n" $DATASETS 21printf " %s\n" $DATASETS
@@ -35,7 +36,7 @@ for SNAPSHOT in $SNAPSHOTS; do
35 36
36 for DATASET in $DATASETS; do 37 for DATASET in $DATASETS; do
37 38
38 MOUNTPOINT=$(zfs get -H mountpoint -o value $DATASET) 39 MOUNTPOINT=$(zfs get -H -o value mountpoint $DATASET)
39 40
40 if [[ $MOUNTPOINT == "legacy" ]]; then 41 if [[ $MOUNTPOINT == "legacy" ]]; then
41 MOUNTPOINT=$(findmnt -n -o target $DATASET) 42 MOUNTPOINT=$(findmnt -n -o target $DATASET)
..