blob: 3e4c9a7ce1db344cfdc7d61c7c96d13da34fc629 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/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
algodir="$(mktemp --tmpdir -d launch-algo.XXXXXXXXXX)"
cleanup() {
if perl -e'exit 1 unless $ARGV[0] =~ m{^/tmp/launch-algo.*$}' "$algodir"; then
rm -rf "$algodir"
fi
}
trap cleanup EXIT
touch "$logfile"
ln -sf "$(basename "$logfile")" "$latest_logfile"
echo "Logging to $latest_logfile"
git clone git@github.com:trailofbits/algo "$algodir"
cd "$algodir"
echo "Installing dependencies..."
# shellcheck disable=SC1090
. "${script_path}/algo-virtualenv" >> "$logfile"
python -m pip install -r requirements.txt
echo "done."
rm -f configs/.gitinit
rmdir configs
mkdir -p .venvs
rm -rf /mnt/algo/configs
mkdir -p /mnt/algo/configs
ln -sf /mnt/algo/configs configs
ln -sf "$algodir"/.venvs /mnt/algo/configs/.venvs
git apply "${script_path}/algo-config.diff"
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"
|