root / bin / del-volume @ 4
Historique | Voir | Annoter | Télécharger (1,49 ko)
1 |
#!/bin/bash |
---|---|
2 |
|
3 |
GETINFO_ISCSI="/sbin/get-conf-iscsi-volume" |
4 |
DEL_ISCSI="/sbin/del-iscsi-volume" |
5 |
|
6 |
function usage { |
7 |
echo "Usage :" 1>&2 |
8 |
echo "$0 [OPTIONS]" 1>&2 |
9 |
echo " -h display this message" 1>&2 |
10 |
echo " -i interactive mode" 1>&2 |
11 |
echo " -n ZFS Volume Name" 1>&2 |
12 |
|
13 |
} |
14 |
|
15 |
function nointeractive { |
16 |
|
17 |
TID=$($GETINFO_ISCSI $NAME_VOL|grep "^tid "|cut -d " " -f2) |
18 |
|
19 |
if [ "$TID" == "" ] |
20 |
then |
21 |
zfs destroy -r $NAME_VOL |
22 |
|
23 |
else |
24 |
$DEL_ISCSI -T $TID |
25 |
if [ $? -eq 0 ] |
26 |
then |
27 |
zfs destroy -r $NAME_VOL |
28 |
else |
29 |
exit 1; |
30 |
fi |
31 |
fi |
32 |
} |
33 |
|
34 |
|
35 |
function interactive { |
36 |
|
37 |
zfs list |
38 |
echo "*** Enter the ZFS Volume Name : ***" |
39 |
while read inputline |
40 |
do |
41 |
NAME_VOL=$inputline |
42 |
echo "*** Do you want really remove the ZFS Volume : $inputline ? (y/n) ***" |
43 |
while read inputConfirm |
44 |
do |
45 |
if [ "$inputConfirm" = "y" ]||[ "$inputConfirm" = "n" ] |
46 |
then |
47 |
break |
48 |
fi |
49 |
echo "*** Do you want really remove the ZFS Volume : $inputline ? (y/n) ***" |
50 |
done |
51 |
|
52 |
|
53 |
if [ "$inputConfirm" = "y" ] |
54 |
then |
55 |
break |
56 |
fi |
57 |
if [ "$inputConfirm" != "y" ] |
58 |
then |
59 |
echo "*** Enter the ZFS Volume Name : ***" |
60 |
fi |
61 |
done |
62 |
nointeractive |
63 |
} |
64 |
|
65 |
while getopts "in:h" OPTION |
66 |
do |
67 |
case $OPTION in |
68 |
h) |
69 |
usage |
70 |
exit 1 |
71 |
;; |
72 |
i) |
73 |
interactive |
74 |
;; |
75 |
n) |
76 |
NAME_VOL=$OPTARG |
77 |
;; |
78 |
*) |
79 |
usage |
80 |
exit 1 |
81 |
;; |
82 |
esac |
83 |
done |
84 |
|
85 |
if [[ -z $NAME_VOL ]] |
86 |
then |
87 |
usage |
88 |
exit 1 |
89 |
fi |
90 |
nointeractive |
91 |
|
92 |
|
93 |
|
94 |
|