Переглянути джерело

mass_deploy script enhancement

Add the possibility to give a fixed name to instances created by mass_deploy
Yann Weber 8 роки тому
джерело
коміт
d57c677cc6
1 змінених файлів з 14 додано та 7 видалено
  1. 14
    7
      progs/mass_deploy.sh

+ 14
- 7
progs/mass_deploy.sh Переглянути файл

@@ -13,7 +13,7 @@ mongodb_connfail() {
13 13
 }
14 14
 
15 15
 usage() {
16
-	echo -e "Usage : $0 (N|purgedb|-h|--help)
16
+	echo -e "Usage : $0 (N|purgedb|-h|--help) [FIXED_NAME]
17 17
 \tWith :
18 18
 \t\t- N the number of instances to create
19 19
 \t\t- purgedb is to remove all created mongodb db\n"
@@ -30,6 +30,8 @@ slim_fails() {
30 30
 	exit 1
31 31
 }
32 32
 
33
+fixed_name="$2"
34
+
33 35
 test -f $conffile || badconf
34 36
 #Load conffile
35 37
 . $conffile
@@ -37,14 +39,19 @@ test -z "$MONGODB_ADMIN_USER" && badconf
37 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 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 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 55
 fi
49 56
 
50 57
 #Check for the presence of mongo and its conf

Loading…
Відмінити
Зберегти