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 # This section are the basic parameters to configure the installation
16 # The 5 letters name you want to give your cluster
22 # If not specified, the initial user email will be composed as
23 # INITIAL_USER@CLUSTER.DOMAIN
24 INITIAL_USER_EMAIL="${INITIAL_USER}@${CLUSTER}.${DOMAIN}"
25 INITIAL_USER_PASSWORD="password"
27 # The example config you want to use. Currently, only "single_host" is
29 CONFIG_DIR="single_host"
31 # Which release of Arvados repo you want to use
33 # Which version of Arvados you want to install. Defaults to 'latest'
37 # Host SSL port where you want to point your browser to access Arvados
38 # Defaults to 443 for regular runs, and to 8443 when called in Vagrant.
39 # You can point it to another port if desired
40 # In Vagrant, make sure it matches what you set in the Vagrantfile
43 # This is a arvados-formula setting.
44 # If branch is set, the script will switch to it before running salt
45 # Usually not needed, only used for testing
48 ##########################################################
49 # Usually there's no need to modify things below this line
55 echo >&2 "Usage: $0 [-h] [-h]"
57 echo >&2 "$0 options:"
58 echo >&2 " -v, --vagrant Run in vagrant and use the /vagrant shared dir"
59 echo >&2 " -p <N>, --ssl-port <N> SSL port to use for the web applications"
60 echo >&2 " -h, --help Display this help and exit"
65 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
66 TEMP=`getopt -o hvp: \
67 --long help,vagrant,ssl-port: \
70 if [ $? != 0 ] ; then echo "GNU getopt missing? Use -h for help"; exit 1 ; fi
71 # Note the quotes around `$TEMP': they are essential!
74 while [ $# -ge 1 ]; do
104 F_DIR="/srv/formulas"
109 apt-get install -y curl git
111 dpkg -l |grep salt-minion
112 if [ ${?} -eq 0 ]; then
113 echo "Salt already installed"
115 curl -L https://bootstrap.saltstack.com -o /tmp/bootstrap_salt.sh
116 sh /tmp/bootstrap_salt.sh -XUdfP -x python3
117 /bin/systemctl disable salt-minion.service
120 # Set salt to masterless mode
121 cat > /etc/salt/minion << EOFSM
127 - ${F_DIR}/*/test/salt/states
139 cat > ${S_DIR}/top.sls << EOFTSLS
142 - example_add_snakeoil_certs
151 cat > ${P_DIR}/top.sls << EOFPSLS
156 - nginx_api_configuration
157 - nginx_controller_configuration
158 - nginx_keepproxy_configuration
159 - nginx_keepweb_configuration
161 - nginx_websocket_configuration
162 - nginx_webshell_configuration
163 - nginx_workbench2_configuration
164 - nginx_workbench_configuration
169 # Get the formula and dependencies
170 cd ${F_DIR} || exit 1
171 for f in postgres arvados nginx docker locale; do
172 git clone https://github.com/saltstack-formulas/${f}-formula.git
175 if [ "x${BRANCH}" != "x" ]; then
176 cd ${F_DIR}/arvados-formula
177 git checkout -t origin/${BRANCH}
181 # sed "s/__DOMAIN__/${DOMAIN}/g; s/__CLUSTER__/${CLUSTER}/g; s/__RELEASE__/${RELEASE}/g; s/__VERSION__/${VERSION}/g" \
182 # ${CONFIG_DIR}/arvados_dev.sls > ${P_DIR}/arvados.sls
184 if [ "x${VAGRANT}" = "xyes" ]; then
185 SOURCE_PILLARS_DIR="/vagrant/${CONFIG_DIR}"
187 SOURCE_PILLARS_DIR="./${CONFIG_DIR}"
190 # Replace cluster and domain name in the example pillars
191 for f in ${SOURCE_PILLARS_DIR}/*; do
192 # sed "s/example.net/${DOMAIN}/g; s/fixme/${CLUSTER}/g" \
193 sed "s/__DOMAIN__/${DOMAIN}/g;
194 s/__CLUSTER__/${CLUSTER}/g;
195 s/__RELEASE__/${RELEASE}/g;
196 s/__HOST_SSL_PORT__/${HOST_SSL_PORT}/g;
197 s/__GUEST_SSL_PORT__/${GUEST_SSL_PORT}/g;
198 s/__INITIAL_USER__/${INITIAL_USER}/g;
199 s/__INITIAL_USER_EMAIL__/${INITIAL_USER_EMAIL}/g;
200 s/__INITIAL_USER_PASSWORD__/${INITIAL_USER_PASSWORD}/g;
201 s/__VERSION__/${VERSION}/g" \
202 ${f} > ${P_DIR}/$(basename ${f})
205 # Let's write an /etc/hosts file that points all the hosts to localhost
207 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
209 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
210 if [ -e /root/.psqlrc ]; then
211 if ! ( grep 'pset pager off' /root/.psqlrc ); then
213 cp /root/.psqlrc /root/.psqlrc.provision.backup
219 echo '\pset pager off' >> /root/.psqlrc
220 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server
222 # Now run the install
223 salt-call --local state.apply -l debug
225 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
226 if [ "x${DELETE_PSQL}" = "xyes" ]; then
227 echo "Removing .psql file"
231 if [ "x${RESTORE_PSQL}" = "xyes" ]; then
232 echo "Restroting .psql file"
233 mv -v /root/.psqlrc.provision.backup /root/.psqlrc
235 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server