@@ -20,4 +20,93 @@ set -a
20
20
# shellcheck source=./rabbitmq-env
21
21
. " ${0%/* } " /rabbitmq-env
22
22
23
- run_escript " ${ESCRIPT_DIR:? must be defined} " /rabbitmqctl ' noinput' " $@ "
23
+ echo " ARGLEN: $# "
24
+ echo " ARG0: $0 "
25
+ echo " ARG1: $1 "
26
+ echo " ARG2: $2 "
27
+ echo " ARG3: $3 "
28
+ echo " ARG4: $4 "
29
+ echo " ARG5: $5 "
30
+
31
+ set -x
32
+
33
+ _tmp_help_requested=' false'
34
+
35
+ for _tmp_argument in " $@ "
36
+ do
37
+ if [ " $_tmp_argument " = ' --help' ]
38
+ then
39
+ _tmp_help_requested=' true'
40
+ break
41
+ fi
42
+ done
43
+
44
+ if [ " $1 " = ' help' ] || [ " $_tmp_help_requested " = ' true' ]
45
+ then
46
+ # In this case, we do not require input and can exit early since
47
+ # help was requested
48
+ #
49
+ run_escript " ${ESCRIPT_DIR:? must be defined} " /rabbitmqctl ' noinput' " $@ "
50
+ exit " $? "
51
+ fi
52
+
53
+ unset _tmp_help_requested
54
+
55
+ maybe_noinput=' noinput'
56
+
57
+ case " $1 " in
58
+ add_user)
59
+ if [ " $# " -eq 2 ]
60
+ then
61
+ # In this case, input is required to provide the password:
62
+ #
63
+ # rabbitmqctl add_user bob
64
+ #
65
+ maybe_noinput=' input'
66
+ elif [ " $# " -eq 3 ]
67
+ then
68
+ # In these cases, input depends on the arguments provided:
69
+ #
70
+ # rabbitmqctl add_user bob --pre-hashed-password (input needed)
71
+ # rabbitmqctl add_user bob bobpassword (NO input needed)
72
+ # rabbitmqctl add_user --pre-hashed-password bob (input needed)
73
+ #
74
+ for _tmp_argument in " $@ "
75
+ do
76
+ if [ " $_tmp_argument " = ' --pre-hashed-password' ]
77
+ then
78
+ maybe_noinput=' input'
79
+ break
80
+ fi
81
+ done
82
+ elif [ " $# " -gt 3 ]
83
+ then
84
+ # If there are 4 or more arguments, no input is needed:
85
+ #
86
+ # rabbitmqctl add_user bob --pre-hashed-password HASHVALUE
87
+ # rabbitmqctl add_user bob bobpassword IGNORED
88
+ # rabbitmqctl add_user --pre-hashed-password bob HASHVALUE
89
+ #
90
+ maybe_noinput=' noinput'
91
+ fi
92
+ ;;
93
+ change_password)
94
+ maybe_noinput=' input'
95
+ if [ " $# " -gt 2 ]
96
+ then
97
+ # If there are 3 or more arguments, no input is needed:
98
+ #
99
+ # rabbitmqctl change_password sue foobar
100
+ # rabbitmqctl change_password sue newpassword IGNORED
101
+ #
102
+ maybe_noinput=' noinput'
103
+ fi
104
+ ;;
105
+ * )
106
+ maybe_noinput=' noinput'
107
+ ;;
108
+ esac
109
+
110
+ unset _tmp_argument
111
+
112
+ run_escript " ${ESCRIPT_DIR:? must be defined} " /rabbitmqctl " $maybe_noinput " " $@ "
0 commit comments