[ "$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 ..."
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
-
-
}
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
-
-
-
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
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
FPM_RESULTS=$("${COMMAND_ARR[@]}")
FPM_EXIT_CODE=$?
+
fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
# SSO server package build done
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
+}
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"
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
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' '`
$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
fi
+echo "Testing complete, no errors!"
+
exit $EXITCODE