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 # postgres packaging on CentOS6 is kind of primitive, needs an initdb
79 service postgresql initdb
80 if [ "$TARGET" = "centos6" ]; then
81 sed -i -e "s/127.0.0.1\/32 ident/127.0.0.1\/32 md5/" /var/lib/pgsql/data/pg_hba.conf
82 sed -i -e "s/::1\/128 ident/::1\/128 md5/" /var/lib/pgsql/data/pg_hba.conf
85 service postgresql start
87 RANDOM_PASSWORD=`date | md5sum |cut -f1 -d' '`
88 cat >/etc/arvados/sso/database.yml <<EOF
92 database: sso_provider_production
93 username: sso_provider_user
94 password: $RANDOM_PASSWORD
98 su postgres -c "psql -c \"CREATE USER sso_provider_user WITH PASSWORD '$RANDOM_PASSWORD'\""
99 su postgres -c "createdb sso_provider_production -O sso_provider_user"
102 if [[ "$FORMAT" == "deb" ]]; then
103 # Test 2: the package should reconfigure cleanly
104 dpkg-reconfigure arvados-sso-server || EXITCODE=3
106 cd /var/www/arvados-sso/current/
107 /usr/local/rvm/bin/rvm-exec default bundle list >"$ARV_PACKAGES_DIR/arvados-sso-server.gems"
109 # Test 3: the package should remove cleanly
110 apt-get remove arvados-sso-server --yes || EXITCODE=3
112 checkexit $EXITCODE "apt-get remove arvados-sso-server --yes"
114 # Test 4: the package configuration should remove cleanly
115 dpkg --purge arvados-sso-server || EXITCODE=4
117 checkexit $EXITCODE "dpkg --purge arvados-sso-server"
119 if [[ -e "/var/www/arvados-sso" ]]; then
123 checkexit $EXITCODE "leftover items under /var/www/arvados-sso"
125 # Test 5: the package should remove cleanly with --purge
127 apt-get remove arvados-sso-server --purge --yes || EXITCODE=5
129 checkexit $EXITCODE "apt-get remove arvados-sso-server --purge --yes"
131 if [[ -e "/var/www/arvados-sso" ]]; then
135 checkexit $EXITCODE "leftover items under /var/www/arvados-sso"
137 elif [[ "$FORMAT" == "rpm" ]]; then
140 # (courtesy of https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/el6/install_passenger.html)
141 yum install -q -y epel-release pygpgme curl
142 curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
143 yum install -q -y nginx passenger
144 sed -i -e 's/^# passenger/passenger/' /etc/nginx/conf.d/passenger.conf
145 # Done setting up Nginx
147 # Test 2: the package should reinstall cleanly
148 yum --assumeyes reinstall arvados-sso-server || EXITCODE=3
150 cd /var/www/arvados-sso/current/
151 /usr/local/rvm/bin/rvm-exec default bundle list >$ARV_PACKAGES_DIR/arvados-sso-server.gems
153 # Test 3: the package should remove cleanly
154 yum -q -y remove arvados-sso-server || EXITCODE=3
156 checkexit $EXITCODE "yum -q -y remove arvados-sso-server"
158 if [[ -e "/var/www/arvados-sso" ]]; then
162 checkexit $EXITCODE "leftover items under /var/www/arvados-sso"
166 if [[ "$EXITCODE" == "0" ]]; then
167 echo "Testing complete, no errors!"
169 echo "Errors while testing!"