36 lines
1.4 KiB
Bash
36 lines
1.4 KiB
Bash
#!/bin/sh
|
|
# Root-only, fixed package names, normal signed APT repositories. No browser-provided shell commands.
|
|
set -eu
|
|
[ "$(id -u)" = 0 ] || exit 1
|
|
exec 9>/run/lock/mars-browser-engine-update.lock
|
|
flock -n 9 || { echo "Browser update already running"; exit 0; }
|
|
case "${1:-}" in
|
|
--force) ;;
|
|
'') python3 - <<'PY' || exit 0
|
|
import os,json,stat
|
|
try:
|
|
fd=os.open('/var/lib/mars-browser/config.json',os.O_RDONLY|os.O_NOFOLLOW|os.O_NONBLOCK)
|
|
with os.fdopen(fd) as f:
|
|
if not stat.S_ISREG(os.fstat(f.fileno()).st_mode): raise ValueError()
|
|
c=json.loads(f.read(16384))
|
|
assert c.get('autoUpdate') is True
|
|
except Exception: raise SystemExit(1)
|
|
PY
|
|
;;
|
|
*) exit 2;;
|
|
esac
|
|
set --
|
|
for p in chromium google-chrome-stable; do
|
|
if dpkg-query -W -f='${Status}' "$p" 2>/dev/null | grep -qx 'install ok installed'; then set -- "$@" "$p"; fi
|
|
done
|
|
[ "$#" -gt 0 ] || { echo 'No supported APT browser package installed'; exit 0; }
|
|
before=$(dpkg-query -W -f='${Package} ${Version}\n' "$@")
|
|
apt-get -o APT::Update::Error-Mode=any update
|
|
DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=60 -y --only-upgrade install "$@"
|
|
after=$(dpkg-query -W -f='${Package} ${Version}\n' "$@")
|
|
if [ "$before" != "$after" ] && systemctl is-active --quiet mars_vme.service; then
|
|
# The root-owned runtime directory is writable only by the supervisor/root.
|
|
# Browser restart is asynchronous; PCAP and NetWare are left untouched.
|
|
touch /run/mars-pcap/browser-engine-update
|
|
fi
|