Fix homelab directory detection when running with sudo
When running with sudo, $HOME becomes /root instead of the actual user's home. Use $SUDO_USER to get the original user's home directory for HOPS deployment. Fixes: ERROR: Homelab directory not found: /root/hops 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -665,7 +665,13 @@ EOF
|
|||||||
log "🚀 Starting deployment..."
|
log "🚀 Starting deployment..."
|
||||||
|
|
||||||
# Ensure we're in the correct directory
|
# Ensure we're in the correct directory
|
||||||
local HOMELAB_DIR="$HOME/hops"
|
# When running with sudo, use the original user's home directory
|
||||||
|
local HOMELAB_DIR
|
||||||
|
if [[ -n "$SUDO_USER" ]]; then
|
||||||
|
HOMELAB_DIR="$(eval echo ~$SUDO_USER)/hops"
|
||||||
|
else
|
||||||
|
HOMELAB_DIR="$HOME/hops"
|
||||||
|
fi
|
||||||
if [[ ! -d "$HOMELAB_DIR" ]]; then
|
if [[ ! -d "$HOMELAB_DIR" ]]; then
|
||||||
error_exit_with_rollback "Homelab directory not found: $HOMELAB_DIR"
|
error_exit_with_rollback "Homelab directory not found: $HOMELAB_DIR"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user