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
18 # The example config you want to use. Currently, only "single_host" is
20 CONFIG_DIR="single_host"
22 # Which release of Arvados repo you want to use
24 # Which version of Arvados you want to install. Defaults to 'latest'
28 # Host SSL port where you want to point your browser to access Arvados
29 # Defaults to 443 for regular runs, and to 8443 when called in Vagrant.
30 # You can point it to another port if desired
31 # In Vagrant, make sure it matches what you set in the Vagrantfile
34 # This is a arvados-formula setting.
35 # If branch is set, the script will switch to it before running salt
36 # Usually not needed, only used for testing
39 ##########################################################
40 # Usually there's no need to modify things below this line
46 echo >&2 "Usage: $0 [-h] [-h]"
48 echo >&2 "$0 options:"
49 echo >&2 " -v, --vagrant Run in vagrant and use the /vagrant shared dir"
50 echo >&2 " -p <N>, --ssl-port <N> SSL port to use for the web applications"
51 echo >&2 " -h, --help Display this help and exit"
56 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
57 TEMP=`getopt -o hvp: \
58 --long help,vagrant,ssl-port: \
61 if [ $? != 0 ] ; then echo "GNU getopt missing? Use -h for help"; exit 1 ; fi
62 # Note the quotes around `$TEMP': they are essential!
65 while [ $# -ge 1 ]; do
100 apt-get install -y curl git
102 dpkg -l |grep salt-minion
103 if [ ${?} -eq 0 ]; then
104 echo "Salt already installed"
106 curl -L https://bootstrap.saltstack.com -o /tmp/bootstrap_salt.sh
107 sh /tmp/bootstrap_salt.sh -XUdfP -x python3
108 /bin/systemctl disable salt-minion.service
111 # Set salt to masterless mode
112 cat > /etc/salt/minion << EOFSM
118 - ${F_DIR}/*/test/salt/states
130 cat > ${S_DIR}/top.sls << EOFTSLS
133 - example_add_snakeoil_certs
142 cat > ${P_DIR}/top.sls << EOFPSLS
147 - nginx_api_configuration
148 - nginx_controller_configuration
149 - nginx_keepproxy_configuration
150 - nginx_keepweb_configuration
152 - nginx_websocket_configuration
153 - nginx_webshell_configuration
154 - nginx_workbench2_configuration
155 - nginx_workbench_configuration
160 # Get the formula and dependencies
161 cd ${F_DIR} || exit 1
162 for f in postgres arvados nginx docker locale; do
163 # git clone https://github.com/saltstack-formulas/${f}-formula.git
164 git clone https://github.com/netmanagers/${f}-formula.git
167 if [ "x${BRANCH}" != "x" ]; then
168 cd ${F_DIR}/arvados-formula
169 git checkout -t origin/${BRANCH}
173 # sed "s/__DOMAIN__/${DOMAIN}/g; s/__CLUSTER__/${CLUSTER}/g; s/__RELEASE__/${RELEASE}/g; s/__VERSION__/${VERSION}/g" \
174 # ${CONFIG_DIR}/arvados_dev.sls > ${P_DIR}/arvados.sls
176 if [ "x${VAGRANT}" = "xyes" ]; then
177 SOURCE_PILLARS_DIR="/vagrant/${CONFIG_DIR}"
179 SOURCE_PILLARS_DIR="./${CONFIG_DIR}"
182 # Replace cluster and domain name in the example pillars
183 for f in ${SOURCE_PILLARS_DIR}/*; do
184 # sed "s/example.net/${DOMAIN}/g; s/fixme/${CLUSTER}/g" \
185 sed "s/__DOMAIN__/${DOMAIN}/g;
186 s/__CLUSTER__/${CLUSTER}/g;
187 s/__RELEASE__/${RELEASE}/g;
188 s/__HOST_SSL_PORT__/${HOST_SSL_PORT}/g;
189 s/__GUEST_SSL_PORT__/${GUEST_SSL_PORT}/g;
190 s/__VERSION__/${VERSION}/g" \
191 ${f} > ${P_DIR}/$(basename ${f})
194 # Let's write an /etc/hosts file that points all the hosts to localhost
196 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
198 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
199 if [ -e /root/.psqlrc ]; then
200 if ! ( grep 'pset pager off' /root/.psqlrc ); then
202 cp /root/.psqlrc /root/.psqlrc.provision.backup
208 echo '\pset pager off' >> /root/.psqlrc
209 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server
211 # Now run the install
212 salt-call --local state.apply -l debug
214 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
215 if [ "x${DELETE_PSQL}" = "xyes" ]; then
216 echo "Removing .psql file"
220 if [ "x${RESTORE_PSQL}" = "xyes" ]; then
221 echo "Restroting .psql file"
222 mv -v /root/.psqlrc.provision.backup /root/.psqlrc
224 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server