mirror of
https://github.com/nightly-labs/openbot.git
synced 2026-11-24 01:55:09 +08:00
* Stop server updates from removing host packages The update installs packages.txt with apt-get install -y, so apt removed packages that conflict with a listed package. On Raspberry Pi OS, pcmanfm-pi breaks pcmanfm: an update removed pcmanfm-pi and the rpd-* desktop packages, or stopped when they were on hold. - Install every package with --no-remove. A required package that needs a removal now stops the update instead of removing host packages. - Move pcmanfm to optional-packages.txt. It is skipped when the pcmanfm command exists or when apt cannot install it without a removal. - stage runs the installed (old) script with the list of the new release, so pcmanfm must leave packages.txt. Old scripts do not read optional-packages.txt, so Pi servers can update to this release. - The Docker image, the boat template and the package check include the new list. Fixes #15262 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Skip an optional package only when apt needs a removal A dry run with --no-remove now decides the skip. A network, lock or dpkg error in the real install stops the update as before, so it does not hide behind the skip message. The docs now give the same skip rules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
3.4 KiB
Bash
Executable File
80 lines
3.4 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
SOURCE=$(cd "$(dirname "$0")" && pwd)
|
|
# shellcheck source=openbot-hosted-update
|
|
source "$SOURCE/openbot-hosted-update"
|
|
|
|
[ "$(id -u)" -eq 0 ] || fail "Run this as root."
|
|
[ "$#" -ge 2 ] && [ "$#" -le 4 ] || fail "usage: $0 <service-user> <unpacked release> [<account server URL> [<display size>]]"
|
|
SERVICE_USER=$1
|
|
RELEASE=$2
|
|
AUTH_API_URL=${3:-}
|
|
DISPLAY_SIZE=${4:-}
|
|
installed_user=""
|
|
if [ -r "$INSTALL/hosted/mode" ] && [ "$(<"$INSTALL/hosted/mode")" = self ] && [ -r "$INSTALL/hosted/service-user" ]; then
|
|
installed_user=$(<"$INSTALL/hosted/service-user")
|
|
fi
|
|
if [ -z "$SERVICE_USER" ]; then
|
|
SERVICE_USER=${installed_user:-openbot}
|
|
elif [ -n "$installed_user" ] && [ "$SERVICE_USER" != "$installed_user" ]; then
|
|
fail "OpenBot is installed for the user $installed_user. Install again without --user, or with --user $installed_user."
|
|
fi
|
|
|
|
[[ $SERVICE_USER =~ ^[a-zA-Z_][a-zA-Z0-9_-]*$ ]] && [ "$SERVICE_USER" != root ] || fail "The service user is not valid."
|
|
[ -x "$RELEASE/openbot" ] || fail "The release has no openbot executable."
|
|
if [ -n "$AUTH_API_URL" ]; then
|
|
[[ $AUTH_API_URL =~ ^https://[^/?#[:space:]]+/?$ ]] || fail "The account server URL must be an HTTPS origin."
|
|
fi
|
|
if [ -n "$DISPLAY_SIZE" ]; then
|
|
[[ $DISPLAY_SIZE =~ ^([1-9][0-9]{2,3})x([1-9][0-9]{2,3})$ ]] &&
|
|
[ "${BASH_REMATCH[1]}" -ge 640 ] && [ "${BASH_REMATCH[1]}" -le 2576 ] &&
|
|
[ "${BASH_REMATCH[2]}" -ge 480 ] && [ "${BASH_REMATCH[2]}" -le 2576 ] ||
|
|
fail "The display size must be WIDTHxHEIGHT from 640x480 to 2576x2576, for example 1920x1080."
|
|
fi
|
|
if [ -f "$INSTALL/hosted/service-user" ] && ! { [ -r "$INSTALL/hosted/mode" ] && [ "$(<"$INSTALL/hosted/mode")" = self ]; }; then
|
|
fail "This computer is an OpenBot hosted server. A self-hosted install would replace it."
|
|
fi
|
|
if ! id "$SERVICE_USER" >/dev/null 2>&1; then
|
|
useradd --system --create-home --home-dir "/var/lib/$SERVICE_USER" --shell /bin/bash "$SERVICE_USER"
|
|
echo "Created the user $SERVICE_USER."
|
|
fi
|
|
|
|
exec 9>"$LOCK"
|
|
flock 9
|
|
install_packages "$SOURCE/packages.txt"
|
|
install_optional_packages "$SOURCE/optional-packages.txt"
|
|
install -d -m 0755 "$INSTALL" "$INSTALL/hosted"
|
|
recover
|
|
prepare_release "$RELEASE"
|
|
version=$(version_of "$RELEASE")
|
|
[ -n "$version" ] || fail "The release has no version."
|
|
installed=$(version_of "$INSTALL/app")
|
|
if [ -n "$installed" ] && newer "$installed" "$version"; then
|
|
fail "OpenBot $installed is installed, and this release has an older version."
|
|
fi
|
|
systemctl stop openbot.service 2>/dev/null || true
|
|
stage_release "$RELEASE"
|
|
swap_in
|
|
printf '%s\n' "$SERVICE_USER" >"$INSTALL/hosted/service-user"
|
|
printf 'self\n' >"$INSTALL/hosted/mode"
|
|
chmod 0644 "$INSTALL/hosted/service-user" "$INSTALL/hosted/mode"
|
|
install_hosting "$SOURCE"
|
|
finish_swap
|
|
|
|
install -d -o "$SERVICE_USER" -g "$(id -gn "$SERVICE_USER")" -m 0700 /srv/openbot-hosted
|
|
set_server_env() {
|
|
local file="$INSTALL/hosted/openbot.env" temporary
|
|
temporary=$(mktemp "$INSTALL/hosted/.openbot.env.XXXXXX")
|
|
if [ -f "$file" ]; then grep -v "^$1=" "$file" >"$temporary" || true; fi
|
|
printf '%s=%s\n' "$1" "$2" >>"$temporary"
|
|
chmod 0644 "$temporary"
|
|
mv -f "$temporary" "$file"
|
|
}
|
|
if [ -n "$AUTH_API_URL" ]; then set_server_env OPENBOT_AUTH_API_URL "${AUTH_API_URL%/}"; fi
|
|
if [ -n "$DISPLAY_SIZE" ]; then set_server_env OPENBOT_DISPLAY_SIZE "$DISPLAY_SIZE"; fi
|
|
flock -u 9
|
|
systemctl start openbot.service
|
|
systemctl start openbot-update.timer
|
|
echo "Installed OpenBot $version. It runs as the user $SERVICE_USER."
|