From 520f82d52f307a3cd61d71e2db8da6574cbfa18b Mon Sep 17 00:00:00 2001 From: JaviPege Date: Wed, 22 Oct 2025 15:43:34 +0200 Subject: [PATCH] Fix installer cleanup removing wrong directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Problem:** Cleanup was trying to remove /mediacenter/docker instead of /home/ubuntu/sailarr-installer (the actual repo directory). **Root Cause:** Recalculating installer directory with dirname BASH_SOURCE at cleanup time instead of using SCRIPT_DIR that was calculated at script start. **Solution:** Use SCRIPT_DIR variable throughout cleanup section. This is more reliable since it's calculated once at the beginning before any directory changes. **Changes:** - Removed INSTALLER_DIR variable recalculation - Use SCRIPT_DIR consistently in all cleanup messages - Updated both success and skip paths to use SCRIPT_DIR **Testing:** This ensures the correct directory (sailarr-installer repo) is removed, not the docker config directory inside /mediacenter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- setup.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/setup.sh b/setup.sh index 8bc5142..fb8de3b 100755 --- a/setup.sh +++ b/setup.sh @@ -1302,14 +1302,15 @@ read -p "Do you want to remove the installer repository? [y/N]: " -n 1 -r echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then - INSTALLER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - log_info "Removing installer repository: ${INSTALLER_DIR}" + # Use SCRIPT_DIR that was calculated at the start of the script + # This is more reliable than recalculating from BASH_SOURCE + log_info "Removing installer repository: ${SCRIPT_DIR}" # Move to parent directory before deletion - cd "${INSTALLER_DIR}/.." + cd "${SCRIPT_DIR}/.." # Remove the installer directory - rm -rf "${INSTALLER_DIR}" + rm -rf "${SCRIPT_DIR}" if [ $? -eq 0 ]; then log_success "Installer repository removed successfully" @@ -1318,13 +1319,13 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then echo "All your configuration is preserved in ${ROOT_DIR}" else log_error "Failed to remove installer repository" - echo "You can manually delete it later: rm -rf ${INSTALLER_DIR}" + echo "You can manually delete it later: rm -rf ${SCRIPT_DIR}" fi else - log_info "Installer repository kept at: $(pwd)" + log_info "Installer repository kept at: ${SCRIPT_DIR}" echo "" echo "You can manually remove it later if needed:" - echo " rm -rf $(pwd)" + echo " rm -rf ${SCRIPT_DIR}" fi echo ""