Statistiques
| Révision :

root / bin / del-filesystem @ 1

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

1
#!/bin/bash
2

    
3
function usage {
4
  echo "Description : destroy a ZFS FileSystem." 1>&2
5
  echo "Usage :" 1>&2
6
  echo "$0 [OPTIONS]" 1>&2
7
  echo " -h display this message" 1>&2
8
  echo " -i interactive mode" 1>&2
9
  echo " -n ZFS Volume Name" 1>&2
10

    
11
}
12

    
13
function nointeractive {
14

    
15
MOUNTED=$(zfs get -H mounted $FS_NAME|awk '{ print $3}')
16

    
17
if [ "$MOUNTED" == "no" ]
18
then
19
   zfs destroy $FS_NAME
20
   
21
else
22
   echo "ZFS FileSystem $FS_NAME mounted" 1>&2
23
   exit 1;
24
fi 
25
}
26

    
27

    
28
function interactive {
29

    
30
zfs list
31
echo "*** Enter the ZFS FileSystem Name : ***" 
32
while read inputline
33
do
34
   NAME_VOL=$inputline 
35
   echo "*** Do you want really remove the ZFS FileSystem : $inputline ? (y/n) ***"
36
   while read inputConfirm
37
   do
38
      if [ "$inputConfirm" = "y" ]||[ "$inputConfirm" = "n" ]
39
      then
40
         break
41
      fi
42
      echo "*** Do you want really remove the ZFS FileSystem : $inputline ? (y/n) ***"
43
   done
44

    
45
   
46
   if [ "$inputConfirm" = "y" ]
47
   then
48
      break
49
   fi
50
   if [ "$inputConfirm" != "y" ]
51
   then
52
      echo "*** Enter the ZFS Volume FileSystem : ***" 
53
   fi
54
done
55
nointeractive
56
}
57

    
58
while getopts "in:h" OPTION
59
do
60
     case $OPTION in
61
         h)
62
             usage
63
             exit 1
64
             ;;
65
         i)
66
             interactive
67
             ;;
68
         n)
69
             FS_NAME=$OPTARG
70
             ;;
71
         *)
72
             usage
73
             exit 1
74
             ;;
75
     esac
76
done
77

    
78
if [[ -z $FS_NAME ]]
79
then
80
     usage
81
     exit 1
82
fi
83
nointeractive
84

    
85