[ARVADOS-DEV] updated: 1e48d4f97d643b3a36f7856284e3a95430bc8f92
git at public.curoverse.com
git at public.curoverse.com
Mon Jan 11 17:17:49 EST 2016
Summary of changes:
.../arvados-api-server-upgrade.sh | 118 ----------
jenkins/arvados-api-server-extras/postinst.sh | 12 -
.../arvados-sso-server-upgrade.sh | 91 --------
.../arvados-sso-server.postinst | 247 ---------------------
.../arvados-workbench-upgrade.sh | 90 --------
jenkins/arvados-workbench-extras/postinst.sh | 12 -
jenkins/rails-package-scripts/README.md | 13 ++
.../rails-package-scripts/arvados-api-server.sh | 12 +
.../rails-package-scripts/arvados-sso-server.sh | 9 +
jenkins/rails-package-scripts/arvados-workbench.sh | 7 +
jenkins/rails-package-scripts/postinst.sh | 247 +++++++++++++++++++++
.../postrm.sh} | 7 +-
.../prerm.sh} | 12 +-
jenkins/rails-package-scripts/step2.sh | 25 +++
jenkins/run-build-packages-sso.sh | 72 +-----
jenkins/run-build-packages.sh | 123 +++-------
jenkins/run-deploy.sh | 5 -
jenkins/run-library.sh | 74 +++++-
jenkins/run-tests.sh | 2 +-
19 files changed, 418 insertions(+), 760 deletions(-)
delete mode 100755 jenkins/arvados-api-server-extras/arvados-api-server-upgrade.sh
delete mode 100644 jenkins/arvados-api-server-extras/postinst.sh
delete mode 100755 jenkins/arvados-sso-server-extras/arvados-sso-server-upgrade.sh
delete mode 100755 jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
delete mode 100755 jenkins/arvados-workbench-extras/arvados-workbench-upgrade.sh
delete mode 100644 jenkins/arvados-workbench-extras/postinst.sh
create mode 100644 jenkins/rails-package-scripts/README.md
create mode 100644 jenkins/rails-package-scripts/arvados-api-server.sh
create mode 100644 jenkins/rails-package-scripts/arvados-sso-server.sh
create mode 100644 jenkins/rails-package-scripts/arvados-workbench.sh
create mode 100644 jenkins/rails-package-scripts/postinst.sh
rename jenkins/{arvados-sso-server-extras/arvados-sso-server.postrm => rails-package-scripts/postrm.sh} (79%)
mode change 100755 => 100644
rename jenkins/{arvados-sso-server-extras/arvados-sso-server.prerm => rails-package-scripts/prerm.sh} (71%)
mode change 100755 => 100644
create mode 100644 jenkins/rails-package-scripts/step2.sh
via 1e48d4f97d643b3a36f7856284e3a95430bc8f92 (commit)
via 211b5c1e8a86fe9f3a6704f76120e2fed78a9247 (commit)
via 81afb79616d482b177d91ee4e198392e750221ab (commit)
via e6ee12052db27b61f8bcf7af89acc9dc520a1799 (commit)
via 0814135175ab777abe515e4ba404dd0bf2929b24 (commit)
via 9f73adf4a13fef44dd133b91c46693aea1af69df (commit)
via c1c5b145f832bd9a647c6e07e19f148cf26ff910 (commit)
via 9fb392b2eaa59f20f7186de726531d922408dfa1 (commit)
via 1c0ce486e11b13ef5cd10959d4eca1fd948d88d1 (commit)
via 26170766797e80d0c86c25a10331f43c6d0eb283 (commit)
via 46ae733bd885da0d75882831af822c9578621730 (commit)
via 2bee50fa0b09c9dd785fe6d6beafe21fa961111d (commit)
via 33f530c93b5bd397c6c9569385613915acf4cdbb (commit)
via 4735c45083770bf8344dd80dd84695bb4e0fd169 (commit)
from 886c3c5c57c6419aceb390aea88c5886f43bbf42 (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 1e48d4f97d643b3a36f7856284e3a95430bc8f92
Merge: 886c3c5 211b5c1
Author: Brett Smith <brett at curoverse.com>
Date: Mon Jan 11 17:17:45 2016 -0500
Merge branch '8014-rails-postinst-scripts-wip'
Refs #8014. Closes #8036.
commit 211b5c1e8a86fe9f3a6704f76120e2fed78a9247
Author: Brett Smith <brett at curoverse.com>
Date: Mon Jan 11 17:17:09 2016 -0500
8014: Rails upgrade scripts are removed; don't run them in deploy script.
diff --git a/jenkins/run-deploy.sh b/jenkins/run-deploy.sh
index f83f901..1b06c65 100755
--- a/jenkins/run-deploy.sh
+++ b/jenkins/run-deploy.sh
@@ -163,8 +163,6 @@ title "Updating API server"
SUM_ECODE=0
run_puppet $IDENTIFIER.arvadosapi.com ECODE
SUM_ECODE=$(($SUM_ECODE + $ECODE))
-run_command $IDENTIFIER.arvadosapi.com ECODE "/usr/local/rvm/bin/rvm-exec /usr/local/bin/arvados-api-server-upgrade.sh"
-SUM_ECODE=$(($SUM_ECODE + $ECODE))
if [ ! "$IDENTIFIER" = "c97qk" ]
then
run_command $IDENTIFIER.arvadosapi.com ECODE "dpkg -L arvados-mailchimp-plugin 2>/dev/null && apt-get install arvados-mailchimp-plugin --reinstall || echo"
@@ -239,9 +237,6 @@ if [[ `host workbench.$ARVADOS_API_HOST |cut -f4 -d' '` != `host $ARVADOS_API_HO
SUM_ECODE=$(($SUM_ECODE + $ECODE))
fi
-run_command workbench.$IDENTIFIER ECODE "/usr/local/rvm/bin/rvm-exec /usr/local/bin/arvados-workbench-upgrade.sh"
-SUM_ECODE=$(($SUM_ECODE + $ECODE))
-
if [[ "$SUM_ECODE" != "0" ]]; then
title "ERROR: Updating workbench FAILED"
EXITCODE=$(($EXITCODE + $SUM_ECODE))
commit 81afb79616d482b177d91ee4e198392e750221ab
Author: Brett Smith <brett at curoverse.com>
Date: Mon Jan 4 18:02:08 2016 -0500
8014: Rails postinst script sets better default access for /etc/arvados.
diff --git a/jenkins/rails-package-scripts/postinst.sh b/jenkins/rails-package-scripts/postinst.sh
index 96e687c..1032d14 100644
--- a/jenkins/rails-package-scripts/postinst.sh
+++ b/jenkins/rails-package-scripts/postinst.sh
@@ -64,6 +64,14 @@ run_and_report() {
return $retcode
}
+setup_confdirs() {
+ for confdir in "$@"; do
+ if [ ! -d "$confdir" ]; then
+ install -d -g "$WWW_OWNER" -m 0750 "$confdir"
+ fi
+ done
+}
+
setup_conffile() {
# Usage: setup_conffile CONFFILE_PATH [SOURCE_PATH]
# Both paths are relative to RELEASE_CONFIG_PATH.
@@ -84,19 +92,27 @@ setup_conffile() {
if [ ! -e "$release_conffile" ]; then
ln -s "$etc_conffile" "$release_conffile"
# If there's a config file in /var/www identical to the one in /etc,
- # overwrite it with a symlink.
+ # overwrite it with a symlink after porting its permissions.
elif cmp --quiet "$release_conffile" "$etc_conffile"; then
+ local ownership="$(stat -c "%U:%G" "$release_conffile")"
+ chown "$ownership" "$etc_conffile"
+ chmod --reference="$release_conffile" "$etc_conffile"
+ chgrp "${ownership#*:}" "$CONFIG_PATH" /etc/arvados
+ chmod g+rx "$CONFIG_PATH" /etc/arvados
ln --force -s "$etc_conffile" "$release_conffile"
fi
fi
if [ -n "$conffile_source" ]; then
- cp --no-clobber "$RELEASE_CONFIG_PATH/$conffile_source" "$etc_conffile"
+ if [ ! -e "$etc_conffile" ]; then
+ install -g "$WWW_OWNER" -m 0640 \
+ "$RELEASE_CONFIG_PATH/$conffile_source" "$etc_conffile"
+ return 1
# Even if $etc_conffile already existed, it might be unmodified from
# the source. This is especially likely when a user installs, updates
# database.yml, then reconfigures before they update application.yml.
# Use cmp to be sure whether $etc_conffile is modified.
- if cmp --quiet "$RELEASE_CONFIG_PATH/$conffile_source" "$etc_conffile"; then
+ elif cmp --quiet "$RELEASE_CONFIG_PATH/$conffile_source" "$etc_conffile"; then
return 1
fi
fi
@@ -137,14 +153,14 @@ configure_version() {
if [ -e /etc/redhat-release ]; then
# Recognize any service that starts with "nginx"; e.g., nginx16.
if [ "$WEB_SERVICE" != "${WEB_SERVICE#nginx}" ]; then
- WWW_OWNER=nginx:nginx
+ WWW_OWNER=nginx
else
- WWW_OWNER=apache:apache
+ WWW_OWNER=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
+ WWW_OWNER=www-data
fi
echo
@@ -154,7 +170,7 @@ configure_version() {
echo
echo -n "Creating symlinks to configuration in $CONFIG_PATH ..."
- mkdir -p $CONFIG_PATH
+ setup_confdirs /etc/arvados "$CONFIG_PATH"
setup_conffile environments/production.rb environments/production.rb.example \
|| true
setup_conffile application.yml application.yml.example || APPLICATION_READY=0
@@ -182,21 +198,20 @@ configure_version() {
echo -n "Ensuring directory and file permissions ..."
# Ensure correct ownership of a few files
- chown "$WWW_OWNER" $RELEASE_PATH/config/environment.rb
- chown "$WWW_OWNER" $RELEASE_PATH/config.ru
- chown "$WWW_OWNER" $RELEASE_PATH/Gemfile.lock
- chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
- chown -R "$WWW_OWNER" $SHARED_PATH/log
+ chown "$WWW_OWNER:" $RELEASE_PATH/config/environment.rb
+ chown "$WWW_OWNER:" $RELEASE_PATH/config.ru
+ chown "$WWW_OWNER:" $RELEASE_PATH/Gemfile.lock
+ chown -R "$WWW_OWNER:" $RELEASE_PATH/tmp
+ chown -R "$WWW_OWNER:" $SHARED_PATH/log
case "$RAILSPKG_DATABASE_LOAD_TASK" in
- db:schema:load) chown "$WWW_OWNER" $RELEASE_PATH/db/schema.rb ;;
- db:structure:load) chown "$WWW_OWNER" $RELEASE_PATH/db/structure.sql ;;
+ db:schema:load) chown "$WWW_OWNER:" $RELEASE_PATH/db/schema.rb ;;
+ db:structure:load) chown "$WWW_OWNER:" $RELEASE_PATH/db/structure.sql ;;
esac
chmod 644 $SHARED_PATH/log/*
chmod -R 2775 $RELEASE_PATH/tmp
echo "... done."
if [ -n "$RAILSPKG_DATABASE_LOAD_TASK" ]; then
- chown "$WWW_OWNER" $RELEASE_PATH/config/database.yml
prepare_database
fi
@@ -213,7 +228,7 @@ configure_version() {
else
echo "Precompiling assets... skipped."
fi
- chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
+ chown -R "$WWW_OWNER:" $RELEASE_PATH/tmp
if [ ! -z "$WEB_SERVICE" ]; then
service "$WEB_SERVICE" restart
commit e6ee12052db27b61f8bcf7af89acc9dc520a1799
Author: Brett Smith <brett at curoverse.com>
Date: Sat Jan 2 12:15:53 2016 -0500
8014, 8059: Unify Rails package building.
* Introduce a handle_rails_package function, and helpers, to build a
Rails package.
* Generalize all the support scripts into unified postinst, prerm, and
postrm scripts. handle_rails_package builds these into the
packages. See jenkins/rails-package-scripts/README.md for details.
* More error checking throughout (e.g., check for failure when doing
any prep work for Rails packages, or the Workbench packages
specifically, using `set -e` in a subshell).
One behavior change from this unification: before this,
run-build-packages treated --build-bundle-packages to mean "*also*
build bundle packages", while run-build-packages-sso treated the
switch to mean "*only* build bundle packages". This commit declares
run-build-packages to be the winner, and makes run-build-packages-sso
consistent with it.
diff --git a/jenkins/arvados-api-server-extras/arvados-api-server-upgrade.sh b/jenkins/arvados-api-server-extras/arvados-api-server-upgrade.sh
deleted file mode 100755
index 2fff1e7..0000000
--- a/jenkins/arvados-api-server-extras/arvados-api-server-upgrade.sh
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/bin/bash
-
-set -e
-
-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
-
-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.
-Set NGINX_SERVICE to the name of the service hosting the Rails server.
-EOF
- exit 1
-elif [ "$NGINX_SERVICE" != "$(echo "$NGINX_SERVICE" | head -n 1)" ]; then
- cat >&2 <<EOF
-Error: multiple nginx services found. Aborting.
-Set NGINX_SERVICE to the name of the service hosting the Rails server.
-EOF
- exit 1
-fi
-
-RELEASE_PATH=/var/www/arvados-api/current
-SHARED_PATH=/var/www/arvados-api/shared
-CONFIG_PATH=/etc/arvados/api/
-
-echo "Assumption: $NGINX_SERVICE is configured to serve your API server URL from"
-echo " /var/www/arvados-api/current"
-echo "Assumption: configuration files are in /etc/arvados/api/"
-echo "Assumption: $NGINX_SERVICE and passenger run as $WWW_OWNER"
-echo
-
-echo "Copying files from $CONFIG_PATH"
-cp -f $CONFIG_PATH/database.yml $RELEASE_PATH/config/database.yml
-cp -f $RELEASE_PATH/config/environments/production.rb.example $RELEASE_PATH/config/environments/production.rb
-cp -f $CONFIG_PATH/application.yml $RELEASE_PATH/config/application.yml
-if [ -e $CONFIG_PATH/omniauth.rb ]; then
- cp -f $CONFIG_PATH/omniauth.rb $RELEASE_PATH/config/initializers/omniauth.rb
-fi
-echo "Done."
-
-# Before we do anything else, make sure some directories and files are in place
-if [[ ! -e $SHARED_PATH/log ]]; then mkdir -p $SHARED_PATH/log; fi
-if [[ ! -e $RELEASE_PATH/tmp ]]; then mkdir -p $RELEASE_PATH/tmp; fi
-if [[ ! -e $RELEASE_PATH/log ]]; then ln -s $SHARED_PATH/log $RELEASE_PATH/log; fi
-if [[ ! -e $SHARED_PATH/log/production.log ]]; then touch $SHARED_PATH/log/production.log; fi
-
-cd "$RELEASE_PATH"
-export RAILS_ENV=production
-
-echo "Making sure bundle is installed"
-set +e
-which bundle > /dev/null
-if [[ "$?" != "0" ]]; then
- gem install bundle
-fi
-set -e
-echo "Done."
-
-echo "Running bundle install"
-bundle install --path $SHARED_PATH/vendor_bundle
-echo "Done."
-
-echo "Precompiling assets"
-# precompile assets; thankfully this does not take long
-bundle exec rake assets:precompile
-echo "Done."
-
-echo "Ensuring directory and file permissions"
-# Ensure correct ownership of a few files
-chown "$WWW_OWNER" $RELEASE_PATH/config/environment.rb
-chown "$WWW_OWNER" $RELEASE_PATH/config.ru
-chown "$WWW_OWNER" $RELEASE_PATH/config/database.yml
-chown "$WWW_OWNER" $RELEASE_PATH/Gemfile.lock
-chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
-chown -R "$WWW_OWNER" $SHARED_PATH/log
-chown "$WWW_OWNER" $RELEASE_PATH/db/structure.sql
-chmod 644 $SHARED_PATH/log/*
-# Rails creates the cache directory if it doesn't exist
-if [[ -d $RELEASE_PATH/tmp/cache/ ]]; then
- chmod -R 2775 $RELEASE_PATH/tmp/cache/
-fi
-echo "Done."
-
-echo "Running sanity check"
-bundle exec rake config:check
-SANITY_CHECK_EXIT_CODE=$?
-echo "Done."
-
-if [[ "$SANITY_CHECK_EXIT_CODE" != "0" ]]; then
- echo "Sanity check failed, aborting. Please roll back to the previous version of the package."
- echo "The database has not been migrated yet, so reinstalling the previous version is safe."
- exit $SANITY_CHECK_EXIT_CODE
-fi
-
-echo "Checking database status"
-# If we use `grep -q`, rake will write a backtrace on EPIPE.
-if bundle exec rake db:migrate:status | grep '^database: ' >/dev/null; then
- echo "Starting db:migrate"
- bundle exec rake db:migrate
-elif [ 0 -eq ${PIPESTATUS[0]} ]; then
- # The database exists, but the migrations table doesn't.
- echo "Setting up database"
- bundle exec rake db:structure:load db:seed
-else
- echo "Error: Database is not ready to set up. Aborting." >&2
- exit 1
-fi
-echo "Done."
-
-echo "Restarting nginx"
-service "$NGINX_SERVICE" restart
-echo "Done."
diff --git a/jenkins/arvados-api-server-extras/postinst.sh b/jenkins/arvados-api-server-extras/postinst.sh
deleted file mode 100644
index 1aeffe9..0000000
--- a/jenkins/arvados-api-server-extras/postinst.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-cd /var/www/arvados-api
-
-chown -R www-data:www-data tmp >/dev/null 2>&1
-chown -R www-data:www-data log >/dev/null 2>&1
-chown www-data:www-data db/structure.sql >/dev/null 2>&1
-chmod 644 log/* >/dev/null 2>&1
-
-# Errors above are not serious
-exit 0
-
diff --git a/jenkins/arvados-workbench-extras/arvados-workbench-upgrade.sh b/jenkins/arvados-workbench-extras/arvados-workbench-upgrade.sh
deleted file mode 100755
index e981517..0000000
--- a/jenkins/arvados-workbench-extras/arvados-workbench-upgrade.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/bash
-
-set -e
-
-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
-
-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.
-Set NGINX_SERVICE to the name of the service hosting the Rails server.
-EOF
- exit 1
-elif [ "$NGINX_SERVICE" != "$(echo "$NGINX_SERVICE" | head -n 1)" ]; then
- cat >&2 <<EOF
-Error: multiple nginx services found. Aborting.
-Set NGINX_SERVICE to the name of the service hosting the Rails server.
-EOF
- exit 1
-fi
-
-RELEASE_PATH=/var/www/arvados-workbench/current
-SHARED_PATH=/var/www/arvados-workbench/shared
-CONFIG_PATH=/etc/arvados/workbench/
-
-echo "Assumption: $NGINX_SERVICE is configured to serve your workbench URL from "
-echo " /var/www/arvados-workbench/current"
-echo "Assumption: configuration files are in /etc/arvados/workbench/"
-echo "Assumption: $NGINX_SERVICE and passenger run as $WWW_OWNER"
-echo
-
-echo "Copying files from $CONFIG_PATH"
-cp -f $CONFIG_PATH/application.yml $RELEASE_PATH/config/application.yml
-cp -f $RELEASE_PATH/config/environments/production.rb.example $RELEASE_PATH/config/environments/production.rb
-echo "Done."
-
-# Before we do anything else, make sure some directories and files are in place
-if [[ ! -e $SHARED_PATH/log ]]; then mkdir -p $SHARED_PATH/log; fi
-if [[ ! -e $RELEASE_PATH/tmp ]]; then mkdir -p $RELEASE_PATH/tmp; fi
-if [[ ! -e $RELEASE_PATH/log ]]; then ln -s $SHARED_PATH/log $RELEASE_PATH/log; fi
-if [[ ! -e $SHARED_PATH/log/production.log ]]; then touch $SHARED_PATH/log/production.log; fi
-
-echo "Making sure bundle is installed"
-set +e
-which bundle > /dev/null
-if [[ "$?" != "0" ]]; then
- gem install bundle
-fi
-set -e
-echo "Done."
-
-echo "Running bundle install"
-(cd $RELEASE_PATH && RAILS_ENV=production bundle install --path $SHARED_PATH/vendor_bundle)
-echo "Done."
-
-# We do not need to precompile assets, they are already part of the package.
-
-echo "Ensuring directory and file permissions"
-chown "$WWW_OWNER" $RELEASE_PATH/config/environment.rb
-chown "$WWW_OWNER" $RELEASE_PATH/config.ru
-chown "$WWW_OWNER" $RELEASE_PATH/config/database.yml
-chown "$WWW_OWNER" $RELEASE_PATH/Gemfile.lock
-chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
-chown -R "$WWW_OWNER" $SHARED_PATH/log
-chown "$WWW_OWNER" $RELEASE_PATH/db/schema.rb
-chmod 644 $SHARED_PATH/log/*
-echo "Done."
-
-echo "Running sanity check"
-(cd $RELEASE_PATH && RAILS_ENV=production bundle exec rake config:check)
-SANITY_CHECK_EXIT_CODE=$?
-echo "Done."
-
-if [[ "$SANITY_CHECK_EXIT_CODE" != "0" ]]; then
- echo "Sanity check failed, aborting. Please roll back to the previous version of the package."
- exit $SANITY_CHECK_EXIT_CODE
-fi
-
-# We do not need to run db:migrate because Workbench is stateless
-
-echo "Restarting nginx"
-service "$NGINX_SERVICE" restart
-echo "Done."
-
diff --git a/jenkins/arvados-workbench-extras/postinst.sh b/jenkins/arvados-workbench-extras/postinst.sh
deleted file mode 100644
index d0aa9b0..0000000
--- a/jenkins/arvados-workbench-extras/postinst.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-cd /var/www/arvados-workbench
-
-chown -R www-data:www-data tmp >/dev/null 2>&1
-chown -R www-data:www-data log >/dev/null 2>&1
-chown www-data:www-data db/schema.rb >/dev/null 2>&1
-chmod 644 log/* >/dev/null 2>&1
-
-# Errors above are not serious
-exit 0
-
diff --git a/jenkins/rails-package-scripts/README.md b/jenkins/rails-package-scripts/README.md
new file mode 100644
index 0000000..6779fb4
--- /dev/null
+++ b/jenkins/rails-package-scripts/README.md
@@ -0,0 +1,13 @@
+When run-build-packages.sh builds a Rails package, it generates the package's pre/post-inst/rm scripts by concatenating:
+
+1. package_name.sh, which defines variables about where package files live and some human-readable names about them.
+2. step2.sh, which uses those to define some utility variables and set defaults for things that aren't set.
+3. stepname.sh, like postinst.sh, prerm.sh, etc., which uses all this information to do the actual work.
+
+Since our build process is a tower of shell scripts, concatenating files seemed like the least worst option to share code between these files and packages. More advanced code generation would've been too much trouble to integrate into our build process at this time. Trying to inject portions of files into other files seemed error-prone and likely to introduce bugs to the end result.
+
+postinst.sh lets the early parts define a few hooks to control behavior:
+
+* After it installs the core configuration files (database.yml, application.yml, and production.rb) to /etc/arvados/server, it calls setup_extra_conffiles. By default this is a noop function (in step2.sh). API server defines this to set up the old omniauth.rb conffile.
+* $RAILSPKG_DATABASE_LOAD_TASK defines the Rake task to load the database. API server uses db:structure:load. SSO server uses db:schema:load. Workbench doesn't set this, which causes the postinst to skip all database work.
+* If $RAILSPKG_SUPPORTS_CONFIG_CHECK != 1, it won't run the config:check rake task. SSO clears this flag (it doesn't have that task code).
diff --git a/jenkins/rails-package-scripts/arvados-api-server.sh b/jenkins/rails-package-scripts/arvados-api-server.sh
new file mode 100644
index 0000000..4df87eb
--- /dev/null
+++ b/jenkins/rails-package-scripts/arvados-api-server.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# This file declares variables common to all scripts for one Rails package.
+
+PACKAGE_NAME=arvados-api-server
+INSTALL_PATH=/var/www/arvados-api
+CONFIG_PATH=/etc/arvados/api
+DOC_URL="http://doc.arvados.org/install/install-api-server.html#configure"
+
+RAILSPKG_DATABASE_LOAD_TASK=db:structure:load
+setup_extra_conffiles() {
+ setup_conffile initializers/omniauth.rb
+}
diff --git a/jenkins/rails-package-scripts/arvados-sso-server.sh b/jenkins/rails-package-scripts/arvados-sso-server.sh
new file mode 100644
index 0000000..10b2ee2
--- /dev/null
+++ b/jenkins/rails-package-scripts/arvados-sso-server.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+# This file declares variables common to all scripts for one Rails package.
+
+PACKAGE_NAME=arvados-sso-server
+INSTALL_PATH=/var/www/arvados-sso
+CONFIG_PATH=/etc/arvados/sso
+DOC_URL="http://doc.arvados.org/install/install-sso.html#configure"
+RAILSPKG_DATABASE_LOAD_TASK=db:schema:load
+RAILSPKG_SUPPORTS_CONFIG_CHECK=0
diff --git a/jenkins/rails-package-scripts/arvados-workbench.sh b/jenkins/rails-package-scripts/arvados-workbench.sh
new file mode 100644
index 0000000..f2b8a56
--- /dev/null
+++ b/jenkins/rails-package-scripts/arvados-workbench.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+# This file declares variables common to all scripts for one Rails package.
+
+PACKAGE_NAME=arvados-workbench
+INSTALL_PATH=/var/www/arvados-workbench
+CONFIG_PATH=/etc/arvados/workbench
+DOC_URL="http://doc.arvados.org/install/install-workbench-app.html#configure"
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/rails-package-scripts/postinst.sh
old mode 100755
new mode 100644
similarity index 82%
rename from jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
rename to jenkins/rails-package-scripts/postinst.sh
index e72d9b8..96e687c
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/rails-package-scripts/postinst.sh
@@ -1,15 +1,8 @@
-#!/bin/bash
+#!/bin/sh
+# This code runs after package variable definitions and step2.sh.
set -e
-INSTALL_PATH=/var/www/arvados-sso
-RELEASE_PATH=$INSTALL_PATH/current
-RELEASE_CONFIG_PATH=$RELEASE_PATH/config
-SHARED_PATH=$INSTALL_PATH/shared
-CONFIG_PATH=/etc/arvados/sso
-PACKAGE_NAME=arvados-sso-server
-DOC_URL="http://doc.arvados.org/install/install-sso.html#configure"
-
DATABASE_READY=1
APPLICATION_READY=1
@@ -20,8 +13,8 @@ else
fi
report_not_ready() {
- local ready_flag=$1; shift
- local config_file=$1; shift
+ local ready_flag="$1"; shift
+ local config_file="$1"; shift
if [ "1" != "$ready_flag" ]; then cat >&2 <<EOF
PLEASE NOTE:
@@ -39,7 +32,7 @@ EOF
}
report_web_service_warning() {
- local warning=$1; shift
+ local warning="$1"; shift
cat >&2 <<EOF
WARNING: $warning.
@@ -59,7 +52,7 @@ run_and_report() {
# This is the usual wrapper that prints ACTION_MSG, runs CMD, then writes
# a message about whether CMD succeeded or failed. Returns the exit code
# of CMD.
- local action_message=$1; shift
+ local action_message="$1"; shift
local retcode=0
echo -n "$action_message..."
if "$@"; then
@@ -79,10 +72,10 @@ setup_conffile() {
# If SOURCE_PATH is given, this function will try to install that file as
# the configuration file in CONFIG_PATH, and return 1 if the file in
# CONFIG_PATH is unmodified from the source.
- local conffile_relpath=$1; shift
- local conffile_source=$1; shift
- local release_conffile=$RELEASE_CONFIG_PATH/$conffile_relpath
- local etc_conffile=$CONFIG_PATH/$(basename "$conffile_relpath")
+ local conffile_relpath="$1"; shift
+ local conffile_source="$1"
+ local release_conffile="$RELEASE_CONFIG_PATH/$conffile_relpath"
+ local etc_conffile="$CONFIG_PATH/$(basename "$conffile_relpath")"
# Note that -h can return true and -e will return false simultaneously
# when the target is a dangling symlink. We're okay with that outcome,
@@ -109,6 +102,27 @@ setup_conffile() {
fi
}
+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
+ echo "Warning: Database is not ready to set up. Skipping database setup." >&2
+ DATABASE_READY=0
+ fi
+}
+
configure_version() {
WEB_SERVICE=${WEB_SERVICE:-$(service --status-all 2>/dev/null \
| grep -Eo '\bnginx|httpd[^[:space:]]*' || true)}
@@ -134,18 +148,20 @@ configure_version() {
fi
echo
- echo "Assumption: $WEB_SERVICE is configured to serve your SSO server URL from"
+ echo "Assumption: $WEB_SERVICE is configured to serve Rails from"
echo " $RELEASE_PATH"
- echo "Assumption: configuration files are in $CONFIG_PATH"
echo "Assumption: $WEB_SERVICE and passenger run as $WWW_OWNER"
echo
- echo -n "Symlinking files from $CONFIG_PATH ..."
+ echo -n "Creating symlinks to configuration in $CONFIG_PATH ..."
mkdir -p $CONFIG_PATH
- setup_conffile database.yml database.yml.example || DATABASE_READY=0
setup_conffile environments/production.rb environments/production.rb.example \
|| true
setup_conffile application.yml application.yml.example || APPLICATION_READY=0
+ if [ -n "$RAILSPKG_DATABASE_LOAD_TASK" ]; then
+ setup_conffile database.yml database.yml.example || DATABASE_READY=0
+ fi
+ setup_extra_conffiles
echo "... done."
# Before we do anything else, make sure some directories and files are in place
@@ -168,31 +184,25 @@ configure_version() {
# Ensure correct ownership of a few files
chown "$WWW_OWNER" $RELEASE_PATH/config/environment.rb
chown "$WWW_OWNER" $RELEASE_PATH/config.ru
- chown "$WWW_OWNER" $RELEASE_PATH/config/database.yml
chown "$WWW_OWNER" $RELEASE_PATH/Gemfile.lock
chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
chown -R "$WWW_OWNER" $SHARED_PATH/log
- chown "$WWW_OWNER" $RELEASE_PATH/db/schema.rb
+ case "$RAILSPKG_DATABASE_LOAD_TASK" in
+ db:schema:load) chown "$WWW_OWNER" $RELEASE_PATH/db/schema.rb ;;
+ db:structure:load) chown "$WWW_OWNER" $RELEASE_PATH/db/structure.sql ;;
+ esac
chmod 644 $SHARED_PATH/log/*
+ chmod -R 2775 $RELEASE_PATH/tmp
echo "... done."
- 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 db:schema:load 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
- echo "Warning: Database is not ready to set up. Skipping database setup." >&2
- DATABASE_READY=0
+ if [ -n "$RAILSPKG_DATABASE_LOAD_TASK" ]; then
+ chown "$WWW_OWNER" $RELEASE_PATH/config/database.yml
+ prepare_database
+ fi
+
+ if [ 11 = "$RAILSPKG_SUPPORTS_CONFIG_CHECK$APPLICATION_READY" ]; then
+ run_and_report "Checking application.yml for completeness" \
+ $COMMAND_PREFIX bundle exec rake config:check || APPLICATION_READY=0
fi
# precompile assets; thankfully this does not take long
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postrm b/jenkins/rails-package-scripts/postrm.sh
old mode 100755
new mode 100644
similarity index 79%
rename from jenkins/arvados-sso-server-extras/arvados-sso-server.postrm
rename to jenkins/rails-package-scripts/postrm.sh
index 070c90e..8c45d2f
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postrm
+++ b/jenkins/rails-package-scripts/postrm.sh
@@ -1,15 +1,12 @@
#!/bin/sh
+# This code runs after package variable definitions and step2.sh.
set -e
-INSTALL_PATH=/var/www/arvados-sso
-RELEASE_PATH=$INSTALL_PATH/current
-SHARED_PATH=$INSTALL_PATH/shared
-CONFIG_PATH=/etc/arvados/sso
-
purge () {
rm -rf $SHARED_PATH/vendor_bundle
rm -rf $SHARED_PATH/log
+ rm -rf $CONFIG_PATH
rmdir $SHARED_PATH || true
rmdir $INSTALL_PATH || true
}
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.prerm b/jenkins/rails-package-scripts/prerm.sh
old mode 100755
new mode 100644
similarity index 71%
rename from jenkins/arvados-sso-server-extras/arvados-sso-server.prerm
rename to jenkins/rails-package-scripts/prerm.sh
index 1a43fa2..4ef5904
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.prerm
+++ b/jenkins/rails-package-scripts/prerm.sh
@@ -1,20 +1,16 @@
#!/bin/sh
-
-set -e
-
-INSTALL_PATH=/var/www/arvados-sso
-RELEASE_PATH=$INSTALL_PATH/current
-SHARED_PATH=$INSTALL_PATH/shared
-CONFIG_PATH=/etc/arvados/sso
+# This code runs after package variable definitions and step2.sh.
remove () {
rm -f $RELEASE_PATH/config/database.yml
rm -f $RELEASE_PATH/config/environments/production.rb
rm -f $RELEASE_PATH/config/application.yml
+ # Old API server configuration file.
+ rm -f $RELEASE_PATH/config/initializers/omniauth.rb
rm -rf $RELEASE_PATH/public/assets/
rm -rf $RELEASE_PATH/tmp
rm -rf $RELEASE_PATH/.bundle
- rm $RELEASE_PATH/log || true
+ rm -rf $RELEASE_PATH/log
}
if [ "$1" = 'remove' ]; then
diff --git a/jenkins/rails-package-scripts/step2.sh b/jenkins/rails-package-scripts/step2.sh
new file mode 100644
index 0000000..6678d49
--- /dev/null
+++ b/jenkins/rails-package-scripts/step2.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# This code runs after package variable definitions, before the actual
+# pre/post package work, to set some variable and function defaults.
+
+if [ -z "$INSTALL_PATH" ]; then
+ cat >&2 <<EOF
+
+PACKAGE BUILD ERROR: $0 is missing package metadata.
+
+This package is buggy. Please mail <support at curoverse.com> to let
+us know the name and version number of the package you tried to
+install, and we'll get it fixed.
+
+EOF
+ exit 3
+fi
+
+RELEASE_PATH=$INSTALL_PATH/current
+RELEASE_CONFIG_PATH=$RELEASE_PATH/config
+SHARED_PATH=$INSTALL_PATH/shared
+
+RAILSPKG_SUPPORTS_CONFIG_CHECK=${RAILSPKG_SUPPORTS_CONFIG_CHECK:-1}
+if ! type setup_extra_conffiles >/dev/null 2>&1; then
+ setup_extra_conffiles() { return; }
+fi
diff --git a/jenkins/run-build-packages-sso.sh b/jenkins/run-build-packages-sso.sh
index 2cee17f..eedb77b 100755
--- a/jenkins/run-build-packages-sso.sh
+++ b/jenkins/run-build-packages-sso.sh
@@ -169,73 +169,9 @@ if [[ ! -d "$WORKSPACE/packages/$TARGET" ]]; then
fi
# Build the SSO server package
-
-cd "$WORKSPACE"
-
-SSO_VERSION=$(version_from_git)
-PACKAGE_NAME=arvados-sso-server
-
-if [[ ! -d "$WORKSPACE/tmp" ]]; then
- mkdir $WORKSPACE/tmp
-fi
-
-if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
- bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
-fi
-
-/usr/bin/git rev-parse HEAD > git-commit.version
-
-cd $WORKSPACE/packages/$TARGET
-
-# Annoyingly, we require a database.yml file for rake assets:precompile to work.
-
-# TODO: add bogus database.yml file so we can precompile the assets and put them in the
-# package. Then remove that database.yml file again. It has to be a valid file though.
-#RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile
-
-# There are just 2 excludes left here, all the others are pulled in via fpm-info.sh, which
-# takes .gitignore into account via a call to git status:
-#
-# 1. The .git directory is excluded by git implicitly, so we can't pick it up from .gitignore.
-# 2. The packages directory needs to be explictly excluded here because it will only be listed
-# if it exists at the time fpm-info.sh runs. If it does not exist at that time, this script
-# will create it and when fpm runs, it will include the directory. So we add it to the exclude
-# list explicitly here, just in case.
-declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward at curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados SSO server - Arvados is a free and open source platform for big data science.'" "--license='Expat License'" "-s" "dir" "-t" "$FORMAT" "-v" "$SSO_VERSION" "-x" "var/www/arvados-sso/current/.git" "-x" "var/www/arvados-sso/current/packages" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-sso-server-extras/arvados-sso-server.postinst" "--before-remove=$RUN_BUILD_PACKAGES_PATH/arvados-sso-server-extras/arvados-sso-server.prerm" "--after-remove=$RUN_BUILD_PACKAGES_PATH/arvados-sso-server-extras/arvados-sso-server.postrm" )
-
-if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
- # This is the complete package with vendor/bundle included.
- # It's big, so we do not build it by default.
- COMMAND_ARR+=("-n" "${PACKAGE_NAME}-with-bundle")
-else
- # The default package excludes vendor/bundle
- COMMAND_ARR+=("-n" "${PACKAGE_NAME}" "-x" "var/www/arvados-sso/current/vendor/bundle")
-fi
-
-# Append --depends X and other arguments specified by fpm-info.sh in
-# the package source dir. These are added last so they can override
-# the arguments added by this script.
-# `--iteration 2` accommodates a postinst change on 2015-12-10.
-declare -a fpm_args=(--iteration 2)
-declare -a fpm_depends=()
-FPM_INFO="$WORKSPACE/fpm-info.sh"
-if [[ -e "$FPM_INFO" ]]; then
- debug_echo "Loading fpm overrides from $FPM_INFO"
- source "$FPM_INFO"
-fi
-
-for i in "${fpm_depends[@]}"; do
- COMMAND_ARR+=('--depends' "$i")
-done
-COMMAND_ARR+=("${fpm_args[@]}")
-COMMAND_ARR+=("$WORKSPACE/=/var/www/arvados-sso/current")
-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
+handle_rails_package arvados-sso-server "$WORKSPACE" \
+ "$WORKSPACE/LICENCE" --url="https://arvados.org" \
+ --description="Arvados SSO server - Arvados is a free and open source platform for big data science." \
+ --license="Expat license"
exit $EXITCODE
diff --git a/jenkins/run-build-packages.sh b/jenkins/run-build-packages.sh
index c6e658c..26486e9 100755
--- a/jenkins/run-build-packages.sh
+++ b/jenkins/run-build-packages.sh
@@ -412,114 +412,47 @@ for deppkg in "${PYTHON3_BACKPORTS[@]}"; do
done
# Build the API server package
-
-cd "$WORKSPACE/services/api"
-
-API_VERSION=$(version_from_git)
-PACKAGE_NAME=arvados-api-server
-
-if [[ ! -d "$WORKSPACE/services/api/tmp" ]]; then
- mkdir $WORKSPACE/services/api/tmp
-fi
-
-
-if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
- bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
-fi
-
-/usr/bin/git rev-parse HEAD > git-commit.version
-
-cd $WORKSPACE/packages/$TARGET
-
-# Annoyingly, we require a database.yml file for rake assets:precompile to work. So for now,
-# we do that in the upgrade script.
-# TODO: add bogus database.yml file so we can precompile the assets and put them in the
-# package. Then remove that database.yml file again. It has to be a valid file though.
-#RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile
-
-# This is the complete package with vendor/bundle included.
-# It's big, so we do not build it by default.
-if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
- declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward at curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados API server - Arvados is a free and open source platform for big data science.'" "--license='GNU Affero General Public License, version 3.0'" "-s" "dir" "-t" "$FORMAT" "-n" "${PACKAGE_NAME}-with-bundle" "-v" "$API_VERSION" "--iteration" "$(default_iteration "$PACKAGE_NAME" "$API_VERSION")" "-x" "var/www/arvados-api/current/tmp" "-x" "var/www/arvados-api/current/log" "-x" "var/www/arvados-api/current/vendor/cache/*" "-x" "var/www/arvados-api/current/coverage" "-x" "var/www/arvados-api/current/Capfile*" "-x" "var/www/arvados-api/current/config/deploy*" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-api-server-extras/postinst.sh" "$WORKSPACE/services/api/=/var/www/arvados-api/current" "$RUN_BUILD_PACKAGES_PATH/arvados-api-server-extras/arvados-api-server-upgrade.sh=/usr/local/bin/arvados-api-server-upgrade.sh" "$WORKSPACE/agpl-3.0.txt=/var/www/arvados-api/current/agpl-3.0.txt")
-
- debug_echo -e "\n${COMMAND_ARR[@]}\n"
-
- FPM_RESULTS=$("${COMMAND_ARR[@]}")
- FPM_EXIT_CODE=$?
- fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
-fi
-
-# Build the 'bare' package without vendor/bundle.
-declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward at curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados API server - Arvados is a free and open source platform for big data science.'" "--license='GNU Affero General Public License, version 3.0'" "-s" "dir" "-t" "$FORMAT" "-n" "${PACKAGE_NAME}" "-v" "$API_VERSION" "--iteration" "$(default_iteration "$PACKAGE_NAME" "$API_VERSION")" "-x" "var/www/arvados-api/current/tmp" "-x" "var/www/arvados-api/current/log" "-x" "var/www/arvados-api/current/vendor/bundle" "-x" "var/www/arvados-api/current/vendor/cache/*" "-x" "var/www/arvados-api/current/coverage" "-x" "var/www/arvados-api/current/Capfile*" "-x" "var/www/arvados-api/current/config/deploy*" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-api-server-extras/postinst.sh" "$WORKSPACE/services/api/=/var/www/arvados-api/current" "$RUN_BUILD_PACKAGES_PATH/arvados-api-server-extras/arvados-api-server-upgrade.sh=/usr/local/bin/arvados-api-server-upgrade.sh" "$WORKSPACE/agpl-3.0.txt=/var/www/arvados-api/current/agpl-3.0.txt")
-
-debug_echo -e "\n${COMMAND_ARR[@]}\n"
-
-FPM_RESULTS=$("${COMMAND_ARR[@]}")
-FPM_EXIT_CODE=$?
-fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
-
-# API server package build done
+handle_rails_package arvados-api-server "$WORKSPACE/services/api" \
+ "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
+ --description="Arvados API server - Arvados is a free and open source platform for big data science." \
+ --license="GNU Affero General Public License, version 3.0"
# Build the workbench server package
+(
+ set -e
+ cd "$WORKSPACE/apps/workbench"
-cd "$WORKSPACE/apps/workbench"
-
-WORKBENCH_VERSION=$(version_from_git)
-PACKAGE_NAME=arvados-workbench
-
-if [[ ! -d "$WORKSPACE/apps/workbench/tmp" ]]; then
- mkdir $WORKSPACE/apps/workbench/tmp
-fi
-
-# We need to bundle to be ready even when we build a package without vendor directory
-# because asset compilation requires it.
-bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
+ # We need to bundle to be ready even when we build a package without vendor directory
+ # because asset compilation requires it.
+ bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
-/usr/bin/git rev-parse HEAD > git-commit.version
+ # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
+ # and we want that in the package, so it's easier to not exclude the tmp directory
+ # from the package - empty it instead.
+ rm -rf tmp
+ mkdir tmp
-# clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
-# and we want that in the package, so it's easier to not exclude the tmp directory
-# from the package - empty it instead.
-rm -rf $WORKSPACE/apps/workbench/tmp/*
+ # Set up application.yml and production.rb so that asset precompilation works
+ \cp config/application.yml.example config/application.yml -f
+ \cp config/environments/production.rb.example config/environments/production.rb -f
+ sed -i 's/secret_token: ~/secret_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/' config/application.yml
-# Set up application.yml and production.rb so that asset precompilation works
-\cp config/application.yml.example config/application.yml -f
-\cp config/environments/production.rb.example config/environments/production.rb -f
-sed -i 's/secret_token: ~/secret_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/' config/application.yml
+ RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile >/dev/null
-RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile >/dev/null
+ # Remove generated configuration files so they don't go in the package.
+ rm config/application.yml config/environments/production.rb
+)
if [[ "$?" != "0" ]]; then
echo "ERROR: Asset precompilation failed"
EXITCODE=1
+else
+ handle_rails_package arvados-workbench "$WORKSPACE/apps/workbench" \
+ "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
+ --description="Arvados Workbench - Arvados is a free and open source platform for big data science." \
+ --license="GNU Affero General Public License, version 3.0"
fi
-cd $WORKSPACE/packages/$TARGET
-
-# This is the complete package with vendor/bundle included.
-# It's big, so we do not build it by default.
-if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
-
- declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward at curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados Workbench - Arvados is a free and open source platform for big data science.'" "--license='GNU Affero General Public License, version 3.0'" "-s" "dir" "-t" "$FORMAT" "-n" "${PACKAGE_NAME}-with-bundle" "-v" "$WORKBENCH_VERSION" "--iteration" "$(default_iteration "$PACKAGE_NAME" "$WORKBENCH_VERSION")" "-x" "var/www/arvados-workbench/current/log" "-x" "var/www/arvados-workbench/current/vendor/cache/*" "-x" "var/www/arvados-workbench/current/coverage" "-x" "var/www/arvados-workbench/current/Capfile*" "-x" "var/www/arvados-workbench/current/config/deploy*" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-workbench-extras/postinst.sh" "$WORKSPACE/apps/workbench/=/var/www/arvados-workbench/current" "$RUN_BUILD_PACKAGES_PATH/arvados-workbench-extras/arvados-workbench-upgrade.sh=/usr/local/bin/arvados-workbench-upgrade.sh" "$WORKSPACE/agpl-3.0.txt=/var/www/arvados-workbench/current/agpl-3.0.txt")
-
- debug_echo -e "\n${COMMAND_ARR[@]}\n"
-
- FPM_RESULTS=$("${COMMAND_ARR[@]}")
- FPM_EXIT_CODE=$?
- fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
-fi
-
-# Build the 'bare' package without vendor/bundle.
-
-declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward at curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados Workbench - Arvados is a free and open source platform for big data science.'" "--license='GNU Affero General Public License, version 3.0'" "-s" "dir" "-t" "$FORMAT" "-n" "${PACKAGE_NAME}" "-v" "$WORKBENCH_VERSION" "--iteration" "$(default_iteration "$PACKAGE_NAME" "$WORKBENCH_VERSION")" "-x" "var/www/arvados-workbench/current/log" "-x" "var/www/arvados-workbench/current/vendor/bundle" "-x" "var/www/arvados-workbench/current/vendor/cache/*" "-x" "var/www/arvados-workbench/current/coverage" "-x" "var/www/arvados-workbench/current/Capfile*" "-x" "var/www/arvados-workbench/current/config/deploy*" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-workbench-extras/postinst.sh" "$WORKSPACE/apps/workbench/=/var/www/arvados-workbench/current" "$RUN_BUILD_PACKAGES_PATH/arvados-workbench-extras/arvados-workbench-upgrade.sh=/usr/local/bin/arvados-workbench-upgrade.sh" "$WORKSPACE/agpl-3.0.txt=/var/www/arvados-workbench/current/agpl-3.0.txt")
-
-debug_echo -e "\n${COMMAND_ARR[@]}\n"
-
-FPM_RESULTS=$("${COMMAND_ARR[@]}")
-FPM_EXIT_CODE=$?
-fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
-
-# Workbench package build done
# clean up temporary GOPATH
rm -rf "$GOPATH"
diff --git a/jenkins/run-library.sh b/jenkins/run-library.sh
index 32a6099..623e844 100755
--- a/jenkins/run-library.sh
+++ b/jenkins/run-library.sh
@@ -114,6 +114,64 @@ default_iteration() {
echo $iteration
}
+_build_rails_package_scripts() {
+ local pkgname="$1"; shift
+ local destdir="$1"; shift
+ local srcdir="$RUN_BUILD_PACKAGES_PATH/rails-package-scripts"
+ for scriptname in postinst prerm postrm; do
+ cat "$srcdir/$pkgname.sh" "$srcdir/step2.sh" "$srcdir/$scriptname.sh" \
+ >"$destdir/$scriptname" || return $?
+ done
+}
+
+handle_rails_package() {
+ local pkgname="$1"; shift
+ local srcdir="$1"; shift
+ local license_path="$1"; shift
+ local scripts_dir="$(mktemp --tmpdir -d "$pkgname-XXXXXXXX.scripts")" && \
+ local version_file="$(mktemp --tmpdir "$pkgname-XXXXXXXX.version")" && (
+ set -e
+ _build_rails_package_scripts "$pkgname" "$scripts_dir"
+ cd "$srcdir"
+ mkdir -p tmp
+ version_from_git >"$version_file"
+ git rev-parse HEAD >git-commit.version
+ if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
+ bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
+ fi
+ )
+ if [[ 0 != "$?" ]] || ! cd "$WORKSPACE/packages/$TARGET"; then
+ echo "ERROR: $pkgname package prep failed" >&2
+ rm -rf "$scripts_dir" "$version_file"
+ EXITCODE=1
+ return 1
+ fi
+ local railsdir="/var/www/${pkgname%-server}/current"
+ local -a pos_args=("$srcdir/=$railsdir" "$pkgname" "Curoverse, Inc." dir
+ "$(cat "$version_file")")
+ local license_arg="$license_path=$railsdir/$(basename "$license_path")"
+ # --iteration=3 accommodates the package scripts change from #8014.
+ local -a switches=(--iteration=3
+ --after-install "$scripts_dir/postinst"
+ --before-remove "$scripts_dir/prerm"
+ --after-remove "$scripts_dir/postrm")
+ # For some reason fpm excludes need to not start with /.
+ local exclude_root="${railsdir#/}"
+ # .git and packages are for the SSO server, which is built from its
+ # repository root.
+ for exclude in .git packages tmp log coverage \
+ vendor/cache/\* Capfile\* config/deploy\*; do
+ switches+=(-x "$exclude_root/$exclude")
+ done
+ fpm_build "${pos_args[@]}" "${switches[@]}" \
+ -x "$exclude_root/vendor/bundle" "$@" "$license_arg"
+ if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
+ posargs[1]="$pkgname-with-bundle"
+ fpm_build "${pos_args[@]}" "${switches[@]}" "$@" "$license_arg"
+ fi
+ rm -rf "$scripts_dir" "$version_file"
+}
+
# Build packages for everything
fpm_build () {
# The package source. Depending on the source type, this can be a
commit 0814135175ab777abe515e4ba404dd0bf2929b24
Author: Brett Smith <brett at curoverse.com>
Date: Fri Jan 1 19:09:08 2016 -0500
Fix quoting of local variable assignments throughout.
When you assign a variable directly (e.g., `FOO=bar`), you don't need
to quote the RHS, because the shell doesn't do expansion in that
case. But when you declare and assign a variable (e.g., `local
foo=bar`), you *do* potentially need to quote it, because `local` is a
command and all the normal expansion rules for running commands
applies.
diff --git a/jenkins/run-library.sh b/jenkins/run-library.sh
index 69ebb08..32a6099 100755
--- a/jenkins/run-library.sh
+++ b/jenkins/run-library.sh
@@ -28,7 +28,7 @@ EOF
}
format_last_commit_here() {
- local format=$1; shift
+ local format="$1"; shift
TZ=UTC git log -n1 --first-parent "--format=format:$format" .
}
@@ -59,8 +59,8 @@ handle_python_package () {
}
handle_ruby_gem() {
- local gem_name=$1; shift
- local gem_version=$(nohash_version_from_git)
+ local gem_name="$1"; shift
+ local gem_version="$(nohash_version_from_git)"
local gem_src_dir="$(pwd)"
if ! [[ -e "${gem_name}-${gem_version}.gem" ]]; then
@@ -76,7 +76,7 @@ package_go_binary() {
local src_path="$1"; shift
local prog="$1"; shift
local description="$1"; shift
- local license_file=${1:-agpl-3.0.txt}; shift
+ local license_file="${1:-agpl-3.0.txt}"; shift
debug_echo "package_go_binary $src_path as $prog"
@@ -86,8 +86,8 @@ package_go_binary() {
ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git"
cd "$GOPATH/src/git.curoverse.com/arvados.git/$src_path"
- local version=$(version_from_git)
- local timestamp=$(timestamp_from_git)
+ local version="$(version_from_git)"
+ local timestamp="$(timestamp_from_git)"
# If the command imports anything from the Arvados SDK, bump the
# version number and build a new package whenever the SDK changes.
@@ -104,8 +104,8 @@ package_go_binary() {
}
default_iteration() {
- local package_name=$1; shift
- local package_version=$1; shift
+ local package_name="$1"; shift
+ local package_version="$1"; shift
local iteration=1
if [[ $package_version =~ ^0\.1\.([0-9]{14})(\.|$) ]] && \
[[ ${BASH_REMATCH[1]} -le $LICENSE_PACKAGE_TS ]]; then
diff --git a/jenkins/run-tests.sh b/jenkins/run-tests.sh
index a7b5fda..bdf541a 100755
--- a/jenkins/run-tests.sh
+++ b/jenkins/run-tests.sh
@@ -393,7 +393,7 @@ gem_uninstall_if_exists() {
}
setup_virtualenv() {
- local venvdest=$1; shift
+ local venvdest="$1"; shift
if ! [[ -e "$venvdest/bin/activate" ]] || ! [[ -e "$venvdest/bin/pip" ]]; then
virtualenv --setuptools "$@" "$venvdest" || fatal "virtualenv $venvdest failed"
fi
commit 9f73adf4a13fef44dd133b91c46693aea1af69df
Author: Brett Smith <brett at curoverse.com>
Date: Fri Jan 1 13:38:00 2016 -0500
8014: Clean database state detection in arvados-sso postinst.
* Remove unused status code capture.
* Use `grep -q`. Previous versions of the script avoided it because
they piped directly from rake tasks, which would get upset when the
pipe broke. Now that we capture all the output, that's no longer a
concern.
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index 1ada186..e72d9b8 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -176,19 +176,15 @@ configure_version() {
chmod 644 $SHARED_PATH/log/*
echo "... done."
- set +e
- DB_MIGRATE_STATUS=`$COMMAND_PREFIX bundle exec rake db:migrate:status 2>&1`
- DB_MIGRATE_STATUS_CODE=$?
- set -e
-
- if echo $DB_MIGRATE_STATUS | grep 'Schema migrations table does not exist yet.' >/dev/null; then
+ 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 db:schema:load db:seed
- elif echo $DB_MIGRATE_STATUS | grep '^database: ' >/dev/null; then
+ 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 'database .* does not exist' >/dev/null; then
+ 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
commit c1c5b145f832bd9a647c6e07e19f148cf26ff910
Author: Brett Smith <brett at curoverse.com>
Date: Fri Jan 1 12:26:20 2016 -0500
8014: Introduce run_and_report function to arvados-sso postinst.
Use this to DRY up code that says "Doing something... done."
This commit removes some `|| exit $?` that's redundant with `set -e`.
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index 530de46..1ada186 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -54,6 +54,23 @@ For RPM-based systems, then reinstall this package.
EOF
}
+run_and_report() {
+ # Usage: run_and_report ACTION_MSG CMD
+ # This is the usual wrapper that prints ACTION_MSG, runs CMD, then writes
+ # a message about whether CMD succeeded or failed. Returns the exit code
+ # of CMD.
+ local action_message=$1; shift
+ local retcode=0
+ echo -n "$action_message..."
+ if "$@"; then
+ echo " done."
+ else
+ retcode=$?
+ echo " failed."
+ fi
+ return $retcode
+}
+
setup_conffile() {
# Usage: setup_conffile CONFFILE_PATH [SOURCE_PATH]
# Both paths are relative to RELEASE_CONFIG_PATH.
@@ -140,18 +157,12 @@ configure_version() {
cd "$RELEASE_PATH"
export RAILS_ENV=production
- echo "Making sure bundle is installed ..."
- set +e
- which bundle > /dev/null
- if [[ "$?" != "0" ]]; then
- $COMMAND_PREFIX gem install bundle
+ if ! $COMMAND_PREFIX bundle --version >/dev/null; then
+ run_and_report "Installing bundle" $COMMAND_PREFIX gem install bundle
fi
- set -e
- echo "... done."
- echo -n "Running bundle install ..."
- $COMMAND_PREFIX bundle install --path $SHARED_PATH/vendor_bundle --quiet || exit $?
- echo "... done."
+ run_and_report "Running bundle install" \
+ $COMMAND_PREFIX bundle install --path $SHARED_PATH/vendor_bundle --quiet
echo -n "Ensuring directory and file permissions ..."
# Ensure correct ownership of a few files
@@ -171,52 +182,35 @@ configure_version() {
set -e
if echo $DB_MIGRATE_STATUS | grep 'Schema migrations table does not exist yet.' >/dev/null; then
- # 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."
+ # The database exists, but the migrations table doesn't.
+ run_and_report "Setting up database" \
+ $COMMAND_PREFIX bundle exec rake db:schema:load db:seed
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."
+ run_and_report "Running db:migrate" \
+ $COMMAND_PREFIX bundle exec rake db:migrate
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
+ 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
echo "Warning: Database is not ready to set up. Skipping database setup." >&2
DATABASE_READY=0
fi
- echo -n "Precompiling assets ..."
# precompile assets; thankfully this does not take long
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
+ run_and_report "Precompiling assets" \
+ $COMMAND_PREFIX bundle exec rake assets:precompile -q -s 2>/dev/null \
+ || APPLICATION_READY=0
else
- echo "... skipped."
+ echo "Precompiling assets... skipped."
fi
chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
if [ ! -z "$WEB_SERVICE" ]; then
- echo -n "Restarting $WEB_SERVICE ..."
- service "$WEB_SERVICE" restart >/dev/null || exit $?
- echo "... done."
+ service "$WEB_SERVICE" restart
fi
}
commit 9fb392b2eaa59f20f7186de726531d922408dfa1
Author: Brett Smith <brett at curoverse.com>
Date: Fri Jan 1 12:17:01 2016 -0500
8014: Improve conffile handling in arvados-sso postinst.
* DRY it up into a function.
* DATABASE_READY and APPLICATION_READY care about whether the
corresponding .yml file is usable. Always detect when it is
unmodified from the .yml.example file.
* Build symlinks from /var/www to /etc in more cases where it's safe.
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index 3631bbe..530de46 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -4,6 +4,7 @@ set -e
INSTALL_PATH=/var/www/arvados-sso
RELEASE_PATH=$INSTALL_PATH/current
+RELEASE_CONFIG_PATH=$RELEASE_PATH/config
SHARED_PATH=$INSTALL_PATH/shared
CONFIG_PATH=/etc/arvados/sso
PACKAGE_NAME=arvados-sso-server
@@ -53,6 +54,44 @@ For RPM-based systems, then reinstall this package.
EOF
}
+setup_conffile() {
+ # Usage: setup_conffile CONFFILE_PATH [SOURCE_PATH]
+ # Both paths are relative to RELEASE_CONFIG_PATH.
+ # This function will try to safely ensure that a symbolic link for
+ # the configuration file points from RELEASE_CONFIG_PATH to CONFIG_PATH.
+ # If SOURCE_PATH is given, this function will try to install that file as
+ # the configuration file in CONFIG_PATH, and return 1 if the file in
+ # CONFIG_PATH is unmodified from the source.
+ local conffile_relpath=$1; shift
+ local conffile_source=$1; shift
+ local release_conffile=$RELEASE_CONFIG_PATH/$conffile_relpath
+ local etc_conffile=$CONFIG_PATH/$(basename "$conffile_relpath")
+
+ # Note that -h can return true and -e will return false simultaneously
+ # when the target is a dangling symlink. We're okay with that outcome,
+ # so check -h first.
+ if [ ! -h "$release_conffile" ]; then
+ if [ ! -e "$release_conffile" ]; then
+ ln -s "$etc_conffile" "$release_conffile"
+ # If there's a config file in /var/www identical to the one in /etc,
+ # overwrite it with a symlink.
+ elif cmp --quiet "$release_conffile" "$etc_conffile"; then
+ ln --force -s "$etc_conffile" "$release_conffile"
+ fi
+ fi
+
+ if [ -n "$conffile_source" ]; then
+ cp --no-clobber "$RELEASE_CONFIG_PATH/$conffile_source" "$etc_conffile"
+ # Even if $etc_conffile already existed, it might be unmodified from
+ # the source. This is especially likely when a user installs, updates
+ # database.yml, then reconfigures before they update application.yml.
+ # Use cmp to be sure whether $etc_conffile is modified.
+ if cmp --quiet "$RELEASE_CONFIG_PATH/$conffile_source" "$etc_conffile"; then
+ return 1
+ fi
+ fi
+}
+
configure_version() {
WEB_SERVICE=${WEB_SERVICE:-$(service --status-all 2>/dev/null \
| grep -Eo '\bnginx|httpd[^[:space:]]*' || true)}
@@ -85,36 +124,11 @@ configure_version() {
echo
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
- 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
-
+ mkdir -p $CONFIG_PATH
+ setup_conffile database.yml database.yml.example || DATABASE_READY=0
+ setup_conffile environments/production.rb environments/production.rb.example \
+ || true
+ setup_conffile application.yml application.yml.example || APPLICATION_READY=0
echo "... done."
# Before we do anything else, make sure some directories and files are in place
commit 1c0ce486e11b13ef5cd10959d4eca1fd948d88d1
Author: Brett Smith <brett at curoverse.com>
Date: Fri Jan 1 11:10:05 2016 -0500
8014: arvados-sso postinst recognizes versioned Nginx service names.
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index 05b331e..3631bbe 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -65,7 +65,8 @@ configure_version() {
fi
if [ -e /etc/redhat-release ]; then
- if [ "$WEB_SERVICE" = "nginx" ]; then
+ # Recognize any service that starts with "nginx"; e.g., nginx16.
+ if [ "$WEB_SERVICE" != "${WEB_SERVICE#nginx}" ]; then
WWW_OWNER=nginx:nginx
else
WWW_OWNER=apache:apache
commit 26170766797e80d0c86c25a10331f43c6d0eb283
Author: Brett Smith <brett at curoverse.com>
Date: Fri Jan 1 11:02:46 2016 -0500
8014: Refactor web service detection warnings in arvados-sso postinst.
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index ce15782..05b331e 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -37,35 +37,31 @@ EOF
fi
}
-configure_version() {
- WEB_SERVICE=${WEB_SERVICE:-$(service --status-all 2>/dev/null \
- | grep -Eo '\bnginx|httpd[^[:space:]]*' || true)}
- if [ -z "$WEB_SERVICE" ]; then
+report_web_service_warning() {
+ local warning=$1; shift
cat >&2 <<EOF
-Warning: web service (Nginx or Apache) not found.
+WARNING: $warning.
To override, set the WEB_SERVICE environment variable to the name of the service
-hosting the Rails server. Alternativey, install nginx.
+hosting the Rails server.
For Debian-based systems, then reconfigure this package with dpkg-reconfigure.
For RPM-based systems, then reinstall this package.
EOF
+}
+
+configure_version() {
+ WEB_SERVICE=${WEB_SERVICE:-$(service --status-all 2>/dev/null \
+ | grep -Eo '\bnginx|httpd[^[:space:]]*' || true)}
+ if [ -z "$WEB_SERVICE" ]; then
+ report_web_service_warning "Web service (Nginx or Apache) not found"
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.
-
-For RPM-based systems, then reinstall this package.
-
-EOF
+ report_web_service_warning \
+ "Multiple web services found. Choosing the first one ($WEB_SERVICE)"
fi
if [ -e /etc/redhat-release ]; then
commit 46ae733bd885da0d75882831af822c9578621730
Author: Brett Smith <brett at curoverse.com>
Date: Fri Jan 1 10:54:00 2016 -0500
8014: Simplify COMMAND_PREFIX-setting code.
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index f7f1ee4..ce15782 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -12,6 +12,12 @@ DOC_URL="http://doc.arvados.org/install/install-sso.html#configure"
DATABASE_READY=1
APPLICATION_READY=1
+if [ -s "$HOME/.rvm/scripts/rvm" ] || [ -s "/usr/local/rvm/scripts/rvm" ]; then
+ COMMAND_PREFIX="/usr/local/rvm/bin/rvm-exec default"
+else
+ COMMAND_PREFIX=
+fi
+
report_not_ready() {
local ready_flag=$1; shift
local config_file=$1; shift
@@ -31,22 +37,6 @@ EOF
fi
}
-setup_ruby_environment() {
- if [ -s "$HOME/.rvm/scripts/rvm" ] ; then
- using_rvm="true"
- elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then
- using_rvm="true"
- else
- using_rvm="false"
- fi
-
- if [ "$using_rvm" = "true" ]; then
- COMMAND_PREFIX="/usr/local/rvm/bin/rvm-exec default"
- else
- COMMAND_PREFIX=
- fi
-}
-
configure_version() {
WEB_SERVICE=${WEB_SERVICE:-$(service --status-all 2>/dev/null \
| grep -Eo '\bnginx|httpd[^[:space:]]*' || true)}
@@ -221,11 +211,9 @@ EOF
if [ "$1" = configure ]; then
# This is a debian-based system
- setup_ruby_environment
configure_version
elif [ "$1" = "0" ] || [ "$1" = "1" ] || [ "$1" = "2" ]; then
# This is an rpm-based system
- setup_ruby_environment
configure_version
fi
commit 2bee50fa0b09c9dd785fe6d6beafe21fa961111d
Author: Brett Smith <brett at curoverse.com>
Date: Fri Jan 1 10:51:01 2016 -0500
8014: Refactor "not fully configured" messages in arvados-sso postinst.
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index 070796e..f7f1ee4 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -7,10 +7,30 @@ RELEASE_PATH=$INSTALL_PATH/current
SHARED_PATH=$INSTALL_PATH/shared
CONFIG_PATH=/etc/arvados/sso
PACKAGE_NAME=arvados-sso-server
+DOC_URL="http://doc.arvados.org/install/install-sso.html#configure"
DATABASE_READY=1
APPLICATION_READY=1
+report_not_ready() {
+ local ready_flag=$1; shift
+ local config_file=$1; shift
+ if [ "1" != "$ready_flag" ]; then cat >&2 <<EOF
+
+PLEASE NOTE:
+
+The $PACKAGE_NAME package was not configured completely because
+$config_file needs some tweaking.
+Please refer to the documentation at
+<$DOC_URL> for more details.
+
+When $(basename "$config_file") has been modified,
+reconfigure or reinstall this package.
+
+EOF
+ fi
+}
+
setup_ruby_environment() {
if [ -s "$HOME/.rvm/scripts/rvm" ] ; then
using_rvm="true"
@@ -209,32 +229,5 @@ elif [ "$1" = "0" ] || [ "$1" = "1" ] || [ "$1" = "2" ]; then
configure_version
fi
-if [ "$DATABASE_READY" = "0" ]; then
- cat <<EOF
-
-PLEASE NOTE:
-
-The $PACKAGE_NAME package was not configured completely because
-$CONFIG_PATH/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 $PACKAGE_NAME package was not configured completely because
-$CONFIG_PATH/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
+report_not_ready "$DATABASE_READY" "$CONFIG_PATH/database.yml"
+report_not_ready "$APPLICATION_READY" "$CONFIG_PATH/application.yml"
commit 33f530c93b5bd397c6c9569385613915acf4cdbb
Author: Brett Smith <brett at curoverse.com>
Date: Fri Jan 1 10:41:23 2016 -0500
8014: Remove unused $VERSION tracking from arvados-sso postinst.
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
index 7423e5b..070796e 100755
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server.postinst
@@ -11,8 +11,6 @@ PACKAGE_NAME=arvados-sso-server
DATABASE_READY=1
APPLICATION_READY=1
-VERSION=`cat $RELEASE_PATH/git-commit.version`
-
setup_ruby_environment() {
if [ -s "$HOME/.rvm/scripts/rvm" ] ; then
using_rvm="true"
@@ -29,12 +27,7 @@ setup_ruby_environment() {
fi
}
-# arguments: <major version> <most recently configured package version>
configure_version() {
- VERSION="$1"
-
- [ "$VERSION" ] || { echo "Error: configure_version: need version parameter" >&2; exit 1; }
-
WEB_SERVICE=${WEB_SERVICE:-$(service --status-all 2>/dev/null \
| grep -Eo '\bnginx|httpd[^[:space:]]*' || true)}
if [ -z "$WEB_SERVICE" ]; then
@@ -209,11 +202,11 @@ EOF
if [ "$1" = configure ]; then
# This is a debian-based system
setup_ruby_environment
- configure_version $VERSION "$2"
+ configure_version
elif [ "$1" = "0" ] || [ "$1" = "1" ] || [ "$1" = "2" ]; then
# This is an rpm-based system
setup_ruby_environment
- configure_version $VERSION
+ configure_version
fi
if [ "$DATABASE_READY" = "0" ]; then
commit 4735c45083770bf8344dd80dd84695bb4e0fd169
Author: Brett Smith <brett at curoverse.com>
Date: Thu Dec 31 15:58:18 2015 -0500
8014: Remove unused sso-server-upgrade.sh script.
diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server-upgrade.sh b/jenkins/arvados-sso-server-extras/arvados-sso-server-upgrade.sh
deleted file mode 100755
index 1a377dc..0000000
--- a/jenkins/arvados-sso-server-extras/arvados-sso-server-upgrade.sh
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/bash
-
-set -e
-
-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
-
-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.
-Set NGINX_SERVICE to the name of the service hosting the Rails server.
-EOF
- exit 1
-elif [ "$NGINX_SERVICE" != "$(echo "$NGINX_SERVICE" | head -n 1)" ]; then
- cat >&2 <<EOF
-Error: multiple nginx services found. Aborting.
-Set NGINX_SERVICE to the name of the service hosting the Rails server.
-EOF
- exit 1
-fi
-
-RELEASE_PATH=/var/www/arvados-sso/current
-SHARED_PATH=/var/www/arvados-sso/shared
-CONFIG_PATH=/etc/arvados/sso/
-
-echo
-echo "Assumption: $NGINX_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
-
-echo "Copying files from $CONFIG_PATH ..."
-cp -f $CONFIG_PATH/database.yml $RELEASE_PATH/config/database.yml
-cp -f $RELEASE_PATH/config/environments/production.rb.example $RELEASE_PATH/config/environments/production.rb
-cp -f $CONFIG_PATH/application.yml $RELEASE_PATH/config/application.yml
-echo "... done."
-
-# Before we do anything else, make sure some directories and files are in place
-if [[ ! -e $SHARED_PATH/log ]]; then mkdir -p $SHARED_PATH/log; fi
-if [[ ! -e $RELEASE_PATH/tmp ]]; then mkdir -p $RELEASE_PATH/tmp; fi
-if [[ ! -e $RELEASE_PATH/log ]]; then ln -s $SHARED_PATH/log $RELEASE_PATH/log; fi
-if [[ ! -e $SHARED_PATH/log/production.log ]]; then touch $SHARED_PATH/log/production.log; fi
-
-cd "$RELEASE_PATH"
-export RAILS_ENV=production
-
-echo "Running bundle install ..."
-bundle install --path $SHARED_PATH/vendor_bundle --quiet
-echo "... done."
-
-echo "Ensuring directory and file permissions ..."
-# Ensure correct ownership of a few files
-chown "$WWW_OWNER" $RELEASE_PATH/config/environment.rb
-chown "$WWW_OWNER" $RELEASE_PATH/config.ru
-chown "$WWW_OWNER" $RELEASE_PATH/config/database.yml
-chown "$WWW_OWNER" $RELEASE_PATH/Gemfile.lock
-chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
-chown -R "$WWW_OWNER" $SHARED_PATH/log
-chown "$WWW_OWNER" $RELEASE_PATH/db/schema.rb
-chmod 644 $SHARED_PATH/log/*
-echo "... done."
-
-# If we use `grep -q`, rake will write a backtrace on EPIPE.
-if bundle exec rake db:migrate:status | grep '^database: ' >/dev/null; then
- echo "Starting db:migrate ..."
- bundle exec rake db:migrate
-elif [ 0 -eq ${PIPESTATUS[0]} ]; then
- # The database exists, but the migrations table doesn't.
- echo "Setting up database ..."
- bundle exec rake db:schema:load db:seed
-else
- echo "Error: Database is not ready to set up. Aborting." >&2
- exit 1
-fi
-echo "... done."
-
-echo "Precompiling assets ..."
-# precompile assets; thankfully this does not take long
-bundle exec rake assets:precompile -q -s
-echo "... done."
-
-echo "Restarting nginx ..."
-service "$NGINX_SERVICE" restart
-echo "... done."
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list