Add support for CentOS6 to the improved SSO packages.
authorWard Vandewege <ward@curoverse.com>
Mon, 28 Sep 2015 04:23:16 +0000 (00:23 -0400)
committerWard Vandewege <ward@curoverse.com>
Mon, 28 Sep 2015 04:23:16 +0000 (00:23 -0400)
refs #7330

jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
jenkins/arvados-sso-server-extras/arvados-sso-server.postrm
jenkins/arvados-sso-server-extras/arvados-sso-server.prerm
jenkins/run-build-packages-sso.sh
jenkins/run-library.sh
jenkins/run-test-packages-sso.sh

index cc23396d6d6e2cf0b70eb4c959621c26be0f224a..736453bc6758b23aee97a1a571c27e7abb20dcd4 100755 (executable)
@@ -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
-
-
index 1d73a687eeec619652e5befa63947848c4092d5c..070c90ee658ed1d9b596906bc31b5fb17663be63 100755 (executable)
@@ -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
-
-
-
index 677a6ace48f93fa7d5e98b63b96ca812182ed913..1a43fa25113344a988e0be4df2bf0deddc71e585 100755 (executable)
@@ -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
index ada7a827e39087b795e45d30801ba5df5ef3e939..8d1de52ae479122e5a44e0d573128b6ac65c7088 100755 (executable)
@@ -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
index f07397f8435fc382dc8d58ca426f72d0f277c61e..f19d58bd39f6ee2f11edb7c7918ecc1d323b9f4a 100755 (executable)
@@ -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
+}
index b9476bba6d20cb9994c2f34dd8c9708f2e853261..02e1b046cfca72bc5ccda4aee644dbe6718946a4 100755 (executable)
@@ -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