Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/scripts/allen/science/install.sh # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / scripts / allen / science / install.sh` 58 lines ยท 3108 bytes Raw Blame History 1 #!/bin/sh 2 # Install allen-science into /opt/allen-science. Run as root: 3 # sh install.sh AIEN_MATH_BINARY [OMC] [IRWASM] [MATH_ADMIT] 4 # Creates the allen-science system user (no home, no shell, no groups, no sudo), installs the 5 # service, the helper, the required engine manifest, the four pinned tools (math-admit with its 6 # math-admit.om source) root-owned and read-only, the same science_protocol.py bytes beside the 7 # gateway adapter in /opt/allen-chat (a copy, not a symlink), and the interim foreground launcher. 8 # It starts nothing and does not register the aien-supervise entry (allen-science.svc is a draft 9 # for /etc/aien-supervise/services/ once aien-supervise is live). 10 # DESTDIR=/some/dir installs the same tree under that directory without creating the user or 11 # setting ownership (used by test_science_sandbox.py; needs no root). 12 set -eu 13 SRC=$(cd "$(dirname "$0")" && pwd) 14 ENGINE=${1:?usage: install.sh AIEN_MATH_BINARY [OMC] [IRWASM] [MATH_ADMIT]} 15 OMC=${2:-/opt/allen-chat/omc} 16 IRWASM=${3:-/opt/allen-chat/irwasm} 17 ADMIT=${4:-$SRC/math-admit} 18 DESTDIR=${DESTDIR:-} 19 DEST=$DESTDIR/opt/allen-science 20 GW=$DESTDIR/opt/allen-chat 21 LIBEXEC=$DESTDIR/usr/local/libexec/aien-supervise 22 if [ -z "$DESTDIR" ]; then 23 [ "$(id -u)" = 0 ] || { echo "install.sh: run as root" >&2; exit 1; } 24 OWN="-o root -g root" 25 else 26 OWN="" 27 fi 28 helper() { /usr/bin/python3.12 -I -c "import sys; sys.path.insert(0, sys.argv[1]); import science_sandbox as s; $1" "$SRC" "$2"; } 29 30 # Refuse binaries that do not match the pins the helper enforces at run time. 31 for pair in "$ADMIT MATH_ADMIT_PIN" "$ENGINE AIEN_MATH_PIN" "$OMC OMC_PIN" "$IRWASM IRWASM_PIN"; do 32 set -- $pair 33 have=$(sha256sum "$1" | cut -d' ' -f1) 34 want=$(helper "print(getattr(s, sys.argv[2]))" "$2") 35 [ "$have" = "$want" ] || { echo "install.sh: $1 sha256 $have, pinned $want" >&2; exit 1; } 36 done 37 # The provenance manifest is required and must name exactly the pinned engine (commit + sha256). 38 problem=$(helper "print(s.manifest_problem(sys.argv[2]) or '')" "$SRC/engine.json") 39 [ -z "$problem" ] || { echo "install.sh: $problem" >&2; exit 1; } 40 41 if [ -z "$DESTDIR" ] && ! id allen-science >/dev/null 2>&1; then 42 useradd --system --user-group --no-create-home --home-dir /nonexistent --shell /usr/sbin/nologin allen-science 43 fi 44 45 install -d $OWN -m 0755 "$DEST" "$GW" "$LIBEXEC" 46 for f in allen_science.py science_protocol.py science_sandbox.py launch.py math-admit.om engine.json; do 47 install $OWN -m 0644 "$SRC/$f" "$DEST/$f" 48 done 49 install $OWN -m 0644 "$SRC/science_protocol.py" "$GW/science_protocol.py" 50 install $OWN -m 0755 "$ADMIT" "$DEST/math-admit" 51 install $OWN -m 0755 "$ENGINE" "$DEST/aien-math" 52 install $OWN -m 0755 "$OMC" "$DEST/omc" 53 install $OWN -m 0755 "$IRWASM" "$DEST/irwasm" 54 install $OWN -m 0755 "$SRC/allen-science-fg" "$LIBEXEC/allen-science-fg" 55 install $OWN -m 0755 "$SRC/allen-science-math-fg" "$LIBEXEC/allen-science-math-fg" 56 cmp -s "$DEST/science_protocol.py" "$GW/science_protocol.py" || { 57 echo "install.sh: service and gateway science_protocol.py differ" >&2; exit 1; } 58 echo "installed $DEST and $GW/science_protocol.py; not started"