From 161685b966a50d735448694f30aa25baa4598bbe Mon Sep 17 00:00:00 2001 From: Arunavo Ray Date: Wed, 21 May 2025 22:30:15 +0530 Subject: [PATCH] Add directory permission check before creating symlink in systemd service setup --- scripts/gitea-mirror-lxc-installer.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/gitea-mirror-lxc-installer.sh b/scripts/gitea-mirror-lxc-installer.sh index 3cc65ac..4cf2d23 100755 --- a/scripts/gitea-mirror-lxc-installer.sh +++ b/scripts/gitea-mirror-lxc-installer.sh @@ -154,7 +154,19 @@ echo -e "${GREEN}Using Bun from: $BUN_PATH${NC}" # Ensure the Bun executable is accessible to the service user if [ ! -f "$BUN_PATH" ]; then echo -e "${YELLOW}Bun not found at $BUN_PATH, creating symlink...${NC}" + + # Check if /usr/local/bin is writable + if [ ! -w "$(dirname "$BUN_PATH")" ]; then + echo -e "${RED}Error: $(dirname "$BUN_PATH") is not writable. Please run the script as root or with sufficient permissions.${NC}" + exit 1 + fi + ln -sf "$(command -v bun)" "$BUN_PATH" + + if [ $? -ne 0 ]; then + echo -e "${RED}Error: Failed to create symlink for Bun in $(dirname "$BUN_PATH").${NC}" + exit 1 + fi fi # Make sure the Bun executable has the right permissions