mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 03:01:21 +02:00
fix(install): docker installer tries mkdir without sudo, escalates on EACCES (#1774)
install/docker-install.sh::create_install_dir ran `mkdir -p "$INSTALL_PATH"` without sudo while DEFAULT_INSTALL_PATH was /opt/bambuddy, root-owned on every Linux distro. set -e then aborted the whole script before docker compose could pull the image — anyone running the documented `curl ... | bash` flow as a normal user hit this on first install. Fix: try the unprivileged `mkdir -p ... 2>/dev/null` first so --path ~/bambuddy, /srv/bambuddy and other writable targets don't trigger a needless password prompt, then fall back to `sudo mkdir -p` + `sudo chown -R "$USER:$USER"` only when the first attempt failed. The chown is load-bearing: without it the script would later try to write docker-compose.yml + .env into a root-owned dir as the invoking user and cascade further EACCES failures. Not changing the default path: install/update.sh and install/update_macos.sh both default INSTALL_DIR to /opt/bambuddy, and install/README.md's update flow documents the same — flipping the install default to ~/bambuddy without coordinating those would silently break self-service updates for anyone following the docs verbatim. The default stays /opt/bambuddy; only the escalation gap closes. set -e survives the redirected stderr because the `if !` form is the documented escape hatch for an expected-failure check. Smoke-tested writable-target, idempotent-rerun, and the failing-mkdir-then-sudo-fallback branches.
This commit is contained in:
@@ -249,7 +249,17 @@ install_docker() {
|
||||
create_install_dir() {
|
||||
log_info "Creating installation directory..."
|
||||
|
||||
mkdir -p "$INSTALL_PATH"
|
||||
if ! mkdir -p "$INSTALL_PATH" 2>/dev/null; then
|
||||
# The default `/opt/bambuddy` (and any other root-owned parent) needs
|
||||
# elevation. Try without sudo first so user-supplied custom paths
|
||||
# under $HOME / /srv / etc. don't drag in an unnecessary password
|
||||
# prompt. On the fallback path, chown the result to the invoking
|
||||
# user so they can edit docker-compose.yml + .env afterwards
|
||||
# without sudo every time (#1774).
|
||||
log_info "$INSTALL_PATH requires sudo to create..."
|
||||
sudo mkdir -p "$INSTALL_PATH"
|
||||
sudo chown -R "$USER:$USER" "$INSTALL_PATH"
|
||||
fi
|
||||
cd "$INSTALL_PATH"
|
||||
|
||||
log_success "Directory created: $INSTALL_PATH"
|
||||
|
||||
Reference in New Issue
Block a user