Skip to content

Commit 101aa85

Browse files
Fix install.sh
1 parent 7aa2cf0 commit 101aa85

File tree

1 file changed

+62
-60
lines changed

1 file changed

+62
-60
lines changed

β€Žinstall.shβ€Ž

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ TOOL_NAME="Luca"
1212
INSTALL_DIR="/usr/local/bin"
1313
TOOL_FOLDER=".luca"
1414
VERSION_FILE="${PWD}/.luca-version"
15+
ORGANIZATION="LucaTools"
1516
REPOSITORY_URL="https://github.com/LucaTools/Luca"
1617
TOOL_DIR="$HOME/$TOOL_FOLDER"
1718
SHELL_HOOK_SCRIPT_PATH="$TOOL_DIR/shell_hook.sh"
@@ -25,7 +26,7 @@ SHELL_HOOK_SCRIPT_URL="https://raw.githubusercontent.com/LucaTools/LucaInstall/H
2526
if [ ! -f "$VERSION_FILE" ]; then
2627
echo "Missing $VERSION_FILE. Fetching the latest version"
2728
# Fetch latest release version from GitHub API
28-
REQUIRED_EXECUTABLE_VERSION=$(curl -LSsf "https://api.github.com/repos/LucaTools/Luca/releases/latest" | grep '"tag_name":' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
29+
REQUIRED_EXECUTABLE_VERSION=$(curl -LSsf "https://api.github.com/repos/$ORGANIZATION/$TOOL_NAME/releases/latest" | grep '"tag_name":' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
2930

3031
if [ -z "$REQUIRED_EXECUTABLE_VERSION" ]; then
3132
echo "ERROR: Could not fetch latest version from $REPOSITORY_URL"
@@ -146,78 +147,79 @@ fi
146147
# Skip the download and installation if version is already current
147148
if [ "$SKIP_INSTALLATION" = "true" ]; then
148149
echo "Skipping Luca download and installation..."
149-
else
150-
# =============================================================================
151-
# LUCA DOWNLOAD AND INSTALLATION
152-
# =============================================================================
153-
154-
echo "πŸ“₯ Downloading $TOOL_NAME ($REQUIRED_EXECUTABLE_VERSION)..."
150+
exit 0
151+
fi
155152

156-
# Download the appropriate version for the detected OS
157-
# Use the updated URL pointing to the new S3 bucket
158-
curl -LSsf --output "./$TEMP_EXECUTABLE_ZIP_FILENAME" \
159-
"https://luca-tool-manager-scripts.s3.eu-west-2.amazonaws.com/$TOOL_NAME/$REQUIRED_EXECUTABLE_VERSION/$TEMP_EXECUTABLE_ZIP_FILENAME"
160-
161-
DOWNLOAD_SUCCESS=$?
162-
if [ $DOWNLOAD_SUCCESS -ne 0 ]; then
163-
echo "❌ ERROR: Could not download $TOOL_NAME ($REQUIRED_EXECUTABLE_VERSION)."
164-
echo "Please check your internet connection and verify the version exists."
165-
exit 1
166-
fi
153+
# =============================================================================
154+
# LUCA DOWNLOAD AND INSTALLATION
155+
# =============================================================================
167156

168-
echo "βœ… Download completed successfully"
157+
echo "πŸ“₯ Downloading $TOOL_NAME ($REQUIRED_EXECUTABLE_VERSION)..."
169158

170-
# =============================================================================
171-
# EXTRACTION AND INSTALLATION
172-
# =============================================================================
159+
# Download the appropriate version for the detected OS
160+
# Use the updated URL pointing to the new S3 bucket
161+
curl -LSsf --output "./$TEMP_EXECUTABLE_ZIP_FILENAME" \
162+
"$REPOSITORY_URL/releases/download/$REQUIRED_EXECUTABLE_VERSION/$TEMP_EXECUTABLE_ZIP_FILENAME"
173163

174-
echo "πŸ“¦ Extracting $TEMP_EXECUTABLE_ZIP_FILENAME..."
175-
176-
# Extract the downloaded zip file quietly
177-
if ! unzip -o -qq "./$TEMP_EXECUTABLE_ZIP_FILENAME" -d ./; then
178-
echo "❌ ERROR: Failed to extract $TEMP_EXECUTABLE_ZIP_FILENAME"
179-
rm -f "./$TEMP_EXECUTABLE_ZIP_FILENAME"
180-
exit 1
181-
fi
164+
DOWNLOAD_SUCCESS=$?
165+
if [ $DOWNLOAD_SUCCESS -ne 0 ]; then
166+
echo "❌ ERROR: Could not download $TOOL_NAME ($REQUIRED_EXECUTABLE_VERSION)."
167+
echo "Please check your internet connection and verify the version exists."
168+
exit 1
169+
fi
170+
171+
echo "βœ… Download completed successfully"
172+
173+
# =============================================================================
174+
# EXTRACTION AND INSTALLATION
175+
# =============================================================================
182176

183-
echo "βœ… Extraction completed"
177+
echo "πŸ“¦ Extracting $TEMP_EXECUTABLE_ZIP_FILENAME..."
184178

185-
# Clean up the downloaded zip file
186-
rm "./$TEMP_EXECUTABLE_ZIP_FILENAME"
187-
echo "🧹 Cleaned up temporary files"
179+
# Extract the downloaded zip file quietly
180+
if ! unzip -o -qq "./$TEMP_EXECUTABLE_ZIP_FILENAME" -d ./; then
181+
echo "❌ ERROR: Failed to extract $TEMP_EXECUTABLE_ZIP_FILENAME"
182+
rm -f "./$TEMP_EXECUTABLE_ZIP_FILENAME"
183+
exit 1
184+
fi
188185

189-
# =============================================================================
190-
# SYSTEM INSTALLATION WITH PRIVILEGE HANDLING
191-
# =============================================================================
186+
echo "βœ… Extraction completed"
192187

193-
# Helper function to run commands with sudo only if needed
194-
# This checks if the install directory is writable before using sudo
195-
sudo_if_install_dir_not_writeable() {
196-
local command="$1"
197-
if [ -w "$INSTALL_DIR" ]; then
198-
# Directory is writable, run without sudo
199-
sh -c "$command"
200-
else
201-
# Directory requires elevated privileges
202-
echo "πŸ” Administrator privileges required for installation to $INSTALL_DIR"
203-
sudo sh -c "$command"
204-
fi
205-
}
188+
# Clean up the downloaded zip file
189+
rm "./$TEMP_EXECUTABLE_ZIP_FILENAME"
190+
echo "🧹 Cleaned up temporary files"
206191

207-
# Create install directory if it doesn't exist
208-
if [ ! -d "$INSTALL_DIR" ]; then
209-
echo "πŸ“ Creating install directory: $INSTALL_DIR"
210-
sudo_if_install_dir_not_writeable "mkdir -p $INSTALL_DIR"
211-
fi
192+
# =============================================================================
193+
# SYSTEM INSTALLATION WITH PRIVILEGE HANDLING
194+
# =============================================================================
212195

213-
# Move the executable to the install directory and make it executable
214-
echo "πŸš€ Installing $TOOL_NAME to $INSTALL_DIR..."
215-
sudo_if_install_dir_not_writeable "mv $TOOL_NAME $EXECUTABLE_FILE"
216-
sudo_if_install_dir_not_writeable "chmod +x $EXECUTABLE_FILE"
196+
# Helper function to run commands with sudo only if needed
197+
# This checks if the install directory is writable before using sudo
198+
sudo_if_install_dir_not_writeable() {
199+
local command="$1"
200+
if [ -w "$INSTALL_DIR" ]; then
201+
# Directory is writable, run without sudo
202+
sh -c "$command"
203+
else
204+
# Directory requires elevated privileges
205+
echo "πŸ” Administrator privileges required for installation to $INSTALL_DIR"
206+
sudo sh -c "$command"
207+
fi
208+
}
217209

218-
echo "βœ… $TOOL_NAME ($REQUIRED_EXECUTABLE_VERSION) successfully installed to $INSTALL_DIR"
210+
# Create install directory if it doesn't exist
211+
if [ ! -d "$INSTALL_DIR" ]; then
212+
echo "πŸ“ Creating install directory: $INSTALL_DIR"
213+
sudo_if_install_dir_not_writeable "mkdir -p $INSTALL_DIR"
219214
fi
220215

216+
# Move the executable to the install directory and make it executable
217+
echo "πŸš€ Installing $TOOL_NAME to $INSTALL_DIR..."
218+
sudo_if_install_dir_not_writeable "mv $TOOL_NAME $EXECUTABLE_FILE"
219+
sudo_if_install_dir_not_writeable "chmod +x $EXECUTABLE_FILE"
220+
221+
echo "βœ… $TOOL_NAME ($REQUIRED_EXECUTABLE_VERSION) successfully installed to $INSTALL_DIR"
222+
221223
# =============================================================================
222224
# SHELL HOOK SETUP
223225
# =============================================================================

0 commit comments

Comments
Β (0)