#!/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"