interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

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).
12set -eu
13SRC=$(cd "$(dirname "$0")" && pwd)
14ENGINE=${1:?usage: install.sh AIEN_MATH_BINARY [OMC] [IRWASM] [MATH_ADMIT]}
15OMC=${2:-/opt/allen-chat/omc}
16IRWASM=${3:-/opt/allen-chat/irwasm}
17ADMIT=${4:-$SRC/math-admit}
18DESTDIR=${DESTDIR:-}
19DEST=$DESTDIR/opt/allen-science
20GW=$DESTDIR/opt/allen-chat
21LIBEXEC=$DESTDIR/usr/local/libexec/aien-supervise
22if [ -z "$DESTDIR" ]; then
23 [ "$(id -u)" = 0 ] || { echo "install.sh: run as root" >&2; exit 1; }
24 OWN="-o root -g root"
25else
26 OWN=""
27fi
28helper() { /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.
31for 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; }
36done
37# The provenance manifest is required and must name exactly the pinned engine (commit + sha256).
38problem=$(helper "print(s.manifest_problem(sys.argv[2]) or '')" "$SRC/engine.json")
39[ -z "$problem" ] || { echo "install.sh: $problem" >&2; exit 1; }
40
41if [ -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
43fi
44
45install -d $OWN -m 0755 "$DEST" "$GW" "$LIBEXEC"
46for 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"
48done
49install $OWN -m 0644 "$SRC/science_protocol.py" "$GW/science_protocol.py"
50install $OWN -m 0755 "$ADMIT" "$DEST/math-admit"
51install $OWN -m 0755 "$ENGINE" "$DEST/aien-math"
52install $OWN -m 0755 "$OMC" "$DEST/omc"
53install $OWN -m 0755 "$IRWASM" "$DEST/irwasm"
54install $OWN -m 0755 "$SRC/allen-science-fg" "$LIBEXEC/allen-science-fg"
55install $OWN -m 0755 "$SRC/allen-science-math-fg" "$LIBEXEC/allen-science-math-fg"
56cmp -s "$DEST/science_protocol.py" "$GW/science_protocol.py" || {
57 echo "install.sh: service and gateway science_protocol.py differ" >&2; exit 1; }
58echo "installed $DEST and $GW/science_protocol.py; not started"