Prepared for options; Updated Version comparasing

This commit is contained in:
Fr4nz D13trich 2025-12-20 17:08:15 +01:00
parent 1ea3c4c1a3
commit 375ff9a2b7

View file

@ -9,17 +9,21 @@ RED="\e[0;31m"
GRN="\e[0;32m" GRN="\e[0;32m"
CRS="\e[0m" CRS="\e[0m"
## FOLDER & GLOBAL VARIABLES ## LOCATIONS
SCRIPT_VERSION="0.4"
mkdir -p /tmp/Helium mkdir -p /tmp/Helium
TMP=/tmp/Helium TMP=/tmp/Helium
INSTALL_PATH=$HOME/.apps/Helium INSTALL_PATH=$HOME/.apps/Helium
PROFILE=$HOME/.profile #PROFILE=$HOME/.profile ### for AUTO UPDATE
MISSING=$(cat $TMP/missingDeps 2>/dev/null)
## GLOBAL VARIABLES
SCRIPT_NAME="Helium Helper"
SCRIPT_VERSION="0.4"
DEPENDENCIES=("curl" "wget") DEPENDENCIES=("curl" "wget")
MISSING=$(cat $TMP/missingDeps 2>/dev/null)
GIT_VERSION=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | grep "tag_name" | tr -d \", | awk '{print $2}') GIT_VERSION=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | grep "tag_name" | tr -d \", | awk '{print $2}')
### SCRIPT DEPENDENCIES ## FUNCTIONS
### DEPENDENCIES
dependency_check() { dependency_check() {
local PACKAGE="$1" local PACKAGE="$1"
@ -32,22 +36,7 @@ dependency_check() {
fi fi
} }
for PACKAGE in "${DEPENDENCIES[@]}" ; do ### INSTALL
dependency_check "$PACKAGE"
done
if ! [ "$MISSING" ] ; then
:
else
echo -e "\n ${RED}Following dependencies are missing :\n\n${YEL}$MISSING\n\n ${CYN}Please install and re-run script !${CRS}"
rm $TMP/missingDeps
exit 1
fi
## CHECK LOCAL INSTALL
install_helium() { install_helium() {
while true ; do while true ; do
@ -76,20 +65,7 @@ install_helium() {
done done
} }
if ! [ -d "$INSTALL_PATH" ] ; then ### UPDATE
echo -e "\n ${RED}Helium directory not found !${CRS}"
install_helium
elif ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
echo -e "\n ${RED}Helium directory found but no executable named ${CYN}helium-browser.AppImage ${RED}!${CRS}"
install_helium
else
:
fi
## COMPARE
update_helium() { update_helium() {
while true ; do while true ; do
@ -118,9 +94,65 @@ update_helium() {
done done
} }
### VERSION
version() {
echo -e " ${CYN}Script Version :\t${GRN}${SCRIPT_VERSION}${CRS}"
}
### HELP
help() {
echo
echo -e "${CYN}${SCRIPT_NAME}${CRS}"
echo
echo -e "Description of scripts purpose and/or function"
echo
echo -e "Syntax: script_name.sh [-h|-i|-V|-v]"
echo
echo -e "Options:"
echo
echo -e "\t-h\tPrint this help page."
echo -e "\t-i\tInstall something."
echo -e "\t-V\tShow script version."
echo -e "\t-v\tVerbose mode."
echo
}
########## MAIN ##########
## DEPENDENCY CHECK
for PACKAGE in "${DEPENDENCIES[@]}" ; do
dependency_check "$PACKAGE"
done
if ! [ "$MISSING" ] ; then
:
else
echo -e "\n ${RED}Following dependencies are missing :\n\n${YEL}$MISSING\n\n ${CYN}Please install and re-run script !${CRS}"
rm $TMP/missingDeps
exit 1
fi
## CHECK FOR LOCAL INSTALL
if ! [ -d "$INSTALL_PATH" ] ; then
echo -e "\n ${RED}Helium directory not found !${CRS}"
install_helium
elif ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
echo -e "\n ${RED}Helium directory found but no executable named ${CYN}helium-browser.AppImage ${RED}!${CRS}"
install_helium
else
:
fi
## UPDATE
LOCAL_VERSION=$($INSTALL_PATH/helium-browser.AppImage --version | awk '{print $2}') LOCAL_VERSION=$($INSTALL_PATH/helium-browser.AppImage --version | awk '{print $2}')
### CHECK FROM EMPTY VERSION TAGS ### CHECK FOR EMPTY VERSION TAGS
if [ -z "$GIT_VERSION" ] ; then if [ -z "$GIT_VERSION" ] ; then
echo -e "\n ${RED}Empty version tag from ${CYN}GitHub ${RED}! Can't compare, exiting ...${CRS}" echo -e "\n ${RED}Empty version tag from ${CYN}GitHub ${RED}! Can't compare, exiting ...${CRS}"
exit 1 exit 1
@ -134,15 +166,26 @@ else
fi fi
### COMPARE LOCAL & REMOTE VERSION
LOCAL_VERSION_NUM=$(echo $LOCAL_VERSION | tr -d .)
GIT_VERSION_NUM=$(echo $GIT_VERSION | tr -d .)
if [ "$GIT_VERSION" == "$LOCAL_VERSION" ] ; then if [ "$GIT_VERSION" == "$LOCAL_VERSION" ] ; then
echo -e "\n ${GRN}Helium is up-to-date !${CRS}\n" echo -e "\n ${GRN}Helium is up-to-date !${CRS}\n"
else elif [ "$GIT_VERSION_NUM" -gt "$LOCAL_VERSION_NUM" ] ; then
echo -e "\n ${RED}Helium is updatable !${CRS}\n" echo -e "\n ${RED}Helium is updatable !${CRS}\n"
echo -e " ${CYN}Local Version : ${CRS}${LOCAL_VERSION}" echo -e " ${CYN}Local Version :\t${CRS}${LOCAL_VERSION}"
echo -e " ${CYN}GitHub Version : ${CRS}${GIT_VERSION}\n" echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n"
update_helium update_helium
else
echo -e "\n ${RED}Version tags malformed or you are using a Beta version !${CRS}\n"
echo -e " ${CYN}Local Version :\t${CRS}${LOCAL_VERSION}"
echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n"
echo -e " ${RED}Update failed ... Exiting ...${CRS}\n"
exit 1
fi fi
rm -rf $TMP rm -rf $TMP