[ARVADOS] created: 5926f360ab027ed94550b56d3086d44c1e9377da

Git user git at public.curoverse.com
Fri Jan 6 11:42:11 EST 2017


        at  5926f360ab027ed94550b56d3086d44c1e9377da (commit)


commit 5926f360ab027ed94550b56d3086d44c1e9377da
Author: Ward Vandewege <ward at curoverse.com>
Date:   Fri Jan 6 11:41:00 2017 -0500

    In our rails postinstall package script, when looking for the
    'database:' line, make sure to match every line of the rake
    db:migrate:status output, not just the first one.
    
    refs #10838

diff --git a/build/rails-package-scripts/postinst.sh b/build/rails-package-scripts/postinst.sh
index 17454ef..178f90d 100644
--- a/build/rails-package-scripts/postinst.sh
+++ b/build/rails-package-scripts/postinst.sh
@@ -121,24 +121,36 @@ setup_conffile() {
 }
 
 prepare_database() {
-  DB_MIGRATE_STATUS=`$COMMAND_PREFIX bundle exec rake db:migrate:status 2>&1 || true`
-  if echo $DB_MIGRATE_STATUS | grep -qF 'Schema migrations table does not exist yet.'; then
-      # The database exists, but the migrations table doesn't.
-      run_and_report "Setting up database" $COMMAND_PREFIX bundle exec \
-                     rake "$RAILSPKG_DATABASE_LOAD_TASK" db:seed
-  elif echo $DB_MIGRATE_STATUS | grep -q '^database: '; then
-      run_and_report "Running db:migrate" \
-                     $COMMAND_PREFIX bundle exec rake db:migrate
-  elif echo $DB_MIGRATE_STATUS | grep -q 'database .* does not exist'; then
-      if ! run_and_report "Running db:setup" \
-           $COMMAND_PREFIX bundle exec rake db:setup 2>/dev/null; then
-          echo "Warning: unable to set up database." >&2
-          DATABASE_READY=0
-      fi
-  else
+
+  MIGRATE_MATCH=0
+  while read -r line ; do
+    if echo $line | grep -qF 'Schema migrations table does not exist yet.'; then
+        MIGRATE_MATCH=1
+        # The database exists, but the migrations table doesn't.
+        run_and_report "Setting up database" $COMMAND_PREFIX bundle exec \
+                       rake "$RAILSPKG_DATABASE_LOAD_TASK" db:seed
+        break
+    elif echo $line | grep -q '^database: '; then
+        MIGRATE_MATCH=1
+        run_and_report "Running db:migrate" \
+                       $COMMAND_PREFIX bundle exec rake db:migrate
+        break
+    elif echo $line | grep -q 'database .* does not exist'; then
+        MIGRATE_MATCH=1
+        if ! run_and_report "Running db:setup" \
+             $COMMAND_PREFIX bundle exec rake db:setup 2>/dev/null; then
+            echo "Warning: unable to set up database." >&2
+            DATABASE_READY=0
+        fi
+        break
+    fi
+  done < <($COMMAND_PREFIX bundle exec rake db:migrate:status 2>&1)
+
+  if [[ "$MIGRATE_MATCH" == "0" ]]; then
     echo "Warning: Database is not ready to set up. Skipping database setup." >&2
     DATABASE_READY=0
   fi
+
 }
 
 configure_version() {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list