Statistiques
| Révision :

root / bin / del-volume @ 39

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

1
#!/bin/bash
2
# $Id: del-volume 39 2013-10-08 12:46:21Z ltaulell $
3

    
4
GETINFO_ISCSI="/sbin/get-conf-iscsi-volume"
5
DEL_ISCSI="/sbin/del-iscsi-volume"
6

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

    
14
}
15

    
16
function nointeractive {
17

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

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

    
35

    
36
function interactive {
37

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

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

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

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

    
93

    
94

    
95