From 0bf2f8eb5b417fba6a3d154881e155c9e4cc4d98 Mon Sep 17 00:00:00 2001 From: Joshua Landwehr Date: Wed, 13 Aug 2025 17:11:41 -0700 Subject: [PATCH 1/6] Change default ports for podman and rootless docker. --- install.sh | 141 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 52 deletions(-) diff --git a/install.sh b/install.sh index 5f53f20..7961b20 100644 --- a/install.sh +++ b/install.sh @@ -15,64 +15,27 @@ NC='\033[0m' # No Color. DEFAULT_HTTP_PORT=80 DEFAULT_HTTPS_PORT=443 +# Default ports for user access without root privileges. +# Used for podman or rootless docker installations. +DEFAULT_USER_HTTP_PORT=8080 +DEFAULT_USER_HTTPS_PORT=8443 + # Initialize variables with default values HTTP_PORT=$DEFAULT_HTTP_PORT HTTPS_PORT=$DEFAULT_HTTPS_PORT ENTERPRISE_INSTALL=0 +# Did the user specify a custom HTTP or HTTPS port? +HTTP_PORT_SET=0 +HTTPS_PORT_SET=0 + EXISITING_ENV=0 USE_SSL=0 USE_PODMAN=0 +ROOTLESS_INSTALL=0 DOCKER_COMPOSE_VERSION=2 DOCKER_COMPOSE="docker compose" -# Parse command line options -while [ $# -gt 0 ]; do - case "$1" in - --http-port) - if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then - HTTP_PORT=$2 - shift 2 - else - log_error "Error: Argument for $1 is missing" - exit 1 - fi - ;; - --https-port) - if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then - HTTPS_PORT=$2 - shift 2 - else - log_error "Error: Argument for $1 is missing" - exit 1 - fi - ;; - --enterprise) - ENTERPRISE_INSTALL=1 - shift 1 - ;; - --use-podman) - USE_PODMAN=1 - shift - ;; - -h|--help) - echo "Usage: $0 [OPTIONS]" - echo "Available options:" - echo " --http-port PORT Specify custom HTTP port (default: $DEFAULT_HTTP_PORT)" - echo " --https-port PORT Specify custom HTTPS port (default: $DEFAULT_HTTPS_PORT)" - echo " --enterprise Enable multi-user enterprise installation" - echo " --use-podman Use Podman instead of Docker, falling back to Docker if Podman is not installed" - echo " -h, --help Show this help message" - exit 0 - ;; - *) - log_error "Unknown option: $1" - echo "Use -h or --help to see available options" - exit 1 - ;; - esac -done - # Minimum required Docker Compose version. MIN_COMPOSE_VERSION="1.27.0" @@ -83,6 +46,59 @@ log_info() { echo -e "${GREEN}[INFO]${NC} $1"; } log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } log_error() { echo -e "${RED}[ERROR]${NC} $1"; } +parse_args() { + # Parse command line options + while [ $# -gt 0 ]; do + case "$1" in + --http-port) + if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then + HTTP_PORT=$2 + HTTP_PORT_SET=1 + shift 2 + else + log_error "Error: Argument for $1 is missing" + exit 1 + fi + ;; + --https-port) + if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then + HTTPS_PORT=$2 + HTTPS_PORT_SET=1 + shift 2 + else + log_error "Error: Argument for $1 is missing" + exit 1 + fi + ;; + --enterprise) + ENTERPRISE_INSTALL=1 + shift 1 + ;; + --use-podman) + USE_PODMAN=1 + shift + ;; + -h|--help) + # Default ports may change based on the container tool used. + detect_container_tool + echo "Usage: $0 [OPTIONS]" + echo "Available options:" + echo " --http-port PORT Specify custom HTTP port (default: $DEFAULT_HTTP_PORT)" + echo " --https-port PORT Specify custom HTTPS port (default: $DEFAULT_HTTPS_PORT)" + echo " --enterprise Enable multi-user enterprise installation" + echo " --use-podman Use Podman instead of Docker, falling back to Docker if Podman is not installed" + echo " -h, --help Show this help message" + exit 0 + ;; + *) + log_error "Unknown option: $1" + echo "Use -h or --help to see available options" + exit 1 + ;; + esac + done +} + portable_sed_i() { # Usage: portable_sed_i 's|pattern|replacement|' filename local expr="$1" @@ -385,10 +401,7 @@ deploy_containers() { fi } -# Main installation process. -main() { - log_info "Starting installation process." - +detect_container_tool() { command_exists docker && has_docker=1 || has_docker=0 command_exists podman && has_podman=1 || has_podman=0 @@ -402,6 +415,30 @@ main() { log_info "Docker is not installed. Podman found. Falling back to Podman." fi + if [ "$USE_PODMAN" = "1" ] || docker info --format '{{.SecurityOptions}}' 2>/dev/null | grep -q rootless; then + ROOTLESS_INSTALL=1 + DEFAULT_HTTP_PORT=$DEFAULT_USER_HTTP_PORT + DEFAULT_HTTPS_PORT=$DEFAULT_USER_HTTPS_PORT + # Update ports if the user didn't specify them. + if [ "$HTTP_PORT_SET" = "1" ]; then + HTTP_PORT=$DEFAULT_USER_HTTP_PORT + fi + if [ "$HTTPS_PORT_SET" = "1" ]; then + HTTPS_PORT=$DEFAULT_USER_HTTPS_PORT + fi + log_info "Rootless installation detected." + fi +} + +# Main installation process. +main() { + # Handle command line arguments. + parse_args "$@" + + log_info "Starting installation process." + + detect_container_tool + arch=$(uname -m) if [ "$USE_PODMAN" = "1" ]; then @@ -445,4 +482,4 @@ main() { } # Run main function. -main +main "$@" From 2da8f6326b188b89c0a83b289347a3232f26d105 Mon Sep 17 00:00:00 2001 From: Joshua Landwehr Date: Wed, 13 Aug 2025 17:21:21 -0700 Subject: [PATCH 2/6] Fix rootless mode install. --- install.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 7961b20..034c09c 100644 --- a/install.sh +++ b/install.sh @@ -81,10 +81,19 @@ parse_args() { -h|--help) # Default ports may change based on the container tool used. detect_container_tool + + if [ "$ROOTLESS_INSTALL" -eq 1 ]; then + http_port_default=$DEFAULT_HTTP_USER_PORT + https_port_default=$DEFAULT_HTTPS_USER_PORT + else + http_port_default=$DEFAULT_HTTP_PORT + https_port_default=$DEFAULT_HTTPS_PORT + fi + echo "Usage: $0 [OPTIONS]" echo "Available options:" - echo " --http-port PORT Specify custom HTTP port (default: $DEFAULT_HTTP_PORT)" - echo " --https-port PORT Specify custom HTTPS port (default: $DEFAULT_HTTPS_PORT)" + echo " --http-port PORT Specify custom HTTP port (default: $http_port_default)" + echo " --https-port PORT Specify custom HTTPS port (default: $https_port_default)" echo " --enterprise Enable multi-user enterprise installation" echo " --use-podman Use Podman instead of Docker, falling back to Docker if Podman is not installed" echo " -h, --help Show this help message" @@ -417,13 +426,11 @@ detect_container_tool() { if [ "$USE_PODMAN" = "1" ] || docker info --format '{{.SecurityOptions}}' 2>/dev/null | grep -q rootless; then ROOTLESS_INSTALL=1 - DEFAULT_HTTP_PORT=$DEFAULT_USER_HTTP_PORT - DEFAULT_HTTPS_PORT=$DEFAULT_USER_HTTPS_PORT # Update ports if the user didn't specify them. - if [ "$HTTP_PORT_SET" = "1" ]; then + if [ "$HTTP_PORT_SET" = "0" ]; then HTTP_PORT=$DEFAULT_USER_HTTP_PORT fi - if [ "$HTTPS_PORT_SET" = "1" ]; then + if [ "$HTTPS_PORT_SET" = "0" ]; then HTTPS_PORT=$DEFAULT_USER_HTTPS_PORT fi log_info "Rootless installation detected." From 02efede1eca30e050bd66420c8b0dcf84732e261 Mon Sep 17 00:00:00 2001 From: Joshua Landwehr Date: Wed, 13 Aug 2025 17:23:34 -0700 Subject: [PATCH 3/6] Fix help message so defaults reflect installation candidates. --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 034c09c..5bb115d 100644 --- a/install.sh +++ b/install.sh @@ -83,8 +83,8 @@ parse_args() { detect_container_tool if [ "$ROOTLESS_INSTALL" -eq 1 ]; then - http_port_default=$DEFAULT_HTTP_USER_PORT - https_port_default=$DEFAULT_HTTPS_USER_PORT + http_port_default=$DEFAULT_USER_HTTP_PORT + https_port_default=$DEFAULT_USER_HTTPS_PORT else http_port_default=$DEFAULT_HTTP_PORT https_port_default=$DEFAULT_HTTPS_PORT From 6bd56c341fc74cb7bb35b7c9adb791e26794873b Mon Sep 17 00:00:00 2001 From: Joshua Landwehr Date: Wed, 13 Aug 2025 17:37:39 -0700 Subject: [PATCH 4/6] Fix setting ports in posix shell. --- install.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/install.sh b/install.sh index 5bb115d..2cbbd17 100644 --- a/install.sh +++ b/install.sh @@ -36,6 +36,56 @@ ROOTLESS_INSTALL=0 DOCKER_COMPOSE_VERSION=2 DOCKER_COMPOSE="docker compose" +<<<<<<< Updated upstream +======= +# Parse command line options +while [ $# -gt 0 ]; do + case "$1" in + --http-port) + if [ $# -ge 2 ] && [ -n "$2" ] && [ "${2#-}" = "$2" ]; then + HTTP_PORT=$2 + shift 2 + else + log_error "Error: Argument for $1 is missing" + exit 1 + fi + ;; + --https-port) + if [ $# -ge 2 ] && [ -n "$2" ] && [ "${2#-}" = "$2" ]; then + HTTPS_PORT=$2 + shift 2 + else + log_error "Error: Argument for $1 is missing" + exit 1 + fi + ;; + --enterprise) + ENTERPRISE_INSTALL=1 + shift 1 + ;; + --use-podman) + USE_PODMAN=1 + shift + ;; + -h|--help) + echo "Usage: $0 [OPTIONS]" + echo "Available options:" + echo " --http-port PORT Specify custom HTTP port (default: $DEFAULT_HTTP_PORT)" + echo " --https-port PORT Specify custom HTTPS port (default: $DEFAULT_HTTPS_PORT)" + echo " --enterprise Enable multi-user enterprise installation" + echo " --use-podman Use Podman instead of Docker, falling back to Docker if Podman is not installed" + echo " -h, --help Show this help message" + exit 0 + ;; + *) + log_error "Unknown option: $1" + echo "Use -h or --help to see available options" + exit 1 + ;; + esac +done + +>>>>>>> Stashed changes # Minimum required Docker Compose version. MIN_COMPOSE_VERSION="1.27.0" From 4878892a644fc22f6964c9cda098d0beeb76eb5b Mon Sep 17 00:00:00 2001 From: Joshua Landwehr Date: Wed, 13 Aug 2025 17:39:49 -0700 Subject: [PATCH 5/6] Fix bad merge. --- install.sh | 56 +++--------------------------------------------------- 1 file changed, 3 insertions(+), 53 deletions(-) diff --git a/install.sh b/install.sh index 2cbbd17..18f23d2 100644 --- a/install.sh +++ b/install.sh @@ -36,56 +36,6 @@ ROOTLESS_INSTALL=0 DOCKER_COMPOSE_VERSION=2 DOCKER_COMPOSE="docker compose" -<<<<<<< Updated upstream -======= -# Parse command line options -while [ $# -gt 0 ]; do - case "$1" in - --http-port) - if [ $# -ge 2 ] && [ -n "$2" ] && [ "${2#-}" = "$2" ]; then - HTTP_PORT=$2 - shift 2 - else - log_error "Error: Argument for $1 is missing" - exit 1 - fi - ;; - --https-port) - if [ $# -ge 2 ] && [ -n "$2" ] && [ "${2#-}" = "$2" ]; then - HTTPS_PORT=$2 - shift 2 - else - log_error "Error: Argument for $1 is missing" - exit 1 - fi - ;; - --enterprise) - ENTERPRISE_INSTALL=1 - shift 1 - ;; - --use-podman) - USE_PODMAN=1 - shift - ;; - -h|--help) - echo "Usage: $0 [OPTIONS]" - echo "Available options:" - echo " --http-port PORT Specify custom HTTP port (default: $DEFAULT_HTTP_PORT)" - echo " --https-port PORT Specify custom HTTPS port (default: $DEFAULT_HTTPS_PORT)" - echo " --enterprise Enable multi-user enterprise installation" - echo " --use-podman Use Podman instead of Docker, falling back to Docker if Podman is not installed" - echo " -h, --help Show this help message" - exit 0 - ;; - *) - log_error "Unknown option: $1" - echo "Use -h or --help to see available options" - exit 1 - ;; - esac -done - ->>>>>>> Stashed changes # Minimum required Docker Compose version. MIN_COMPOSE_VERSION="1.27.0" @@ -101,7 +51,7 @@ parse_args() { while [ $# -gt 0 ]; do case "$1" in --http-port) - if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then + if [ $# -ge 2 ] && [ -n "$2" ] && [ "${2#-}" = "$2" ]; then HTTP_PORT=$2 HTTP_PORT_SET=1 shift 2 @@ -111,7 +61,7 @@ parse_args() { fi ;; --https-port) - if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then + if [ $# -ge 2 ] && [ -n "$2" ] && [ "${2#-}" = "$2" ]; then HTTPS_PORT=$2 HTTPS_PORT_SET=1 shift 2 @@ -491,7 +441,7 @@ detect_container_tool() { main() { # Handle command line arguments. parse_args "$@" - + log_info "Starting installation process." detect_container_tool From d3f233191f39e0ace798d5ac5fed8c63df67580a Mon Sep 17 00:00:00 2001 From: Joshua Landwehr Date: Thu, 14 Aug 2025 14:09:38 -0700 Subject: [PATCH 6/6] Add testing for port 8080. --- .github/workflows/test-install.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml index 8db2585..c01841c 100644 --- a/.github/workflows/test-install.yml +++ b/.github/workflows/test-install.yml @@ -72,8 +72,10 @@ jobs: chmod +x ./install.sh sudo ./install.sh - - name: Validate port 80 is listening + - name: Validate port is listening run: | - sudo ss -ltnp | grep ':80 ' || { - echo "Port 80 is not listening"; exit 1; + PORT=$([ "${{ matrix.engine }}" = "podman" ] && echo 8080 || echo 80) + sudo ss -ltnp | grep -E ":${PORT}\b" || { + echo "Port $PORT is not listening" + exit 1 }