-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extensive installation script with more user feedback (#13)
- Loading branch information
1 parent
36013b9
commit 69b2132
Showing
1 changed file
with
77 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,80 @@ | ||
#!/bin/bash | ||
|
||
wget https://codeload.github.com/dutchdronesquad/rh-stream-overlays/zip/main -O ~/temp.zip | ||
unzip ~/temp.zip | ||
# Function to download and install/update the plugin | ||
install_or_update_plugin() { | ||
echo "Fetching the latest stable release version..." | ||
REPO="dutchdronesquad/rh-stream-overlays" | ||
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep "tag_name" | cut -d '"' -f 4) | ||
|
||
if [ -z "$LATEST_RELEASE" ]; then | ||
echo "Error: Unable to fetch the latest release version." | ||
exit 1 | ||
fi | ||
|
||
# Move the plugin folder into RotorHazard and remove the rest | ||
mv ~/rh-stream-overlays-main/stream_overlays ~/RotorHazard/src/server/plugins/stream_overlays | ||
rm -R ~/rh-stream-overlays-main | ||
rm ~/temp.zip | ||
echo "Latest release version is $LATEST_RELEASE. Downloading..." | ||
DOWNLOAD_URL="https://codeload.github.com/$REPO/zip/refs/tags/$LATEST_RELEASE" | ||
TEMP_ZIP=~/temp.zip | ||
echo "" | ||
|
||
wget $DOWNLOAD_URL -O $TEMP_ZIP | ||
if [ $? -ne 0 ]; then | ||
echo "Error: Failed to download the release." | ||
exit 1 | ||
fi | ||
|
||
echo "Extracting the downloaded zip file..." | ||
unzip -q $TEMP_ZIP -d ~ | ||
if [ $? -ne 0 ]; then | ||
echo "Error: Failed to unzip the file." | ||
rm $TEMP_ZIP | ||
exit 1 | ||
fi | ||
|
||
FOLDER_NAME=$(unzip -Z1 $TEMP_ZIP | head -1 | cut -d'/' -f1) | ||
if [ -z "$FOLDER_NAME" ]; then | ||
echo "Error: Unable to determine the folder name from the zip file." | ||
rm $TEMP_ZIP | ||
exit 1 | ||
fi | ||
|
||
TARGET_DIR=~/RotorHazard/src/server/plugins | ||
echo "Moving the files to $TARGET_DIR" | ||
mv ~/$FOLDER_NAME/stream_overlays $TARGET_DIR | ||
if [ $? -ne 0 ]; then | ||
echo "Error: Failed to move the plugin directory." | ||
rm -R ~/$FOLDER_NAME | ||
rm $TEMP_ZIP | ||
exit 1 | ||
fi | ||
|
||
echo "Cleaning up temporary files" | ||
rm -R ~/$FOLDER_NAME | ||
rm $TEMP_ZIP | ||
|
||
echo "Update to version $LATEST_RELEASE completed successfully!" | ||
} | ||
|
||
# Ask the user if they want to install/update the plugin | ||
read -p "Do you want to install the stream overlays plugin? (y/n): " choice | ||
case "$choice" in | ||
y|Y ) | ||
# Check if the plugin directory already exists | ||
PLUGIN_DIR=~/RotorHazard/src/server/plugins/stream_overlays | ||
if [ -d "$PLUGIN_DIR" ]; then | ||
read -p "The plugin already exists in RotorHazard. Do you want to update it? (y/n): " update_choice | ||
case "$update_choice" in | ||
y|Y ) | ||
# Remove existing directory | ||
echo "Removing the existing plugin directory..." | ||
rm -rf $PLUGIN_DIR | ||
install_or_update_plugin;; | ||
n|N ) echo "Update cancelled.";; | ||
* ) echo "Invalid choice. Update cancelled.";; | ||
esac | ||
else | ||
install_or_update_plugin | ||
fi | ||
;; | ||
n|N ) echo "Installation cancelled.";; | ||
* ) echo "Invalid choice. Installation/update cancelled.";; | ||
esac |