summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-12-31 19:14:43 -0500
committerJesse Luehrs <doy@tozt.net>2019-01-01 16:32:08 -0500
commit1fa60d11953e073160aef2c9ae3f2b42036e26e6 (patch)
tree7cbe8b24b466ce33db27db15a5c7a9c2bd848221 /bin
parent973f3f74902182f3799f69432fb8a8f90dee8885 (diff)
downloadpuppet-tozt-1fa60d11953e073160aef2c9ae3f2b42036e26e6.tar.gz
puppet-tozt-1fa60d11953e073160aef2c9ae3f2b42036e26e6.zip
fix algo launch script for algo updates
python dependencies are mostly installed by ansible now
Diffstat (limited to 'bin')
-rwxr-xr-xbin/algo-config4
-rwxr-xr-xbin/helpers/algo-virtualenv20
-rwxr-xr-xbin/helpers/launch-algo26
3 files changed, 27 insertions, 23 deletions
diff --git a/bin/algo-config b/bin/algo-config
index 80a8e29..0aa413a 100755
--- a/bin/algo-config
+++ b/bin/algo-config
@@ -4,7 +4,7 @@ set -o pipefail
script_path="$(realpath "$(dirname "$0")")"
secrets_bin="${script_path}/secrets"
-config_path="$(echo /mnt/algo/algo/configs/*/wireguard)"
+config_path="$(echo /mnt/algo/configs/*/wireguard)"
"$secrets_bin" open
trap '"$secrets_bin" close' EXIT
@@ -12,7 +12,7 @@ trap '"$secrets_bin" close' EXIT
if [ -z "${VIRTUAL_ENV:-}" ]; then
# shellcheck disable=SC1090
. "${script_path}/helpers/algo-virtualenv"
- :
+ python -m pip install segno
fi
# hush
diff --git a/bin/helpers/algo-virtualenv b/bin/helpers/algo-virtualenv
index 531873f..efb0c64 100755
--- a/bin/helpers/algo-virtualenv
+++ b/bin/helpers/algo-virtualenv
@@ -2,21 +2,9 @@
set -eu
set -o pipefail
-# using tmpdir as a virtualenv because the tozt-secrets filesystem is too small
-# to hold the whole python installation
-envdir="$(mktemp --tmpdir -d launch-algo.XXXXXXXXXX)"
-cleanup() {
- if perl -e'exit 1 unless $ARGV[0] =~ m{^/tmp/launch-algo.*$}' "$envdir"; then
- rm -rf "$envdir"
- fi
-}
-trap cleanup EXIT
-
-python2 -m virtualenv --python="$(command -v python2)" "$envdir"
+python -m virtualenv --python="$(command -v python2)" env
set +eu
-# shellcheck disable=SC1090
-. "$envdir"/bin/activate
+# shellcheck disable=SC1091
+source env/bin/activate
set -eu
-
-python -m pip install -U pip
-python -m pip install -r /mnt/algo/algo/requirements.txt
+python -m pip install -U pip virtualenv
diff --git a/bin/helpers/launch-algo b/bin/helpers/launch-algo
index f926529..3e4c9a7 100755
--- a/bin/helpers/launch-algo
+++ b/bin/helpers/launch-algo
@@ -5,22 +5,38 @@ 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"
-cd /mnt/algo/algo
-git reset --hard
-git clean -dfx
-git pull
-git apply "${script_path}/algo-config.diff"
+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 "