FIX: discourse-doctor plugin check too loose (#478)
[discourse_docker.git] / discourse-doctor
index 0f4c1f0dc7de26122886642965ba8d77b3d0dea4..4d669000223ba2a2cec412b1a01bf6d3058aa745 100755 (executable)
@@ -185,7 +185,7 @@ get_discourse_config() {
 
 check_plugins() {
   log -e "\n\n==================== PLUGINS ===================="
-  log -e "$(grep git containers/$app_name.yml)"
+  log -e "$(grep 'git clone' containers/$app_name.yml)"
   grep git containers/$app_name.yml > /tmp/$PPID.grep
 
   if grep -cv "github.com/discourse" /tmp/$PPID.grep > /dev/null
@@ -270,19 +270,29 @@ check_docker() {
     # too hard to pass STDERR of ./launcher to log()
     ./launcher rebuild $app_name 2>&1 | tee -a $LOG_FILE
     log "==================== END REBUILD LOG ===================="
-    docker ps| tail -n +2 > /tmp/$UUID-docker.txt
+    docker ps | tail -n +2 > /tmp/$UUID-docker.txt
     if grep $app_name /tmp/$UUID-docker.txt
     then
       log -e "\nDiscourse container $app_name is now running."
       log ". . . waiting 30 seconds for container to crank up. . . "
       sleep 30
     else
-      log "$app_name still not running!"
+      log "Failed to rebuild $app_name."
       # check_ip_match checks if curl to $DISCOURSE_HOSTNAME gets to this server
       # It works only if ports 80 and 443 are free
       check_ip_match $DISCOURSE_HOSTNAME
       log "You should probably remove any non-standard plugins and rebuild."
       NO_CONTAINER='y'
+      log "Attempting to restart existing container. . . "
+      ./launcher start $app_name 2>&1 | tee -a $LOG_FILE
+      docker ps | tail -n +2 > /tmp/$UUID-docker.txt
+      if grep $app_name /tmp/$UUID-docker.txt
+      then
+        log "Restarted the container."
+        NO_CONTAINER='n'
+      else
+        log "Failed to restart the container."
+      fi
     fi
   fi
 }
@@ -306,10 +316,16 @@ print_done() {
 
   if [ $app_name == 'app' ] && [ "$NO_CONTAINER" != 'y' ]
   then
-    cp $LOG_FILE shared/standalone/log/var-log/$DOCTOR_FILE
-    sudo docker exec -w /var/www/discourse -i $app_name cp /var/log/$DOCTOR_FILE  public
-    log "The output of this program may be available at http://$DISCOURSE_HOSTNAME/$DOCTOR_FILE"
-    log "You should inspect that file carefully before sharing the URL."
+    read -p "Would you like to serve a publicly available version of this file? (Y/n)" serve
+    if [ $serve == 'Y' ]
+    then
+        cp $LOG_FILE shared/standalone/log/var-log/$DOCTOR_FILE
+        sudo docker exec -w /var/www/discourse -i $app_name cp /var/log/$DOCTOR_FILE  public
+        log "The output of this program may be available at http://$DISCOURSE_HOSTNAME/$DOCTOR_FILE"
+        log "You should inspect that file carefully before sharing the URL."
+    else
+        log "Publicly available log not generated."
+    fi
   fi
   # The following is not in the web log file since it was copied above, which seems corect
   log