summaryrefslogtreecommitdiffstats
path: root/bin/helpers/launch-algo
blob: f92652998b7e53c5595ce2960ad6a8405383a69d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
set -eu
set -o pipefail

script_path="$(realpath "$(dirname "$0")")"
logfile="/mnt/algo/algo-log-$(date +%s).log"
latest_logfile=/mnt/algo/algo-log-latest.log

touch "$logfile"
ln -sf "$(basename "$logfile")" "$latest_logfile"
echo "Logging to $latest_logfile"

cd /mnt/algo/algo
git reset --hard
git clean -dfx
git pull
git apply "${script_path}/algo-config.diff"

echo "Installing dependencies..."
# shellcheck disable=SC1090
. "${script_path}/algo-virtualenv" >> "$logfile"
echo "done."

echo "Running Ansible..."
do_token=$(cat /mnt/digitalocean)
ansible-playbook main.yml -e "
    provider=digitalocean
    server_name=algo
    ondemand_cellular=false
    ondemand_wifi=false
    local_dns=false
    ssh_tunneling=true
    windows=false
    store_cakey=false
    region=nyc3
    do_token=$do_token
" >> "$logfile"

"${script_path}/../algo-config"

# need to wait for the controlmaster process to exit
# XXX there should be a way to tell it to exit, but i don't know how to
# calculate the correct controlpath
sleep 60
echo "Done"