Skip to content

Commit

Permalink
Merge pull request #2 from vmfarms/fix/add-dir
Browse files Browse the repository at this point in the history
fix: make install script more robust
  • Loading branch information
hany committed Sep 6, 2024
2 parents 2946c98 + 639ebf6 commit da0a765
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,43 @@ install_command() {
destination_path=$2
cmd=""
if [ "$(id -u)" != "0" ]; then
echo "You will be prompted for your sudo password in order to install sidepro in /usr/local/bin."
echo "You will be prompted for your sudo password to install sidepro in /usr/local/bin."
cmd+="sudo "
fi

# Create /usr/local/bin if it doesn't exist
${cmd}mkdir -p /usr/local/bin

cmd+="install -m 755 $download_path $destination_path"
eval "$cmd"
}

if ! command -v curl &> /dev/null; then
echo "Error: curl is not installed. Please install curl and try again."
exit 1
fi

if [[ ! "$PATH" == *":/usr/local/bin:"* ]]; then
echo "Warning: Your path is missing /usr/local/bin, you need to add this to use sidepro."
fi

LATEST_VERSION=$(curl -s https://api.github.com/repos/vmfarms/sidepro/releases/latest 2>&1 | grep "tag_name" | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$LATEST_VERSION" ]; then
echo "Unable to determine the latest version."
exit 1
echo "Unable to determine the latest version. Please visit the following URL to download manually:"
echo "https://github.com/vmfarms/sidepro/releases"
echo "After downloading, you can install it using: sudo install -m 755 /path/to/downloaded/sidepro /usr/local/bin/sidepro"
exit 1
fi
SIDEPRO_TMP="/tmp/sidepro-$(date +%s)"
curl -L "https://github.com/vmfarms/sidepro/releases/download/${LATEST_VERSION}/sidepro" -o "$SIDEPRO_TMP" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Failed to download sidepro. Please check your internet connection and try again."
exit 1
fi

install_command "$SIDEPRO_TMP" "/usr/local/bin/sidepro"

# Clean up the temporary file
rm -f "$SIDEPRO_TMP"

echo "sidepro has been successfully installed to /usr/local/bin/sidepro"

0 comments on commit da0a765

Please sign in to comment.