@@ -85,7 +85,7 @@ check_pids(){
8585wait_for_pids (){
8686 # We are sleeping a bit here mostly because sidekiq is slow at writing it's pid
8787 i=0;
88- while [ ! -f $web_server_pid_path -o ! -f $sidekiq_pid_path -o [ " $mail_room_enabled " = true && ! -f $mail_room_pid_path ] ] ; do
88+ while [ ! -f $web_server_pid_path ] || [ ! -f $sidekiq_pid_path ] || { [ " $mail_room_enabled " = true ] && [ ! -f $mail_room_pid_path ] } ; do
8989 sleep 0.1;
9090 i=$(( i+ 1 ))
9191 if [ $(( i% 10 )) = 0 ]; then
@@ -120,13 +120,15 @@ check_status(){
120120 else
121121 sidekiq_status=" -1"
122122 fi
123- if [ " $mail_room_enabled " = true && $mpid -ne 0 ]; then
124- kill -0 " $mpid " 2> /dev/null
125- mail_room_status=" $? "
126- else
127- mail_room_status=" -1"
123+ if [ " $mail_room_enabled " = true ]; then
124+ if [ $mpid -ne 0 ]; then
125+ kill -0 " $mpid " 2> /dev/null
126+ mail_room_status=" $? "
127+ else
128+ mail_room_status=" -1"
129+ fi
128130 fi
129- if [ $web_status = 0 -a $sidekiq_status = 0 -a [ " $mail_room_enabled " != true || $mail_room_status = 0 ] ] ; then
131+ if [ $web_status = 0 ] && [ $sidekiq_status = 0 ] && { [ " $mail_room_enabled " != true ] || [ $mail_room_status = 0 ] } ; then
130132 gitlab_status=0
131133 else
132134 # http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
@@ -140,21 +142,21 @@ check_stale_pids(){
140142 check_status
141143 # If there is a pid it is something else than 0, the service is running if
142144 # *_status is == 0.
143- if [ " $wpid " != " 0" -a " $web_status " != " 0" ]; then
145+ if [ " $wpid " != " 0" ] && [ " $web_status " != " 0" ]; then
144146 echo " Removing stale Unicorn web server pid. This is most likely caused by the web server crashing the last time it ran."
145147 if ! rm " $web_server_pid_path " ; then
146148 echo " Unable to remove stale pid, exiting."
147149 exit 1
148150 fi
149151 fi
150- if [ " $spid " != " 0" -a " $sidekiq_status " != " 0" ]; then
152+ if [ " $spid " != " 0" ] && [ " $sidekiq_status " != " 0" ]; then
151153 echo " Removing stale Sidekiq job dispatcher pid. This is most likely caused by Sidekiq crashing the last time it ran."
152154 if ! rm " $sidekiq_pid_path " ; then
153155 echo " Unable to remove stale pid, exiting"
154156 exit 1
155157 fi
156158 fi
157- if [ " $mail_room_enabled " = true && " $mpid " != " 0" -a " $mail_room_status " != " 0" ]; then
159+ if [ " $mail_room_enabled " = true ] && [ " $mpid " != " 0" ] && [ " $mail_room_status " != " 0" ]; then
158160 echo " Removing stale MailRoom job dispatcher pid. This is most likely caused by MailRoom crashing the last time it ran."
159161 if ! rm " $mail_room_pid_path " ; then
160162 echo " Unable to remove stale pid, exiting"
@@ -166,7 +168,7 @@ check_stale_pids(){
166168# # If no parts of the service is running, bail out.
167169exit_if_not_running (){
168170 check_stale_pids
169- if [ " $web_status " != " 0" -a " $sidekiq_status " != " 0" -a [ " $mail_room_enabled " = true && " $mail_room_status " != " 0" ] ] ; then
171+ if [ " $web_status " != " 0" ] && [ " $sidekiq_status " != " 0" ] && { [ " $mail_room_enabled " ! = true ] || [ " $mail_room_status " != " 0" ] } ; then
170172 echo " GitLab is not running."
171173 exit
172174 fi
@@ -182,7 +184,7 @@ start_gitlab() {
182184 if [ " $sidekiq_status " != " 0" ]; then
183185 echo -n " Starting GitLab Sidekiq"
184186 fi
185- if [ " $mail_room_enabled " = true && " $mail_room_status " != " 0" ]; then
187+ if [ " $mail_room_enabled " = true ] && [ " $mail_room_status " != " 0" ]; then
186188 echo -n " Starting GitLab MailRoom"
187189 fi
188190
@@ -206,7 +208,7 @@ start_gitlab() {
206208 if [ " $mail_room_enabled " = true ]; then
207209 # If MailRoom is already running, don't start it again.
208210 if [ " $mail_room_status " = " 0" ]; then
209- echo " The MailRoom email processor is already running with pid $spid , not restarting"
211+ echo " The MailRoom email processor is already running with pid $mpid , not restarting"
210212 else
211213 RAILS_ENV=$RAILS_ENV bin/mail_room start &
212214 fi
@@ -228,7 +230,7 @@ stop_gitlab() {
228230 if [ " $sidekiq_status " = " 0" ]; then
229231 echo -n " Shutting down GitLab Sidekiq"
230232 fi
231- if [ " $mail_room_enabled " = true && " $mail_room_status " = " 0" ]; then
233+ if [ " $mail_room_enabled " = true ] && [ " $mail_room_status " = " 0" ]; then
232234 echo -n " Shutting down GitLab MailRoom"
233235 fi
234236
@@ -241,16 +243,16 @@ stop_gitlab() {
241243 RAILS_ENV=$RAILS_ENV bin/background_jobs stop
242244 fi
243245 # And do the same thing for the MailRoom.
244- if [ " $mail_room_enabled " = true && " $mail_room_status " = " 0" ]; then
246+ if [ " $mail_room_enabled " = true ] && [ " $mail_room_status " = " 0" ]; then
245247 RAILS_ENV=$RAILS_ENV bin/mail_room stop
246248 fi
247249
248250 # If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script.
249- while [ " $web_status " = " 0" -o " $sidekiq_status " = " 0" -o [ " $mail_room_enabled " = true && " $mail_room_status " = " 0" ] ] ; do
251+ while [ " $web_status " = " 0" ] || [ " $sidekiq_status " = " 0" ] || { [ " $mail_room_enabled " = true ] && [ " $mail_room_status " = " 0" ] } ; do
250252 sleep 1
251253 check_status
252254 printf " ."
253- if [ " $web_status " != " 0" -a " $sidekiq_status " != " 0" -a [ " $mail_room_enabled " != true || " $mail_room_status " != " 0" ] ] ; then
255+ if [ " $web_status " != " 0" ] && [ " $sidekiq_status " != " 0" ] && { [ " $mail_room_enabled " != true ] || [ " $mail_room_status " != " 0" ] } ; then
254256 printf " \n"
255257 break
256258 fi
@@ -270,7 +272,7 @@ stop_gitlab() {
270272# # Prints the status of GitLab and it's components.
271273print_status () {
272274 check_status
273- if [ " $web_status " != " 0" -a " $sidekiq_status " != " 0" -a [ " $mail_room_enabled " != true || " $mail_room_status " != " 0" ] ] ; then
275+ if [ " $web_status " != " 0" ] && [ " $sidekiq_status " != " 0" ] && { [ " $mail_room_enabled " != true ] || [ " $mail_room_status " != " 0" ] } ; then
274276 echo " GitLab is not running."
275277 return
276278 fi
@@ -291,7 +293,7 @@ print_status() {
291293 printf " The GitLab MailRoom email processor is \033[31mnot running\033[0m.\n"
292294 fi
293295 end
294- if [ " $web_status " = " 0" -a " $sidekiq_status " = " 0" -a [ " $mail_room_enabled " != true || " $mail_room_status " = " 0" ] ] ; then
296+ if [ " $web_status " = " 0" ] && [ " $sidekiq_status " = " 0" ] && { [ " $mail_room_enabled " != true ] || [ " $mail_room_status " = " 0" ] } ; then
295297 printf " GitLab and all its components are \033[32mup and running\033[0m.\n"
296298 fi
297299}
@@ -322,7 +324,7 @@ reload_gitlab(){
322324# # Restarts Sidekiq and Unicorn.
323325restart_gitlab (){
324326 check_status
325- if [ " $web_status " = " 0" -o " $sidekiq_status " = " 0" -o [ " $mail_room_enabled " = true && " $mail_room_status " = " 0" ] ] ; then
327+ if [ " $web_status " = " 0" ] || [ " $sidekiq_status " = " 0" ] || { [ " $mail_room_enabled " = true ] && [ " $mail_room_status " = " 0" ] } ; then
326328 stop_gitlab
327329 fi
328330 start_gitlab
0 commit comments