#!/bin/sh # Bootstrap this fork; run.py remains the deployment entry point. set -eu fail() { printf '%s\n' "Firegex installer: $*" >&2; exit 1; } [ "$(uname -s)" = Linux ] || fail 'Linux is required.' command -v python3 >/dev/null 2>&1 || fail 'Install Python 3.10 or newer first.' command -v git >/dev/null 2>&1 || fail 'Install git first.' python3 -c 'import sys, tarfile; sys.exit(not (sys.version_info >= (3, 10) and hasattr(tarfile, "tar_filter")))' \ || fail 'Update Python: version 3.10+ with tarfile extraction filters is required.' standalone=0 for argument in "$@"; do case "$argument" in --standalone) standalone=1 ;; --prebuilt) fail 'Upstream prebuilt images do not include MCP; omit --prebuilt.' ;; esac done # Keep rootless Docker on the standalone path even after privilege elevation. docker_info=$(docker info --format '{{json .SecurityOptions}}' 2>/dev/null) || docker_info= case "$docker_info" in *rootless*) standalone=1; set -- "$@" --standalone ;; esac use_sudo=0 if [ "$(id -u)" != 0 ] && { [ "$standalone" = 1 ] || [ -z "$docker_info" ]; }; then command -v sudo >/dev/null 2>&1 || fail 'Root privileges are required; run as root or install sudo.' use_sudo=1 fi install_dir=${FIREGEX_INSTALL_DIR:-"$PWD/firegex"} case "$install_dir" in /*) ;; *) install_dir=$PWD/$install_dir ;; esac if [ -e "$install_dir" ] || [ -L "$install_dir" ]; then fail "$install_dir already exists. Use its run.py, or select a new FIREGEX_INSTALL_DIR." fi printf '%s\n' "Downloading Av0idD4rk/firegex into $install_dir" git clone --depth 1 --branch main https://github.com/Av0idD4rk/firegex.git "$install_dir" printf '%s\n' "Manage this installation with: $install_dir/run.py" cd "$install_dir" if [ "$use_sudo" = 1 ]; then exec sudo python3 ./run.py start "$@" fi exec python3 ./run.py start "$@"