3 # Copyright (C) The Arvados Authors. All rights reserved.
5 # SPDX-License-Identifier: CC-BY-SA-3.0
7 # If you want to test arvados in a single host, you can run this script, which
8 # will install it using salt masterless
9 # This script is run by the Vagrant file when you run it with
13 ##########################################################
14 # The 5 letters name you want to give your cluster
20 # If not specified, the initial user email will be composed as
21 # INITIAL_USER@CLUSTER.DOMAIN
22 INITIAL_USER_EMAIL="${INITIAL_USER}@${CLUSTER}.${DOMAIN}"
23 INITIAL_USER_PASSWORD="password"
25 # The example config you want to use. Currently, only "single_host" is
27 CONFIG_DIR="single_host"
29 # Which release of Arvados repo you want to use
31 # Which version of Arvados you want to install. Defaults to 'latest'
35 # Host SSL port where you want to point your browser to access Arvados
36 # Defaults to 443 for regular runs, and to 8443 when called in Vagrant.
37 # You can point it to another port if desired
38 # In Vagrant, make sure it matches what you set in the Vagrantfile
41 # This is a arvados-formula setting.
42 # If branch is set, the script will switch to it before running salt
43 # Usually not needed, only used for testing
46 ##########################################################
47 # Usually there's no need to modify things below this line
53 echo >&2 "Usage: $0 [-h] [-h]"
55 echo >&2 "$0 options:"
56 echo >&2 " -v, --vagrant Run in vagrant and use the /vagrant shared dir"
57 echo >&2 " -p <N>, --ssl-port <N> SSL port to use for the web applications"
58 echo >&2 " -h, --help Display this help and exit"
63 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
64 TEMP=`getopt -o hvp: \
65 --long help,vagrant,ssl-port: \
68 if [ $? != 0 ] ; then echo "GNU getopt missing? Use -h for help"; exit 1 ; fi
69 # Note the quotes around `$TEMP': they are essential!
72 while [ $# -ge 1 ]; do
102 F_DIR="/srv/formulas"
107 apt-get install -y curl git
109 dpkg -l |grep salt-minion
110 if [ ${?} -eq 0 ]; then
111 echo "Salt already installed"
113 curl -L https://bootstrap.saltstack.com -o /tmp/bootstrap_salt.sh
114 sh /tmp/bootstrap_salt.sh -XUdfP -x python3
115 /bin/systemctl disable salt-minion.service
118 # Set salt to masterless mode
119 cat > /etc/salt/minion << EOFSM
125 - ${F_DIR}/*/test/salt/states
137 cat > ${S_DIR}/top.sls << EOFTSLS
140 - example_add_snakeoil_certs
149 cat > ${P_DIR}/top.sls << EOFPSLS
154 - nginx_api_configuration
155 - nginx_controller_configuration
156 - nginx_keepproxy_configuration
157 - nginx_keepweb_configuration
159 - nginx_websocket_configuration
160 - nginx_webshell_configuration
161 - nginx_workbench2_configuration
162 - nginx_workbench_configuration
167 # Get the formula and dependencies
168 cd ${F_DIR} || exit 1
169 for f in postgres arvados nginx docker locale; do
170 # git clone https://github.com/saltstack-formulas/${f}-formula.git
171 git clone https://github.com/netmanagers/${f}-formula.git
174 if [ "x${BRANCH}" != "x" ]; then
175 cd ${F_DIR}/arvados-formula
176 git checkout -t origin/${BRANCH}
180 # sed "s/__DOMAIN__/${DOMAIN}/g; s/__CLUSTER__/${CLUSTER}/g; s/__RELEASE__/${RELEASE}/g; s/__VERSION__/${VERSION}/g" \
181 # ${CONFIG_DIR}/arvados_dev.sls > ${P_DIR}/arvados.sls
183 if [ "x${VAGRANT}" = "xyes" ]; then
184 SOURCE_PILLARS_DIR="/vagrant/${CONFIG_DIR}"
186 SOURCE_PILLARS_DIR="./${CONFIG_DIR}"
189 # Replace cluster and domain name in the example pillars
190 for f in ${SOURCE_PILLARS_DIR}/*; do
191 # sed "s/example.net/${DOMAIN}/g; s/fixme/${CLUSTER}/g" \
192 sed "s/__DOMAIN__/${DOMAIN}/g;
193 s/__CLUSTER__/${CLUSTER}/g;
194 s/__RELEASE__/${RELEASE}/g;
195 s/__HOST_SSL_PORT__/${HOST_SSL_PORT}/g;
196 s/__GUEST_SSL_PORT__/${GUEST_SSL_PORT}/g;
197 s/__INITIAL_USER__/${INITIAL_USER}/g;
198 s/__INITIAL_USER_EMAIL__/${INITIAL_USER_EMAIL}/g;
199 s/__INITIAL_USER_PASSWORD__/${INITIAL_USER_PASSWORD}/g;
200 s/__VERSION__/${VERSION}/g" \
201 ${f} > ${P_DIR}/$(basename ${f})
204 # Let's write an /etc/hosts file that points all the hosts to localhost
206 echo "127.0.0.2 api keep keep0 collections download ws workbench workbench2 ${CLUSTER}.${DOMAIN} api.${CLUSTER}.${DOMAIN} keep.${CLUSTER}.${DOMAIN} keep0.${CLUSTER}.${DOMAIN} collections.${CLUSTER}.${DOMAIN} download.${CLUSTER}.${DOMAIN} ws.${CLUSTER}.${DOMAIN} workbench.${CLUSTER}.${DOMAIN} workbench2.${CLUSTER}.${DOMAIN}" >> /etc/hosts
208 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
209 if [ -e /root/.psqlrc ]; then
210 if ! ( grep 'pset pager off' /root/.psqlrc ); then
212 cp /root/.psqlrc /root/.psqlrc.provision.backup
218 echo '\pset pager off' >> /root/.psqlrc
219 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server
221 # Now run the install
222 salt-call --local state.apply -l debug
224 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
225 if [ "x${DELETE_PSQL}" = "xyes" ]; then
226 echo "Removing .psql file"
230 if [ "x${RESTORE_PSQL}" = "xyes" ]; then
231 echo "Restroting .psql file"
232 mv -v /root/.psqlrc.provision.backup /root/.psqlrc
234 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server