Statistiques
| Révision :

root / bin / del-volume @ 40

Historique | Voir | Annoter | Télécharger (1,52 ko)

1
#!/bin/bash
2
# $Id: del-volume 40 2013-10-08 14:37:55Z ltaulell $
3

    
4
# TODO: fix typos
5

    
6
GETINFO_ISCSI="/sbin/get-conf-iscsi-volume"
7
DEL_ISCSI="/sbin/del-iscsi-volume"
8

    
9
function usage {
10
  echo "Usage :" 1>&2
11
  echo "$0 [OPTIONS]" 1>&2
12
  echo " -h display this message" 1>&2
13
  echo " -i interactive mode" 1>&2
14
  echo " -n ZFS Volume Name" 1>&2
15

    
16
}
17

    
18
function nointeractive {
19

    
20
TID=$($GETINFO_ISCSI $NAME_VOL|grep "^tid "|cut -d " " -f2)
21

    
22
if [ "$TID" == "" ]
23
then
24
   zfs destroy -r $NAME_VOL
25
   
26
else
27
   $DEL_ISCSI -T $TID
28
   if [ $? -eq 0 ]
29
   then
30
     zfs destroy -r $NAME_VOL
31
   else
32
      exit 1;
33
   fi
34
fi 
35
}
36

    
37

    
38
function interactive {
39

    
40
zfs list
41
echo "*** Enter the ZFS Volume Name : ***" 
42
while read inputline
43
do
44
   NAME_VOL=$inputline 
45
   echo "*** Do you want really remove the ZFS Volume : $inputline ? (y/n) ***"
46
   while read inputConfirm
47
   do
48
      if [ "$inputConfirm" = "y" ]||[ "$inputConfirm" = "n" ]
49
      then
50
         break
51
      fi
52
      echo "*** Do you want really remove the ZFS Volume : $inputline ? (y/n) ***"
53
   done
54

    
55
   
56
   if [ "$inputConfirm" = "y" ]
57
   then
58
      break
59
   fi
60
   if [ "$inputConfirm" != "y" ]
61
   then
62
      echo "*** Enter the ZFS Volume Name : ***" 
63
   fi
64
done
65
nointeractive
66
}
67

    
68
while getopts "in:h" OPTION
69
do
70
     case $OPTION in
71
         h)
72
             usage
73
             exit 1
74
             ;;
75
         i)
76
             interactive
77
             ;;
78
         n)
79
             NAME_VOL=$OPTARG
80
             ;;
81
         *)
82
             usage
83
             exit 1
84
             ;;
85
     esac
86
done
87

    
88
if [[ -z $NAME_VOL ]]
89
then
90
     usage
91
     exit 1
92
fi
93
nointeractive
94

    
95

    
96

    
97