-
Notifications
You must be signed in to change notification settings - Fork 1
/
zsr
executable file
·38 lines (31 loc) · 851 Bytes
/
zsr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
interactive=0
if /usr/bin/tty > /dev/null;
then
interactive=1
fi
# https://github.com/maxtsepkov/bash_colors/blob/master/bash_colors.sh
uncolorize () { sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g"; }
if [ $interactive -eq 1 ]
then say() { echo -ne $1;echo -e $nocolor; }
# Colors, yo!
green="\e[1;32m"
red="\e[1;31m"
blue="\e[1;34m"
purple="\e[1;35m"
cyan="\e[1;36m"
nocolor="\e[0m"
else
# do nothing
say() { true; }
fi
export PATH="/root/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
dataset_list=`mktemp /tmp/datasets.XXXXXX`
zfs list -t snap -r -H tank -o name -s name |grep @ > ${dataset_list}
for snap in "$@";do
for dataset in `grep @.*${snap}.*$ ${dataset_list}`;do
say "$green ${dataset}"
zfs destroy ${dataset}
done
done
rm ${dataset_list}