Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081#!/usr/bin/env bash# The step a person runs next. Only the body of step() changes between runs.set -uo pipefailcd "$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"mkdir -p logsexec > >(tee logs/next.log) 2>&1
step() { # Copies two working values from .env to the vault under the account owner's login, because # the project's token gets NotAllowed on writes even with the Editor role, and returns that # token to read-only. The login uses a throwaway session directory, so the project's and # other projects' sessions stay as they are. Prints outcomes, never a value. local session rc session="$(mktemp -d)" export BEZ_PASS_SESSION_DIR="$session/pass" bench/pass-cli.sh login rc=$? if [ "$rc" -eq 0 ]; then python3 - <<'PY'import json, re, subprocess, sys
PASS, VAULT = "bench/pass-cli.sh", "folknet"
def env_field(key): for line in open(".env"): m = re.match(rf"\s*(?:export\s+)?{key}=(.*)$", line.rstrip("\n")) if m: return m.group(1).strip().strip("\"'") sys.exit(f"{key} is not in .env")
def view(title): r = subprocess.run([PASS, "item", "view", "--vault-name", VAULT, "--item-title", title, "--field", "password"], capture_output=True, text=True) return r.stdout.strip() if r.returncode == 0 else None
def report(title, r, value): same = view(title) == value print(title, "write exit", r.returncode, "; vault matches .env:", same) if r.returncode: print(" error:", r.stderr.replace(value, "<value>").strip()[:300]) return same
value = env_field("WEBENGINE_JOB_EVENTS_TOKEN")r = subprocess.run([PASS, "item", "update", "--vault-name", VAULT, "--item-title", "job-events-token", "--field", f"password={value}"], capture_output=True, text=True)ok = report("job-events-token", r, value)
value = env_field("SZZT_APP_PASSWORD")if view("szzt-app-password") is not None: same = view("szzt-app-password") == value print("szzt-app-password already exists; left unchanged; vault matches .env:", same) ok = ok and sameelse: template = json.dumps({"title": "szzt-app-password", "username": None, "email": None, "password": value, "totp_uri": None, "urls": []}) r = subprocess.run([PASS, "item", "create", "login", "--vault-name", VAULT, "--from-template", "-"], input=template, capture_output=True, text=True) ok = report("szzt-app-password", r, value) and oksys.exit(0 if ok else 1)PY rc=$? fi bench/pass-cli.sh personal-access-token access grant \ --personal-access-token-name bez-box --vault-name folknet --role viewer bench/pass-cli.sh personal-access-token access list-access \ --personal-access-token-name bez-box bench/pass-cli.sh logout rm -rf -- "$session" return "$rc"}
echo "== next.sh start $(date -u +%FT%TZ) at $(git rev-parse --short HEAD)"stepcode=$?echo "== next.sh exit $code $(date -u +%FT%TZ)"exit "$code"