5 if [ -e /etc/redhat-release ]; then
8 # Assume we're on a Debian-based system for now.
9 WWW_OWNER=www-data:www-data
12 NGINX_SERVICE=${NGINX_SERVICE:-$(service --status-all 2>/dev/null \
13 | grep -Eo '\bnginx[^[:space:]]*' || true)}
14 if [ -z "$NGINX_SERVICE" ]; then
16 Error: nginx service not found. Aborting.
17 Set NGINX_SERVICE to the name of the service hosting the Rails server.
20 elif [ "$NGINX_SERVICE" != "$(echo "$NGINX_SERVICE" | head -n 1)" ]; then
22 Error: multiple nginx services found. Aborting.
23 Set NGINX_SERVICE to the name of the service hosting the Rails server.
28 RELEASE_PATH=/var/www/arvados-workbench/current
29 SHARED_PATH=/var/www/arvados-workbench/shared
30 CONFIG_PATH=/etc/arvados/workbench/
32 echo "Assumption: $NGINX_SERVICE is configured to serve your workbench URL from "
33 echo " /var/www/arvados-workbench/current"
34 echo "Assumption: configuration files are in /etc/arvados/workbench/"
35 echo "Assumption: $NGINX_SERVICE and passenger run as $WWW_OWNER"
38 echo "Copying files from $CONFIG_PATH"
39 cp -f $CONFIG_PATH/application.yml $RELEASE_PATH/config/application.yml
40 cp -f $RELEASE_PATH/config/environments/production.rb.example $RELEASE_PATH/config/environments/production.rb
43 # Before we do anything else, make sure some directories and files are in place
44 if [[ ! -e $SHARED_PATH/log ]]; then mkdir -p $SHARED_PATH/log; fi
45 if [[ ! -e $RELEASE_PATH/tmp ]]; then mkdir -p $RELEASE_PATH/tmp; fi
46 if [[ ! -e $RELEASE_PATH/log ]]; then ln -s $SHARED_PATH/log $RELEASE_PATH/log; fi
47 if [[ ! -e $SHARED_PATH/log/production.log ]]; then touch $SHARED_PATH/log/production.log; fi
49 echo "Running bundle install"
50 (cd $RELEASE_PATH && RAILS_ENV=production bundle install --path $SHARED_PATH/vendor_bundle)
53 # We do not need to precompile assets, they are already part of the package.
55 echo "Ensuring directory and file permissions"
56 chown "$WWW_OWNER" $RELEASE_PATH/config/environment.rb
57 chown "$WWW_OWNER" $RELEASE_PATH/config.ru
58 chown "$WWW_OWNER" $RELEASE_PATH/config/database.yml
59 chown "$WWW_OWNER" $RELEASE_PATH/Gemfile.lock
60 chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
61 chown -R "$WWW_OWNER" $SHARED_PATH/log
62 chown "$WWW_OWNER" $RELEASE_PATH/db/schema.rb
63 chmod 644 $SHARED_PATH/log/*
66 echo "Running sanity check"
67 (cd $RELEASE_PATH && RAILS_ENV=production bundle exec rake config:check)
68 SANITY_CHECK_EXIT_CODE=$?
71 if [[ "$SANITY_CHECK_EXIT_CODE" != "0" ]]; then
72 echo "Sanity check failed, aborting. Please roll back to the previous version of the package."
73 exit $SANITY_CHECK_EXIT_CODE
76 # We do not need to run db:migrate because Workbench is stateless
78 echo "Restarting nginx"
79 service "$NGINX_SERVICE" restart