~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/atlibs-mesh-agents

atirc mesh agents on socialweb.computer VMs as an atlibs module

0
0
main
33 lines · 1.3 KB Raw History
#!/bin/sh
# Root, on the VM, after the peer records are written: one `atirc mesh run` per node (the agent's and yours,
# both carrying your channel and the agent's own) and `atirc agent run` for the agent; your node also listens on
# 127.0.0.1:LISTEN for your page (the contract's "atirc" WebRTC tunnel). KEY=value lines on stdin.
set -eu
while IFS='=' read -r k v; do
	case "$k" in
	NICK | YOU | HANDLE | CHANNELS | PEERS | LISTEN) eval "$k=\$v" ;;
	esac
done
args=""
for c in $CHANNELS; do args="$args -c $c"; done
for p in $PEERS; do args="$args --peer $p"; done
unit() {
	cat >"/etc/systemd/system/$1.service" <<EOF
[Unit]
Description=$1
After=network-online.target $3
Wants=network-online.target
[Service]
User=$2
Environment=HOME=/home/$2 ATP_USERNAME=$HANDLE ATIRC_NICK=$2
ExecStart=$4
Restart=always
RestartSec=5
EOF
}
unit "atirc-mesh-$NICK" "$NICK" "" "/usr/local/bin/atirc mesh run --no-publish --no-webrtc$args"
unit "atirc-mesh-$YOU" "$YOU" "" "/usr/local/bin/atirc mesh run --no-publish --no-webrtc --local-listen 127.0.0.1:$LISTEN$args"
unit "atirc-agent-$NICK" "$NICK" "atirc-mesh-$NICK.service" "/usr/local/bin/atirc agent run"
systemctl daemon-reload
systemctl restart "atirc-mesh-$NICK" "atirc-mesh-$YOU" "atirc-agent-$NICK"
systemctl is-active "atirc-mesh-$NICK" "atirc-mesh-$YOU" "atirc-agent-$NICK" | tr '\n' ' '