mirror of
https://github.com/nightly-labs/openbot.git
synced 2026-11-23 02:01:26 +08:00
* Remove code comments and add the no-comments rule Remove the comments from first-party code and configuration files: TS/JS, JSX, CSS, SQL migrations, Swift, Kotlin, Gradle, shell, Docker, systemd, Nix, YAML, TOML, JSONC and GritQL. Keep only what a tool reads: license headers, shebangs, compiler and lint directives, JSDoc types in plain .js files, generated file headers, GritQL scope lines, the install-server.sh help text and the openbot-boat-pre-stop marker. Vendored code, fixtures and released schemas keep their comments. Add the rule to AGENTS.md, and change the docs that asked for comments. Add two i18n keys that only comments named to RELEASED_SOURCE_KEYS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep comments that are data in strings The benchmark task files in opencode-free-models-bench.ts tell the model what each function must do. The sample file and HTML page in the two stories are display content. Put their comments back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep released migrations and mobile native inputs unchanged check:migrations compares each released migration with v0.73.0 byte for byte, so restore src/backend/migrations. A change to a native build input of apps/mobile makes a new runtime version, so restore those files and the extra fingerprint sources. List these files and the comment markers that a tool reads in AGENTS.md. Remove the last requests for comments in src/renderer/AGENTS.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
3.3 KiB
Bash
Executable File
79 lines
3.3 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 -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."
|