6 DEBUG=${ARVADOS_DEBUG:-0}
8 STDOUT_IF_DEBUG=/dev/null
9 STDERR_IF_DEBUG=/dev/null
11 if [[ "$DEBUG" != 0 ]]; then
12 STDOUT_IF_DEBUG=/dev/stdout
13 STDERR_IF_DEBUG=/dev/stderr
25 echo -e "$0: Unknown target '$TARGET'.\n" >&2
30 if ! [[ -n "$WORKSPACE" ]]; then
31 echo >&2 "$helpmessage"
33 echo >&2 "Error: WORKSPACE environment variable not set"
38 if ! [[ -d "$WORKSPACE" ]]; then
39 echo >&2 "$helpmessage"
41 echo >&2 "Error: $WORKSPACE is not a directory"
47 txt="********** $1 **********"
48 printf "\n%*s%s\n\n" $((($COLUMNS-${#txt})/2)) "" "$txt"
52 if [[ "$1" != "0" ]]; then
53 title "!!!!!! $2 FAILED !!!!!!"
58 # Find the SSO server package
62 if [[ ! -d "/var/www/arvados-sso" ]]; then
63 echo "/var/www/arvados-sso should exist"
67 if [[ ! -e "/etc/arvados/sso/application.yml" ]]; then
68 mkdir -p /etc/arvados/sso/
69 RANDOM_PASSWORD=`date | md5sum |cut -f1 -d' '`
70 cp config/application.yml.example /etc/arvados/sso/application.yml
71 sed -i -e 's/uuid_prefix: ~/uuid_prefix: zzzzz/' /etc/arvados/sso/application.yml
72 sed -i -e "s/secret_token: ~/secret_token: $RANDOM_PASSWORD/" /etc/arvados/sso/application.yml
75 if [[ ! -e "/etc/arvados/sso/database.yml" ]]; then
76 # We need to set up our database configuration now.
77 if [[ "$FORMAT" == "rpm" ]]; then
78 service postgresql initdb
79 sed -i -e "s/127.0.0.1\/32 ident/127.0.0.1\/32 md5/" /var/lib/pgsql/data/pg_hba.conf
80 sed -i -e "s/::1\/128 ident/::1\/128 md5/" /var/lib/pgsql/data/pg_hba.conf
82 service postgresql start
84 RANDOM_PASSWORD=`date | md5sum |cut -f1 -d' '`
85 cat >/etc/arvados/sso/database.yml <<EOF
89 database: sso_provider_production
90 username: sso_provider_user
91 password: $RANDOM_PASSWORD
95 su postgres -c "psql -c \"CREATE USER sso_provider_user WITH PASSWORD '$RANDOM_PASSWORD'\""
96 su postgres -c "createdb sso_provider_production -O sso_provider_user"
99 if [[ "$FORMAT" == "deb" ]]; then
100 # Test 2: the package should reconfigure cleanly
101 dpkg-reconfigure arvados-sso-server || EXITCODE=3
103 cd /var/www/arvados-sso/current/
104 /usr/local/rvm/bin/rvm-exec default bundle list >"$ARV_PACKAGES_DIR/arvados-sso-server.gems"
106 # Test 3: the package should remove cleanly
107 apt-get remove arvados-sso-server --yes || EXITCODE=3
109 checkexit $EXITCODE "apt-get remove arvados-sso-server --yes"
111 # Test 4: the package configuration should remove cleanly
112 dpkg --purge arvados-sso-server || EXITCODE=4
114 checkexit $EXITCODE "dpkg --purge arvados-sso-server"
116 if [[ -e "/var/www/arvados-sso" ]]; then
120 checkexit $EXITCODE "leftover items under /var/www/arvados-sso"
122 # Test 5: the package should remove cleanly with --purge
124 apt-get remove arvados-sso-server --purge --yes || EXITCODE=5
126 checkexit $EXITCODE "apt-get remove arvados-sso-server --purge --yes"
128 if [[ -e "/var/www/arvados-sso" ]]; then
132 checkexit $EXITCODE "leftover items under /var/www/arvados-sso"
134 elif [[ "$FORMAT" == "rpm" ]]; then
137 # (courtesy of https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/el6/install_passenger.html)
138 yum install -q -y epel-release pygpgme curl
139 curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
140 yum install -q -y nginx passenger
141 sed -i -e 's/^# passenger/passenger/' /etc/nginx/conf.d/passenger.conf
142 # Done setting up Nginx
144 # Test 2: the package should reinstall cleanly
145 yum --assumeyes reinstall arvados-sso-server || EXITCODE=3
147 cd /var/www/arvados-sso/current/
148 /usr/local/rvm/bin/rvm-exec default bundle list >$ARV_PACKAGES_DIR/arvados-sso-server.gems
150 # Test 3: the package should remove cleanly
151 yum -q -y remove arvados-sso-server || EXITCODE=3
153 checkexit $EXITCODE "yum -q -y remove arvados-sso-server"
155 if [[ -e "/var/www/arvados-sso" ]]; then
159 checkexit $EXITCODE "leftover items under /var/www/arvados-sso"
163 if [[ "$EXITCODE" == "0" ]]; then
164 echo "Testing complete, no errors!"
166 echo "Errors while testing!"