Clean up and refinements

This commit is contained in:
Fr4nz D13trich 2025-12-21 23:22:42 +01:00
parent f633a04f98
commit f909883f57
3 changed files with 117 additions and 103 deletions

View file

@ -22,38 +22,33 @@ SCRIPT_PATH=$HOME/.local/bin
## GLOBAL VARIABLES ## GLOBAL VARIABLES
SCRIPT_NAME="Helium Helper Script" SCRIPT_NAME="Helium Helper Script"
SCRIPT_VERSION="0.5.1" SCRIPT_VERSION="0.5.1"
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}')
########## FUNCTIONS ########### ########## FUNCTIONS ###########
### DEPENDENCIES ### DEPENDENCIES
dependency_check() { cmd_query() {
cmd_query() {
local PACKAGE="$1" local PACKAGE="$1"
if command -v "$PACKAGE" >/dev/null 2>&1 ; then if ! command -v "$PACKAGE" >/dev/null 2>&1 ; then
:
else
echo "$PACKAGE" >> $TMP/missingDeps echo "$PACKAGE" >> $TMP/missingDeps
fi fi
} }
dependency_check () {
DEPENDENCIES=("curl" "wget")
mkdir -p $TMP
for PACKAGE in "${DEPENDENCIES[@]}" ; do for PACKAGE in "${DEPENDENCIES[@]}" ; do
cmd_query "$PACKAGE" cmd_query "$PACKAGE"
done done
if ! [ "$MISSING" ] ; then if [ -f "$TMP/missingDeps" ] ; then
: MISSING=$(cat $TMP/missingDeps)
echo -e "\n ${RED}Following dependencies are missing :\n\n${YEL}$MISSING\n\n ${CYN}Please install and re-run script !${CRS}"
else exit_clean
echo -e "\n ${RED}Following dependencies are missing :\n\n${YEL}$MISSING\n\n ${CYN}Please install and re-run script!${CRS}" exit
rm $TMP/missingDeps
exit 1
fi fi
} }
@ -63,15 +58,12 @@ local_check() {
if ! [ -d "$INSTALL_PATH" ] ; then if ! [ -d "$INSTALL_PATH" ] ; then
echo -e "\n ${RED}Helium directory not found!${CRS}" echo -e "\n ${RED}Helium directory not found!${CRS}"
install_helium install_helium
exit 1 exit
elif ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then 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}" echo -e "\n ${RED}Helium directory found but no executable named ${CYN}helium-browser.AppImage${RED}!${CRS}"
install_helium install_helium
exit 1 exit
else
:
fi fi
} }
@ -81,10 +73,7 @@ install_helium() {
if [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then if [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
echo -e "\n ${CYN}Helium AppImage found! Trying to update...${CRS}" echo -e "\n ${CYN}Helium AppImage found! Trying to update...${CRS}"
update_helium update_helium
exit 0 exit
else
:
fi fi
@ -100,12 +89,11 @@ install_helium() {
mkdir -p $INSTALL_PATH mkdir -p $INSTALL_PATH
mv $TMP/$GIT_FILENAME $INSTALL_PATH/helium-browser.AppImage mv $TMP/$GIT_FILENAME $INSTALL_PATH/helium-browser.AppImage
echo -e "\n ${GRN}Helium is installed!${CRS}\n" echo -e "\n ${GRN}Helium is installed!${CRS}\n"
clean_tmp exit
exit 0
elif [[ "$CONFIRM_INSTALL" == "n" || "$CONFIRM_INSTALL" == "N" ]] ; then elif [[ "$CONFIRM_INSTALL" == "n" || "$CONFIRM_INSTALL" == "N" ]] ; then
echo -e "\n ${RED}Installation cancelled!${CRS}\n" echo -e "\n ${RED}Installation cancelled!${CRS}\n"
exit 1 exit
else else
echo -e " ${YEL}Invalid response!${CRS}\n" echo -e " ${YEL}Invalid response!${CRS}\n"
@ -115,15 +103,15 @@ install_helium() {
done done
} }
### LAUNCHER ### LAUNCHER --> TO DO
add_launcher() { add_launcher() {
if ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then if ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
echo -e "\n ${RED}Helium AppImage not found! Can't add launcher...${CRS}" echo -e "\n ${RED}Helium AppImage not found! Can't add launcher...${CRS}"
exit 1 exit
else else
echo -e "\n ${RED}Not implemented yet...${CRS}" echo -e "\n ${RED}Not implemented yet...${CRS}"
exit 0 exit
fi fi
} }
@ -131,18 +119,16 @@ add_launcher() {
### UPDATE ### UPDATE
update_helium() { update_helium() {
LOCAL_VERSION=$($INSTALL_PATH/helium-browser.AppImage --version | awk '{print $2}') LOCAL_VERSION=$($INSTALL_PATH/helium-browser.AppImage --version | 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}')
### CHECK FOR 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
elif [ -z "$LOCAL_VERSION" ] ; then elif [ -z "$LOCAL_VERSION" ] ; then
echo -e "\n ${RED}Empty version tag from ${CYN}local AppImage${RED}! Can't compare, exiting...${CRS}" echo -e "\n ${RED}Empty version tag from ${CYN}local AppImage${RED}! Can't compare, exiting...${CRS}"
exit 1 exit
else
:
fi fi
@ -167,15 +153,17 @@ update_helium() {
mkdir -p $TMP mkdir -p $TMP
wget -P $TMP $GIT_URL -q --show-progress wget -P $TMP $GIT_URL -q --show-progress
chmod +x $TMP/$GIT_FILENAME chmod +x $TMP/$GIT_FILENAME
rm $INSTALL_PATH/helium-browser.OldAppImage >/dev/null 2>&1 if [ -f "$INSTALL_PATH/helium-browser.OldAppImage" ] ; then
mv $INSTALL_PATH/helium-browser.AppImage $INSTALL_PATH/helium-browser.OldAppImage >/dev/null 2>&1 rm $INSTALL_PATH/helium-browser.OldAppImage
fi
mv $INSTALL_PATH/helium-browser.AppImage $INSTALL_PATH/helium-browser.Old
mv $TMP/$GIT_FILENAME $INSTALL_PATH/helium-browser.AppImage mv $TMP/$GIT_FILENAME $INSTALL_PATH/helium-browser.AppImage
echo -e "\n ${GRN}Helium is up-to-date !${CRS}\n" echo -e "\n ${GRN}Helium is up-to-date !${CRS}\n"
break break
elif [[ "$CONFIRM" == "n" || "$CONFIRM" == "N" ]] ; then elif [[ "$CONFIRM" == "n" || "$CONFIRM" == "N" ]] ; then
echo -e "\n ${RED}Update cancelled!${CRS}\n" echo -e "\n ${RED}Update cancelled!${CRS}\n"
exit 1 exit
else else
echo -e " ${YEL}Invalid response!${CRS}\n" echo -e " ${YEL}Invalid response!${CRS}\n"
@ -189,21 +177,21 @@ update_helium() {
echo -e " ${CYN}Local Version :\t${CRS}${LOCAL_VERSION}" echo -e " ${CYN}Local Version :\t${CRS}${LOCAL_VERSION}"
echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n" echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n"
echo -e " ${RED}Update failed... Exiting...${CRS}\n" echo -e " ${RED}Update failed... Exiting...${CRS}\n"
exit 1 exit
fi fi
} }
### AUTOMATIC UPDATE ### AUTOMATIC UPDATE --> TO DO
auto_update() { auto_update() {
if ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then if ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
echo -e "\n ${RED}Helium AppImage not found! Can't add auto update script...${CRS}" echo -e "\n ${RED}Helium AppImage not found! Can't add auto update script...${CRS}"
exit 1 exit
else else
echo -e "\n ${RED}Not implemented yet...${CRS}" echo -e "\n ${RED}Not implemented yet...${CRS}"
exit 0 exit
fi fi
} }
@ -218,11 +206,11 @@ remove_helium() {
if [[ "$CONFIRM_REMOVE" == "" || "$CONFIRM_REMOVE" == "y" || "$CONFIRM_REMOVE" == "Y" ]] ; then if [[ "$CONFIRM_REMOVE" == "" || "$CONFIRM_REMOVE" == "y" || "$CONFIRM_REMOVE" == "Y" ]] ; then
rm -rf $INSTALL_PATH rm -rf $INSTALL_PATH
echo -e "\n ${RED}Helium removed!${CRS}\n" echo -e "\n ${RED}Helium removed!${CRS}\n"
exit 0 exit
elif [[ "$CONFIRM_REMOVE" == "n" || "$CONFIRM_REMOVE" == "N" ]] ; then elif [[ "$CONFIRM_REMOVE" == "n" || "$CONFIRM_REMOVE" == "N" ]] ; then
echo -e "\n ${RED}Removal cancelled!${CRS}\n" echo -e "\n ${RED}Removal cancelled!${CRS}\n"
exit 0 exit
else else
echo -e " ${YEL}Invalid response!${CRS}\n" echo -e " ${YEL}Invalid response!${CRS}\n"
@ -233,7 +221,7 @@ remove_helium() {
else else
echo -e "\n ${RED}Can't remove Helium! ${YEL}${INSTALL_PATH} ${RED}directory not found...${CRS}\n" echo -e "\n ${RED}Can't remove Helium! ${YEL}${INSTALL_PATH} ${RED}directory not found...${CRS}\n"
exit 1 exit
fi fi
} }
@ -241,19 +229,19 @@ remove_helium() {
### SCRIPT VERSION ### SCRIPT VERSION
script_version() { script_version() {
echo -e "\n ${CYN}Helium Helper Script Version : ${GRN}${SCRIPT_VERSION}${CRS}\n" echo -e "\n ${CYN}Helium Helper Script Version : ${GRN}${SCRIPT_VERSION}${CRS}\n"
exit 0 exit
} }
### UPDATE SCRIPT ### UPDATE SCRIPT --> TO DO
update_script() { update_script() {
if ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then if ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
echo -e "\n ${RED}Helium AppImage not found! Can't update script...${CRS}" echo -e "\n ${RED}Helium AppImage not found! Can't update script...${CRS}"
exit 1 exit
else else
echo -e "\n ${RED}Not implemented yet...${CRS}" echo -e "\n ${RED}Not implemented yet...${CRS}"
exit 0 exit
fi fi
} }
@ -261,18 +249,16 @@ update_script() {
### COMPARE APPIMAGE VERSION ### COMPARE APPIMAGE VERSION
compare_version() { compare_version() {
LOCAL_VERSION=$($INSTALL_PATH/helium-browser.AppImage --version | awk '{print $2}') LOCAL_VERSION=$($INSTALL_PATH/helium-browser.AppImage --version | 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}')
### CHECK FOR 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
elif [ -z "$LOCAL_VERSION" ] ; then elif [ -z "$LOCAL_VERSION" ] ; then
echo -e "\n ${RED}Empty version tag from ${CYN}local AppImage${RED}! Can't compare, exiting...${CRS}" echo -e "\n ${RED}Empty version tag from ${CYN}local AppImage${RED}! Can't compare, exiting...${CRS}"
exit 1 exit
else
:
fi fi
@ -284,20 +270,20 @@ compare_version() {
echo -e "\n ${GRN}Helium is up-to-date!${CRS}\n" echo -e "\n ${GRN}Helium is up-to-date!${CRS}\n"
echo -e " ${CYN}Local Version :\t${CRS}${LOCAL_VERSION}" echo -e " ${CYN}Local Version :\t${CRS}${LOCAL_VERSION}"
echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n" echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n"
exit 0 exit
elif [ "$GIT_VERSION_NUM" -gt "$LOCAL_VERSION_NUM" ] ; then elif [ "$GIT_VERSION_NUM" -gt "$LOCAL_VERSION_NUM" ] ; then
echo -e "\n ${YEL}Helium is updatable!${CRS}\n" echo -e "\n ${YEL}Helium is updatable!${CRS}\n"
echo -e " ${CYN}Local Version :\t${CRS}${LOCAL_VERSION}" echo -e " ${CYN}Local Version :\t${CRS}${LOCAL_VERSION}"
echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n" echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n"
exit 0 exit
else else
echo -e "\n ${RED}Version tags malformed or you are using a Beta version!${CRS}\n" 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}Local Version :\t${CRS}${LOCAL_VERSION}"
echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n" echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n"
echo -e " ${RED}Update failed ... Exiting ...${CRS}\n" echo -e " ${RED}Update failed ... Exiting ...${CRS}\n"
exit 1 exit
fi fi
} }
@ -318,14 +304,19 @@ help() {
echo -e "\t-S\tUpdate script ${RED}--> Not yet working${CRS}" echo -e "\t-S\tUpdate script ${RED}--> Not yet working${CRS}"
echo -e "\t-h\tPrint this help page.\n" echo -e "\t-h\tPrint this help page.\n"
echo -e "Configured locations:\n" echo -e "Configured locations:\n"
echo -e "\t${GRN}${INSTALL_PATH}${CRS}\t\tInstall location" echo -e "\t${YEL}${INSTALL_PATH}${CRS}\t\tInstall location"
echo -e "\t${GRN}${LAUNCHER_PATH}${CRS}\tLauncher location" echo -e "\t${YEL}${LAUNCHER_PATH}${CRS}\tLauncher location"
echo -e "\t${GRN}${SCRIPT_PATH}${CRS}\t\t\tScript location\n" echo -e "\t${YEL}${SCRIPT_PATH}${CRS}\t\t\tScript location\n"
} }
### CLEAN ### EXIT CLEAN
clean_tmp() { exit_clean() {
if [ -d "$TMP" ] ; then
rm -rf $TMP rm -rf $TMP
fi
exit
} }
########## MAIN ########## ########## MAIN ##########
@ -337,21 +328,28 @@ while getopts ":i,:L,:u,:U,:r,:c,:s,:S,:h" OPTION ; do
echo -e "\n ${YEL}Installing Helium Browser...${CRS}" echo -e "\n ${YEL}Installing Helium Browser...${CRS}"
dependency_check dependency_check
install_helium install_helium
clean_tmp exit_clean
exit ;; exit ;;
L) L)
echo -e "\n ${YEL}Adding Helium Browser launcher...${CRS}" echo -e "\n ${YEL}Adding Helium Browser launcher...${CRS}"
dependency_check dependency_check
add_launcher add_launcher
#clean_tmp exit_clean
exit ;; exit ;;
u) u)
echo -e "\n ${YEL}Updating Helium Browser...${CRS}" echo -e "\n ${YEL}Updating Helium Browser...${CRS}"
dependency_check dependency_check
update_helium update_helium
clean_tmp exit_clean
exit ;;
U)
echo -e "\n ${YEL}Enabling automatic updates...${CRS}"
dependency_check
auto_update
exit_clean
exit ;; exit ;;
r) r)
@ -363,18 +361,26 @@ while getopts ":i,:L,:u,:U,:r,:c,:s,:S,:h" OPTION ; do
echo -e "\n ${YEL}Comparing remote to local version...${CRS}" echo -e "\n ${YEL}Comparing remote to local version...${CRS}"
dependency_check dependency_check
compare_version compare_version
exit_clean
exit ;; exit ;;
s) s)
script_version script_version
exit ;; exit ;;
S)
echo -e "\n ${YEL}Updating script...${CRS}"
dependency_check
update_script
exit_clean
exit ;;
h) h)
help help
exit;; exit;;
*) *)
echo -e "\n ${YEL}Option not recognized... Refer to help below!${CRS}" echo -e "\n ${YEL}Option ${RED}-t${YEL} not recognized... Refer to help below!${CRS}"
help help
exit;; exit;;
@ -392,6 +398,4 @@ local_check
update_helium update_helium
## CLEAN ## CLEAN
clean_tmp exit_clean
exit 0

49
test.sh
View file

@ -1,33 +1,36 @@
#!/bin/bash #!/bin/bash
TMP=/tmp/Helium
DEPENDENCIES=("curl" "wget" "xeggw")
### DEPENDENCIES --> NEEDS FIXING
dependency_check () (
mkdir -p $TMP
cmd_query() {
local PACKAGE="$1"
INSTALL_PATH=$HOME/.apps/Helium if command -v "$PACKAGE" >/dev/null 2>&1 ; then
:
GIT_VERSION=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | grep "tag_name" | tr -d \", | awk '{print $2}') else
LOCAL_VERSION=$($INSTALL_PATH/helium-browser.AppImage --version | awk '{print $2}') echo "$PACKAGE" >> $TMP/missingDeps
LOCAL_VERSION_NUM=$(echo $LOCAL_VERSION | tr -d .) fi
GIT_VERSION_NUM=$(echo $GIT_VERSION | tr -d .) }
echo $GIT_VERSION for PACKAGE in "${DEPENDENCIES[@]}" ; do
echo $LOCAL_VERSION cmd_query "$PACKAGE"
echo
echo $GIT_VERSION_NUM
echo $LOCAL_VERSION_NUM
if [ "$GIT_VERSION_NUM" -eq "$LOCAL_VERSION_NUM" ] ; then done
echo "Version is equal"
exit 0
elif [ "$GIT_VERSION_NUM" -gt "$LOCAL_VERSION_NUM" ] ; then if ! [ -f "$TMP/missingDeps" ] ; then
echo "Version is more recent" :
exit 0
elif [ "$GIT_VERSION_NUM" -lt "$LOCAL_VERSION_NUM" ] ; then else
echo "Version is older" MISSING=$(cat $TMP/missingDeps)
exit 0 echo -e "\n ${RED}Following dependencies are missing :\n\n${YEL}$MISSING\n\n ${CYN}Please install and re-run script !${CRS}"
else fi
echo "Something's fishy... EXITING" )
exit 1
fi dependency_check
rm -rf $TMP
exit

13
todo.md
View file

@ -4,11 +4,18 @@
- Improved Version comparasing - Improved Version comparasing
- Added options [ -i | -u | -c | -s | -h ] - Added options [ -i | -u | -c | -s | -h ]
- Pre - Released Version 0.5 - Pre - Released Version 0.5
- Clean up function added
- Remover function added --> Need to extend after launcher implementation
- Dummy functions added for:
- Desktop entry
- Auto Update
- Script update
## Add ## Add
- Internet connectivity check in [Auto Update Script](https://lab.c95.org/fr4nz/shell-scripts/src/branch/main/helium-browser/helium_auto_update.sh) - Internet connectivity check in [Auto Update Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_auto_update.sh)
- Desktop entry [Helper Script](https://lab.c95.org/fr4nz/shell-scripts/src/branch/main/helium-browser/helium_helper.sh) - Desktop entry [Helper Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_helper.sh)
- Desktop entry updater [Helper Script](https://lab.c95.org/fr4nz/shell-scripts/src/branch/main/helium-browser/helium_helper.sh) & [Auto Update Script](https://lab.c95.org/fr4nz/shell-scripts/src/branch/main/helium-browser/helium_auto_update.sh) - Desktop entry updater [Helper Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_helper.sh) & [Auto Update Script](https://lab.c95.org/fr4nz/helium-helper/src/branch/main/helium_auto_update.sh)
- Script updater - Script updater
- Architecture detection - Architecture detection
- Uninstaller --> Partially done - Uninstaller --> Partially done