6 . /usr/local/lib/arvbox/common.sh
9 export RAILS_ENV=development
11 run_bundler --without=development
12 bundle exec passenger start --runtime-check-only --runtime-dir=/var/lib/passenger
14 if test "$1" = "--only-deps" ; then
20 if ! test -s /var/lib/arvados/sso_uuid_prefix ; then
21 ruby -e 'puts "#{rand(2**64).to_s(36)[0,5]}"' > /var/lib/arvados/sso_uuid_prefix
23 uuid_prefix=$(cat /var/lib/arvados/sso_uuid_prefix)
25 if ! test -s /var/lib/arvados/sso_secret_token ; then
26 ruby -e 'puts rand(2**400).to_s(36)' > /var/lib/arvados/sso_secret_token
28 secret_token=$(cat /var/lib/arvados/sso_secret_token)
30 if ! test -s /var/lib/arvados/self-signed.key ; then
31 openssl req -new -x509 -nodes -out /var/lib/arvados/self-signed.pem -keyout /var/lib/arvados/self-signed.key -days 365 -subj '/CN=localhost'
34 cat >config/application.yml <<EOF
36 uuid_prefix: $uuid_prefix
37 secret_token: $secret_token
38 default_link_url: "http://$localip"
39 allow_account_registration: true
42 if ! test -f /var/lib/arvados/sso_database_pw ; then
43 ruby -e 'puts rand(2**128).to_s(36)' > /var/lib/arvados/sso_database_pw
45 database_pw=$(cat /var/lib/arvados/sso_database_pw)
47 if ! (psql postgres -c "\du" | grep "^ arvados_sso ") >/dev/null ; then
48 psql postgres -c "create user arvados_sso with password '$database_pw'"
49 psql postgres -c "ALTER USER arvados_sso CREATEDB;"
52 sed "s/password:.*/password: $database_pw/" <config/database.yml.example >config/database.yml
54 if ! test -f /var/lib/arvados/sso_database_setup ; then
55 bundle exec rake db:setup
57 if ! test -s /var/lib/arvados/sso_app_secret ; then
58 ruby -e 'puts rand(2**400).to_s(36)' > /var/lib/arvados/sso_app_secret
60 app_secret=$(cat /var/lib/arvados/sso_app_secret)
62 bundle exec rails console <<EOF
65 c.app_id = "arvados-server"
66 c.app_secret = "$app_secret"
70 touch /var/lib/arvados/sso_database_setup
75 bundle exec rake db:migrate
78 if test "$1" = "--only-setup" ; then
82 exec bundle exec passenger start --port=${services[sso]} \
83 --runtime-dir=/var/lib/passenger \
84 --ssl --ssl-certificate=/var/lib/arvados/self-signed.pem \
85 --ssl-certificate-key=/var/lib/arvados/self-signed.key