[ARVADOS-DEV] updated: 9ac3e54bc97741867159976495d723a06f2cf28d

git at public.curoverse.com git at public.curoverse.com
Mon Sep 28 17:43:15 EDT 2015


Summary of changes:
 .../arvados-sso-server.postinst                    | 161 ++++++++++++++++-----
 .../arvados-sso-server.postrm                      |  10 +-
 .../arvados-sso-server.prerm                       |   6 +-
 jenkins/run-build-packages-sso.sh                  |  15 ++
 jenkins/run-library.sh                             |   9 ++
 jenkins/run-test-packages-sso.sh                   |  32 ++--
 6 files changed, 182 insertions(+), 51 deletions(-)

       via  9ac3e54bc97741867159976495d723a06f2cf28d (commit)
       via  3789a46123ea8a3c90977d8365d3720f9f6585b1 (commit)
      from  f23d3167e9163944b7a52ce9d822b930053bb957 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 9ac3e54bc97741867159976495d723a06f2cf28d
Author: Ward Vandewege <ward at curoverse.com>
Date:   Mon Sep 28 17:42:58 2015 -0400

    A number of additional tweaks.
    
    refs #7330

diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index 736453b..ecd9b44 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -7,6 +7,9 @@ RELEASE_PATH=$INSTALL_PATH/current
 SHARED_PATH=$INSTALL_PATH/shared
 CONFIG_PATH=/etc/arvados/sso
 
+DATABASE_READY=1
+APPLICATION_READY=1
+
 VERSION=`cat $RELEASE_PATH/git-commit.version`
 
 setup_ruby_environment() {
@@ -82,18 +85,35 @@ EOF
 
   echo -n "Symlinking files from $CONFIG_PATH ..."
 
+  if [ ! -f $CONFIG_PATH/database.yml ]; then
+    mkdir -p $CONFIG_PATH
+    cp $RELEASE_PATH/config/database.yml.example $CONFIG_PATH/database.yml
+    DATABASE_READY=0
+  fi
+
   if [ ! -h $RELEASE_PATH/config/database.yml ]; then
     ln -s $CONFIG_PATH/database.yml $RELEASE_PATH/config/database.yml
   fi
+
+  if [ ! -f $CONFIG_PATH/production.rb ]; then
+    mkdir -p $CONFIG_PATH
+    cp $RELEASE_PATH/config/environments/production.rb.example $CONFIG_PATH/production.rb
+  fi
+
   if [ ! -h $RELEASE_PATH/config/environments/production.rb ]; then
-    if [ ! -f $CONFIG_PATH/production.rb ]; then
-      cp $RELEASE_PATH/config/environments/production.rb.example $CONFIG_PATH/production.rb
-    fi
     ln -s $CONFIG_PATH/production.rb $RELEASE_PATH/config/environments/production.rb
   fi
+
+  if [ ! -f $CONFIG_PATH/application.yml ]; then
+    mkdir -p $CONFIG_PATH
+    cp $RELEASE_PATH/config/application.yml.example $CONFIG_PATH/application.yml
+    APPLICATION_READY=0
+  fi
+
   if [ ! -h $RELEASE_PATH/config/application.yml ]; then
     ln -s $CONFIG_PATH/application.yml $RELEASE_PATH/config/application.yml
   fi
+
   echo "... done."
 
   # Before we do anything else, make sure some directories and files are in place
@@ -122,7 +142,7 @@ EOF
   echo "... done."
 
   set +e
-  DB_MIGRATE_STATUS=`$COMMAND_PREFIX bundle exec rake db:migrate:status 2>/dev/null`
+  DB_MIGRATE_STATUS=`$COMMAND_PREFIX bundle exec rake db:migrate:status 2>&1`
   DB_MIGRATE_STATUS_CODE=$?
   set -e
 
@@ -130,28 +150,50 @@ EOF
     # The database exists, but the migrations table doesn't.
     echo -n "Setting up database ..."
     $COMMAND_PREFIX bundle exec rake db:schema:load db:seed || exit $?
+    echo "... done."
   elif echo $DB_MIGRATE_STATUS | grep '^database: ' >/dev/null; then
     echo -n "Running db:migrate ..."
     $COMMAND_PREFIX bundle exec rake db:migrate || exit $?
+    echo "... done."
+  elif echo $DB_MIGRATE_STATUS | grep 'database .* does not exist' >/dev/null; then
+    echo -n "Running db:setup ..."
+    set +e
+    $COMMAND_PREFIX bundle exec rake db:setup 2>/dev/null
+    if [ "$?" = "0" ]; then
+      echo "... done."
+    else
+      echo "... failed."
+      echo "Warning: unable to set up database." >&2
+      DATABASE_READY=0
+    fi
+    set -e
   else
-    echo "Error: Database is not ready to set up. Aborting." >&2
-    exit 1
+    echo "Warning: Database is not ready to set up. Skipping database setup." >&2
+    DATABASE_READY=0
   fi
-  echo "... done."
 
   echo -n "Precompiling assets ..."
   # precompile assets; thankfully this does not take long
-  $COMMAND_PREFIX bundle exec rake assets:precompile -q -s || exit $?
+  if [ "$APPLICATION_READY" = "1" ]; then
+    set +e
+    $COMMAND_PREFIX bundle exec rake assets:precompile -q -s 2>/dev/null
+    if [ "$?" = "0" ]; then
+      echo "... done."
+    else
+      echo "... failed."
+      APPLICATION_READY=0
+    fi
+    set -e
+  else
+    echo "... skipped."
+  fi
   chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
-  echo "... done."
 
   if [ ! -z "$WEB_SERVICE" ]; then
     echo -n "Restarting $WEB_SERVICE ..."
-    service "$WEB_SERVICE" restart || exit $?
+    service "$WEB_SERVICE" restart >/dev/null || exit $?
     echo "... done."
   fi
-
-  echo
 }
 
 if [ "$1" = configure ]; then
@@ -163,3 +205,33 @@ elif [ "$1" = "0" ] || [ "$1" = "1" ] || [ "$1" = "2" ]; then
   setup_ruby_environment
   configure_version $VERSION
 fi
+
+if [ "$DATABASE_READY" = "0" ]; then
+  cat <<EOF
+
+PLEASE NOTE:
+
+The arvados-sso package was not configured completely because
+/etc/arvados/database.yml needs some tweaking. Please refer to the
+documentation at http://doc.arvados.org/install/install-sso.html#configure for
+more details.
+
+When database.yml has been modified, reconfigure or reinstall this package.
+EOF
+fi
+
+if [ "$APPLICATION_READY" = "0" ]; then
+  cat <<EOF
+
+PLEASE NOTE:
+
+The arvados-sso package was not configured completely because
+/etc/arvados/application.yml needs some tweaking. Please refer to the
+documentation at http://doc.arvados.org/install/install-sso.html#configure for
+more details.
+
+When application.yml has been modified, reconfigure or reinstall this package.
+EOF
+fi
+
+echo

commit 3789a46123ea8a3c90977d8365d3720f9f6585b1
Author: Ward Vandewege <ward at curoverse.com>
Date:   Mon Sep 28 00:23:16 2015 -0400

    Add support for CentOS6 to the improved SSO packages.
    
    refs #7330

diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index cc23396..736453b 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -31,40 +31,53 @@ configure_version() {
 
   [ "$VERSION" ] || { echo "Error: configure_version: need version parameter" >&2; exit 1; }
 
-  if [ -e /etc/redhat-release ]; then
-      WWW_OWNER=nginx:nginx
-  else
-      # Assume we're on a Debian-based system for now.
-      WWW_OWNER=www-data:www-data
-  fi
+  WEB_SERVICE=${WEB_SERVICE:-$(service --status-all 2>/dev/null \
+      | grep -Eo '\bnginx|httpd[^[:space:]]*' || true)}
+  if [ -z "$WEB_SERVICE" ]; then
+    cat >&2 <<EOF
+
+Warning: web service (Nginx or Apache) not found.
 
-  NGINX_SERVICE=${NGINX_SERVICE:-$(service --status-all 2>/dev/null \
-      | grep -Eo '\bnginx[^[:space:]]*' || true)}
-  if [ -z "$NGINX_SERVICE" ]; then
-      cat >&2 <<EOF
-Error: nginx service not found. Aborting.
+To override, set the WEB_SERVICE environment variable to the name of the service
+hosting the Rails server. Alternativey, install nginx.
 
-Set NGINX_SERVICE to the name of the service hosting the Rails server
-and reconfigure this package with dpkg-reconfigure.
+For Debian-based systems, then reconfigure this package with dpkg-reconfigure.
+
+For RPM-based systems, then reinstall this package.
 
 EOF
-      exit 0
-  elif [ "$NGINX_SERVICE" != "$(echo "$NGINX_SERVICE" | head -n 1)" ]; then
-      cat >&2 <<EOF
-Error: multiple nginx services found. Aborting.
+  elif [ "$WEB_SERVICE" != "$(echo "$WEB_SERVICE" | head -n 1)" ]; then
+    WEB_SERVICE=$(echo "$WEB_SERVICE" | head -n 1)
+    cat >&2 <<EOF
+Warning: multiple web services found. Choosing the first one ($WEB_SERVICE).
+
+To override, set the WEB_SERVICE environment variable to the name of the service
+hosting the Rails server.
+
+For Debian-based systems, then reconfigure this package with dpkg-reconfigure.
 
-Set NGINX_SERVICE to the name of the service hosting the Rails server
-and reconfigure this package with dpkg-reconfigure.
+For RPM-based systems, then reinstall this package.
 
 EOF
-      exit 0
+  fi
+
+  if [ -e /etc/redhat-release ]; then
+      if [ "$WEB_SERVICE" = "nginx" ]; then
+        WWW_OWNER=nginx:nginx
+      else
+        WWW_OWNER=apache:apache
+      fi
+  else
+      # Assume we're on a Debian-based system for now.
+      # Both Apache and Nginx run as www-data by default.
+      WWW_OWNER=www-data:www-data
   fi
 
   echo
-  echo "Assumption: $NGINX_SERVICE is configured to serve your SSO server URL from"
+  echo "Assumption: $WEB_SERVICE is configured to serve your SSO server URL from"
   echo "            /var/www/arvados-sso/current"
   echo "Assumption: configuration files are in /etc/arvados/sso/"
-  echo "Assumption: $NGINX_SERVICE and passenger run as $WWW_OWNER"
+  echo "Assumption: $WEB_SERVICE and passenger run as $WWW_OWNER"
   echo
 
   echo -n "Symlinking files from $CONFIG_PATH ..."
@@ -132,15 +145,21 @@ EOF
   chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
   echo "... done."
 
-  echo -n "Restarting nginx ..."
-  service "$NGINX_SERVICE" restart || exit $?
-  echo "... done."
+  if [ ! -z "$WEB_SERVICE" ]; then
+    echo -n "Restarting $WEB_SERVICE ..."
+    service "$WEB_SERVICE" restart || exit $?
+    echo "... done."
+  fi
+
   echo
 }
 
 if [ "$1" = configure ]; then
+  # This is a debian-based system
   setup_ruby_environment
   configure_version $VERSION "$2"
+elif [ "$1" = "0" ] || [ "$1" = "1" ] || [ "$1" = "2" ]; then
+  # This is an rpm-based system
+  setup_ruby_environment
+  configure_version $VERSION
 fi
-
-
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postrm b/jenkins/arvados-sso-server-extras/arvados-sso-server.postrm
index 1d73a68..070c90e 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postrm
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postrm
@@ -15,8 +15,12 @@ purge () {
 }
 
 if [ "$1" = 'purge' ]; then
+  # This is a debian-based system and purge was requested
+  purge
+elif [ "$1" = "0" ] || [ "$1" = "1" ] || [ "$1" = "2" ]; then
+  # This is an rpm-based system, no guarantees are made, always purge
+  # Apparently yum doesn't actually remember what it installed.
+  # Clean those files up here, then purge.
+  rm -rf $RELEASE_PATH
   purge
 fi
-
-
-
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.prerm b/jenkins/arvados-sso-server-extras/arvados-sso-server.prerm
index 677a6ac..1a43fa2 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.prerm
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.prerm
@@ -14,9 +14,13 @@ remove () {
   rm -rf $RELEASE_PATH/public/assets/
   rm -rf $RELEASE_PATH/tmp
   rm -rf $RELEASE_PATH/.bundle
-  rm $RELEASE_PATH/log
+  rm $RELEASE_PATH/log || true
 }
 
 if [ "$1" = 'remove' ]; then
+  # This is a debian-based system and removal was requested
+  remove
+elif [ "$1" = "0" ] || [ "$1" = "1" ] || [ "$1" = "2" ]; then
+  # This is an rpm-based system
   remove
 fi
diff --git a/jenkins/run-build-packages-sso.sh b/jenkins/run-build-packages-sso.sh
index ada7a82..8d1de52 100755
--- a/jenkins/run-build-packages-sso.sh
+++ b/jenkins/run-build-packages-sso.sh
@@ -136,6 +136,20 @@ else
     GEM=gem
 fi
 
+if [[ "$TARGET" == "centos6" ]]; then
+  # CentOS6 comes with git 1.7.1, but we want at least 1.7.6
+  # because we use git status --ignore in fpm-info.sh
+  cd /usr/src
+  install_package libcurl-devel zlib-devel wget gettext
+  wget https://www.kernel.org/pub/software/scm/git/git-1.8.5.6.tar.gz
+  tar xzf git-1.8.5.6.tar.gz
+  cd git-1.8.5.6
+  make configure
+  ./configure --prefix=/usr --without-tcltk
+  make all
+  make install
+fi
+
 # Make all files world-readable -- jenkins runs with umask 027, and has checked
 # out our git tree here
 chmod o+r "$WORKSPACE" -R
@@ -218,6 +232,7 @@ debug_echo -e "\n${COMMAND_ARR[@]}\n"
 
 FPM_RESULTS=$("${COMMAND_ARR[@]}")
 FPM_EXIT_CODE=$?
+
 fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
 
 # SSO server package build done
diff --git a/jenkins/run-library.sh b/jenkins/run-library.sh
index f07397f..f19d58b 100755
--- a/jenkins/run-library.sh
+++ b/jenkins/run-library.sh
@@ -183,3 +183,12 @@ fpm_verify () {
     echo "Error building package for $1:\n $FPM_RESULTS"
   fi
 }
+
+install_package() {
+  PACKAGES=$@
+  if [[ "$FORMAT" == "deb" ]]; then
+    $SUDO apt-get install $PACKAGES --yes
+  elif [[ "$FORMAT" == "rpm" ]]; then
+    $SUDO yum -q -y install $PACKAGES
+  fi
+}
diff --git a/jenkins/run-test-packages-sso.sh b/jenkins/run-test-packages-sso.sh
index b9476bb..02e1b04 100755
--- a/jenkins/run-test-packages-sso.sh
+++ b/jenkins/run-test-packages-sso.sh
@@ -110,15 +110,6 @@ if ! [[ -d "$WORKSPACE" ]]; then
   exit 1
 fi
 
-install_package() {
-  PACKAGES=$@
-  if [[ "$FORMAT" == "deb" ]]; then
-    $SUDO apt-get install $PACKAGES --yes
-  elif [[ "$FORMAT" == "rpm" ]]; then
-    $SUDO yum -q -y install $PACKAGES
-  fi
-}
-
 # Find the SSO server package
 
 cd "$WORKSPACE"
@@ -129,7 +120,7 @@ PACKAGE_NAME=arvados-sso
 if [[ "$FORMAT" == "deb" ]]; then
   PACKAGE_PATH=$WORKSPACE/packages/$TARGET/arvados-sso_${SSO_VERSION}_amd64.deb
 elif [[ "$FORMAT" == "rpm" ]]; then
-  PACKAGE_PATH=$WORKSPACE/packages/$TARGET/arvados-sso-${SSO_VERSION}.x86_64.rpm
+  PACKAGE_PATH=$WORKSPACE/packages/$TARGET/arvados-sso-${SSO_VERSION}-1.x86_64.rpm
 fi
 
 # Test 1a: the package to test must exist
@@ -170,7 +161,19 @@ if [[ ! -e "/etc/arvados/sso/application.yml" ]]; then
 fi
 
 if [[ ! -e "/etc/arvados/sso/database.yml" ]]; then
-  install_package postgresql
+  # We haven't installed our dependencies yet, but we need to set up our
+  # database configuration now. Install postgresql if need be.
+  if [[ "$FORMAT" == "deb" ]]; then
+    install_package postgresql
+  elif [[ "$FORMAT" == "rpm" ]]; then
+    install_package postgresql-server
+    # postgres packaging on CentOS6 is kind of primitive, needs an initdb
+    $SUDO service postgresql initdb
+    if [ "$TARGET" = "centos6" ]; then
+      sed -i -e "s/127.0.0.1\/32          ident/127.0.0.1\/32          md5/" /var/lib/pgsql/data/pg_hba.conf
+      sed -i -e "s/::1\/128               ident/::1\/128               md5/" /var/lib/pgsql/data/pg_hba.conf
+    fi
+  fi
   $SUDO service postgresql start
 
   RANDOM_PASSWORD=`date | md5sum |cut -f1 -d' '`
@@ -188,12 +191,15 @@ EOF
     $SUDO -u postgres createdb sso_provider_production -O sso_provider_user
   else
     install_package sudo
+    if [ "$TARGET" = "centos6" ]; then
+      # Work around silly CentOS6 default, cf. https://bugzilla.redhat.com/show_bug.cgi?id=1020147
+      sed -i -e 's/Defaults    requiretty/#Defaults    requiretty/' /etc/sudoers
+    fi
     /usr/bin/sudo -u postgres psql -c "CREATE USER sso_provider_user WITH PASSWORD '$RANDOM_PASSWORD'"
     /usr/bin/sudo -u postgres createdb sso_provider_production -O sso_provider_user
   fi
 fi
 
-
 if [[ "$FORMAT" == "deb" ]]; then
   # Test 2: the package should install cleanly
   # In order to get the package dependencies, we need to first do an install
@@ -239,4 +245,6 @@ elif [[ "$FORMAT" == "rpm" ]]; then
 
 fi
 
+echo "Testing complete, no errors!"
+
 exit $EXITCODE

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list