Browse Source

mass_deploy script enhancement

Add the possibility to give a fixed name to instances created by mass_deploy
Yann Weber 8 years ago
parent
commit
d57c677cc6
1 changed files with 14 additions and 7 deletions
  1. 14
    7
      progs/mass_deploy.sh

+ 14
- 7
progs/mass_deploy.sh View File

13
 }
13
 }
14
 
14
 
15
 usage() {
15
 usage() {
16
-	echo -e "Usage : $0 (N|purgedb|-h|--help)
16
+	echo -e "Usage : $0 (N|purgedb|-h|--help) [FIXED_NAME]
17
 \tWith :
17
 \tWith :
18
 \t\t- N the number of instances to create
18
 \t\t- N the number of instances to create
19
 \t\t- purgedb is to remove all created mongodb db\n"
19
 \t\t- purgedb is to remove all created mongodb db\n"
30
 	exit 1
30
 	exit 1
31
 }
31
 }
32
 
32
 
33
+fixed_name="$2"
34
+
33
 test -f $conffile || badconf
35
 test -f $conffile || badconf
34
 #Load conffile
36
 #Load conffile
35
 . $conffile
37
 . $conffile
37
 test -z "$MONGODB_ADMIN_PASSWORD" && badconf
39
 test -z "$MONGODB_ADMIN_PASSWORD" && badconf
38
 
40
 
39
 
41
 
40
-#Check for the presence of /usr/share/dict/words to generate random names
41
-if [ -f '/usr/share/dict/words' ]
42
+if [ -z "$fixed_name" ]
42
 then
43
 then
43
-	echo "/usr/share/dict/words found. Using this file as source for random names"
44
-	random_name=$(sed -nE 's/^([A-Za-z0-9]+)$/\1/p' /usr/share/dict/words |shuf|head -n1)
44
+	#Check for the presence of /usr/share/dict/words to generate random names
45
+	if [ -f '/usr/share/dict/words' ]
46
+	then
47
+		echo "/usr/share/dict/words found. Using this file as source for random names"
48
+		random_name=$(sed -nE 's/^([A-Za-z0-9]+)$/\1/p' /usr/share/dict/words |shuf|head -n1)
49
+	else
50
+		echo -e "\n\n\tWarning... /usr/share/dict/words not found using \$RANDOM for random names generation"
51
+		random_name=$RANDOM
52
+	fi
45
 else
53
 else
46
-	echo -e "\n\n\tWarning... /usr/share/dict/words not found using \$RANDOM for random names generation"
47
-	random_name=$RANDOM
54
+	random_name="$fixed_name"
48
 fi
55
 fi
49
 
56
 
50
 #Check for the presence of mongo and its conf
57
 #Check for the presence of mongo and its conf

Loading…
Cancel
Save