Files
mars_nwe_pcab/install-browser.sh

36 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
[[ $EUID == 0 ]] || { echo 'Use sudo ./install-browser.sh'; exit 1; }
for x in node ffmpeg pulseaudio pactl python3 zip setpriv prlimit; do command -v "$x" >/dev/null || { echo "Missing $x; see BROWSER.md"; exit 1; }; done
[[ -x /usr/bin/node && -x /usr/bin/setpriv && -x /usr/bin/prlimit ]] || { echo "System Node.js and util-linux required at /usr/bin"; exit 1; }
/usr/bin/node -e 'if(+process.versions.node.split(".")[0]<20)process.exit(1)'
getent passwd mars-browser >/dev/null || useradd --system --home-dir /var/lib/mars-browser --shell /usr/sbin/nologin mars-browser
install -d -o mars-browser -g mars-browser -m 0700 /var/lib/mars-browser
install -d -m 0755 /usr/local/libexec/mars-browser
install -m 0644 browser/*.mjs browser/pulse.pa /usr/local/libexec/mars-browser/
install -d -m 0755 /usr/local/share/mars-vme
work=$(mktemp -d); trap 'rm -rf -- "$work"' EXIT
(cd clients && zip -q -r "$work/browser-client-source.zip" retro-browser -x '*/mars-retrobrowser-x11' '*.exe' '*.prg' '*.o')
install -m 0644 "$work/browser-client-source.zip" /usr/local/share/mars-vme/
install -m 0755 browser/update-engine.sh browser/launch-browser.sh /usr/local/libexec/mars-browser/
# Migrate the previous independent units before the integrated worker starts.
# Preserve the existing config.json and archive former unit files for rollback.
for unit in mars-browser.service mars-browser-audio.service; do
if systemctl cat "$unit" >/dev/null 2>&1; then systemctl disable --now "$unit"; fi
if [[ -f /etc/systemd/system/$unit && ! -L /etc/systemd/system/$unit ]]; then
backup=/var/lib/mars-vme/browser-legacy-units
install -d -m 0700 "$backup"
cp -a /etc/systemd/system/"$unit" "$backup/"
rm -- /etc/systemd/system/"$unit"
fi
done
install -m 0644 browser/*.service browser/*.timer /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now mars-browser-update.timer
# An already-running *new* supervisor consumes this marker; it never restarts NetWare.
if systemctl is-active --quiet mars_vme.service && [[ -d /run/mars-pcap ]]; then
touch /run/mars-pcap/browser-engine-update
fi
printf 'Browser module installed. Start mars_vme.service (new supervisor required). Existing configuration retained; first installation listener/audio disabled.\n'