Clean up and refinements
This commit is contained in:
parent
f633a04f98
commit
f909883f57
3 changed files with 117 additions and 103 deletions
156
helium_helper.sh
156
helium_helper.sh
|
|
@ -22,39 +22,34 @@ SCRIPT_PATH=$HOME/.local/bin
|
|||
## GLOBAL VARIABLES
|
||||
SCRIPT_NAME="Helium Helper Script"
|
||||
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 ###########
|
||||
|
||||
### DEPENDENCIES
|
||||
dependency_check() {
|
||||
cmd_query() {
|
||||
local PACKAGE="$1"
|
||||
cmd_query() {
|
||||
local PACKAGE="$1"
|
||||
|
||||
if command -v "$PACKAGE" >/dev/null 2>&1 ; then
|
||||
:
|
||||
if ! command -v "$PACKAGE" >/dev/null 2>&1 ; then
|
||||
echo "$PACKAGE" >> $TMP/missingDeps
|
||||
|
||||
else
|
||||
echo "$PACKAGE" >> $TMP/missingDeps
|
||||
|
||||
fi
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
dependency_check () {
|
||||
DEPENDENCIES=("curl" "wget")
|
||||
mkdir -p $TMP
|
||||
|
||||
for PACKAGE in "${DEPENDENCIES[@]}" ; do
|
||||
cmd_query "$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
|
||||
|
||||
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}"
|
||||
exit_clean
|
||||
exit
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -63,15 +58,12 @@ local_check() {
|
|||
if ! [ -d "$INSTALL_PATH" ] ; then
|
||||
echo -e "\n ${RED}Helium directory not found!${CRS}"
|
||||
install_helium
|
||||
exit 1
|
||||
exit
|
||||
|
||||
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
|
||||
exit 1
|
||||
|
||||
else
|
||||
:
|
||||
exit
|
||||
|
||||
fi
|
||||
}
|
||||
|
|
@ -81,10 +73,7 @@ install_helium() {
|
|||
if [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
|
||||
echo -e "\n ${CYN}Helium AppImage found! Trying to update...${CRS}"
|
||||
update_helium
|
||||
exit 0
|
||||
|
||||
else
|
||||
:
|
||||
exit
|
||||
|
||||
fi
|
||||
|
||||
|
|
@ -100,12 +89,11 @@ install_helium() {
|
|||
mkdir -p $INSTALL_PATH
|
||||
mv $TMP/$GIT_FILENAME $INSTALL_PATH/helium-browser.AppImage
|
||||
echo -e "\n ${GRN}Helium is installed!${CRS}\n"
|
||||
clean_tmp
|
||||
exit 0
|
||||
exit
|
||||
|
||||
elif [[ "$CONFIRM_INSTALL" == "n" || "$CONFIRM_INSTALL" == "N" ]] ; then
|
||||
echo -e "\n ${RED}Installation cancelled!${CRS}\n"
|
||||
exit 1
|
||||
exit
|
||||
|
||||
else
|
||||
echo -e " ${YEL}Invalid response!${CRS}\n"
|
||||
|
|
@ -115,15 +103,15 @@ install_helium() {
|
|||
done
|
||||
}
|
||||
|
||||
### LAUNCHER
|
||||
### LAUNCHER --> TO DO
|
||||
add_launcher() {
|
||||
if ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
|
||||
echo -e "\n ${RED}Helium AppImage not found! Can't add launcher...${CRS}"
|
||||
exit 1
|
||||
exit
|
||||
|
||||
else
|
||||
echo -e "\n ${RED}Not implemented yet...${CRS}"
|
||||
exit 0
|
||||
exit
|
||||
|
||||
fi
|
||||
}
|
||||
|
|
@ -131,18 +119,16 @@ add_launcher() {
|
|||
### UPDATE
|
||||
update_helium() {
|
||||
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
|
||||
if [ -z "$GIT_VERSION" ] ; then
|
||||
echo -e "\n ${RED}Empty version tag from ${CYN}GitHub${RED}! Can't compare, exiting...${CRS}"
|
||||
exit 1
|
||||
exit
|
||||
|
||||
elif [ -z "$LOCAL_VERSION" ] ; then
|
||||
echo -e "\n ${RED}Empty version tag from ${CYN}local AppImage${RED}! Can't compare, exiting...${CRS}"
|
||||
exit 1
|
||||
|
||||
else
|
||||
:
|
||||
exit
|
||||
|
||||
fi
|
||||
|
||||
|
|
@ -167,15 +153,17 @@ update_helium() {
|
|||
mkdir -p $TMP
|
||||
wget -P $TMP $GIT_URL -q --show-progress
|
||||
chmod +x $TMP/$GIT_FILENAME
|
||||
rm $INSTALL_PATH/helium-browser.OldAppImage >/dev/null 2>&1
|
||||
mv $INSTALL_PATH/helium-browser.AppImage $INSTALL_PATH/helium-browser.OldAppImage >/dev/null 2>&1
|
||||
if [ -f "$INSTALL_PATH/helium-browser.OldAppImage" ] ; then
|
||||
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
|
||||
echo -e "\n ${GRN}Helium is up-to-date !${CRS}\n"
|
||||
break
|
||||
|
||||
elif [[ "$CONFIRM" == "n" || "$CONFIRM" == "N" ]] ; then
|
||||
echo -e "\n ${RED}Update cancelled!${CRS}\n"
|
||||
exit 1
|
||||
exit
|
||||
|
||||
else
|
||||
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}GitHub Version :\t${CRS}${GIT_VERSION}\n"
|
||||
echo -e " ${RED}Update failed... Exiting...${CRS}\n"
|
||||
exit 1
|
||||
exit
|
||||
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
### AUTOMATIC UPDATE
|
||||
### AUTOMATIC UPDATE --> TO DO
|
||||
auto_update() {
|
||||
if ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
|
||||
echo -e "\n ${RED}Helium AppImage not found! Can't add auto update script...${CRS}"
|
||||
exit 1
|
||||
exit
|
||||
|
||||
else
|
||||
echo -e "\n ${RED}Not implemented yet...${CRS}"
|
||||
exit 0
|
||||
exit
|
||||
|
||||
fi
|
||||
}
|
||||
|
|
@ -218,11 +206,11 @@ remove_helium() {
|
|||
if [[ "$CONFIRM_REMOVE" == "" || "$CONFIRM_REMOVE" == "y" || "$CONFIRM_REMOVE" == "Y" ]] ; then
|
||||
rm -rf $INSTALL_PATH
|
||||
echo -e "\n ${RED}Helium removed!${CRS}\n"
|
||||
exit 0
|
||||
exit
|
||||
|
||||
elif [[ "$CONFIRM_REMOVE" == "n" || "$CONFIRM_REMOVE" == "N" ]] ; then
|
||||
echo -e "\n ${RED}Removal cancelled!${CRS}\n"
|
||||
exit 0
|
||||
exit
|
||||
|
||||
else
|
||||
echo -e " ${YEL}Invalid response!${CRS}\n"
|
||||
|
|
@ -233,7 +221,7 @@ remove_helium() {
|
|||
|
||||
else
|
||||
echo -e "\n ${RED}Can't remove Helium! ${YEL}${INSTALL_PATH} ${RED}directory not found...${CRS}\n"
|
||||
exit 1
|
||||
exit
|
||||
|
||||
fi
|
||||
}
|
||||
|
|
@ -241,19 +229,19 @@ remove_helium() {
|
|||
### SCRIPT VERSION
|
||||
script_version() {
|
||||
echo -e "\n ${CYN}Helium Helper Script Version : ${GRN}${SCRIPT_VERSION}${CRS}\n"
|
||||
exit 0
|
||||
exit
|
||||
|
||||
}
|
||||
|
||||
### UPDATE SCRIPT
|
||||
### UPDATE SCRIPT --> TO DO
|
||||
update_script() {
|
||||
if ! [ -f "$INSTALL_PATH/helium-browser.AppImage" ] ; then
|
||||
echo -e "\n ${RED}Helium AppImage not found! Can't update script...${CRS}"
|
||||
exit 1
|
||||
exit
|
||||
|
||||
else
|
||||
echo -e "\n ${RED}Not implemented yet...${CRS}"
|
||||
exit 0
|
||||
exit
|
||||
|
||||
fi
|
||||
}
|
||||
|
|
@ -261,18 +249,16 @@ update_script() {
|
|||
### COMPARE APPIMAGE VERSION
|
||||
compare_version() {
|
||||
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
|
||||
if [ -z "$GIT_VERSION" ] ; then
|
||||
echo -e "\n ${RED}Empty version tag from ${CYN}GitHub${RED}! Can't compare, exiting...${CRS}"
|
||||
exit 1
|
||||
exit
|
||||
|
||||
elif [ -z "$LOCAL_VERSION" ] ; then
|
||||
echo -e "\n ${RED}Empty version tag from ${CYN}local AppImage${RED}! Can't compare, exiting...${CRS}"
|
||||
exit 1
|
||||
|
||||
else
|
||||
:
|
||||
exit
|
||||
|
||||
fi
|
||||
|
||||
|
|
@ -284,20 +270,20 @@ compare_version() {
|
|||
echo -e "\n ${GRN}Helium is up-to-date!${CRS}\n"
|
||||
echo -e " ${CYN}Local Version :\t${CRS}${LOCAL_VERSION}"
|
||||
echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n"
|
||||
exit 0
|
||||
exit
|
||||
|
||||
elif [ "$GIT_VERSION_NUM" -gt "$LOCAL_VERSION_NUM" ] ; then
|
||||
echo -e "\n ${YEL}Helium is updatable!${CRS}\n"
|
||||
echo -e " ${CYN}Local Version :\t${CRS}${LOCAL_VERSION}"
|
||||
echo -e " ${CYN}GitHub Version :\t${CRS}${GIT_VERSION}\n"
|
||||
exit 0
|
||||
exit
|
||||
|
||||
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
|
||||
exit
|
||||
|
||||
fi
|
||||
}
|
||||
|
|
@ -318,14 +304,19 @@ help() {
|
|||
echo -e "\t-S\tUpdate script ${RED}--> Not yet working${CRS}"
|
||||
echo -e "\t-h\tPrint this help page.\n"
|
||||
echo -e "Configured locations:\n"
|
||||
echo -e "\t${GRN}${INSTALL_PATH}${CRS}\t\tInstall location"
|
||||
echo -e "\t${GRN}${LAUNCHER_PATH}${CRS}\tLauncher location"
|
||||
echo -e "\t${GRN}${SCRIPT_PATH}${CRS}\t\t\tScript location\n"
|
||||
echo -e "\t${YEL}${INSTALL_PATH}${CRS}\t\tInstall location"
|
||||
echo -e "\t${YEL}${LAUNCHER_PATH}${CRS}\tLauncher location"
|
||||
echo -e "\t${YEL}${SCRIPT_PATH}${CRS}\t\t\tScript location\n"
|
||||
}
|
||||
|
||||
### CLEAN
|
||||
clean_tmp() {
|
||||
rm -rf $TMP
|
||||
### EXIT CLEAN
|
||||
exit_clean() {
|
||||
if [ -d "$TMP" ] ; then
|
||||
rm -rf $TMP
|
||||
|
||||
fi
|
||||
|
||||
exit
|
||||
}
|
||||
|
||||
########## 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}"
|
||||
dependency_check
|
||||
install_helium
|
||||
clean_tmp
|
||||
exit_clean
|
||||
exit ;;
|
||||
|
||||
L)
|
||||
echo -e "\n ${YEL}Adding Helium Browser launcher...${CRS}"
|
||||
dependency_check
|
||||
add_launcher
|
||||
#clean_tmp
|
||||
exit_clean
|
||||
exit ;;
|
||||
|
||||
u)
|
||||
echo -e "\n ${YEL}Updating Helium Browser...${CRS}"
|
||||
dependency_check
|
||||
update_helium
|
||||
clean_tmp
|
||||
exit_clean
|
||||
exit ;;
|
||||
|
||||
U)
|
||||
echo -e "\n ${YEL}Enabling automatic updates...${CRS}"
|
||||
dependency_check
|
||||
auto_update
|
||||
exit_clean
|
||||
exit ;;
|
||||
|
||||
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}"
|
||||
dependency_check
|
||||
compare_version
|
||||
exit_clean
|
||||
exit ;;
|
||||
|
||||
s)
|
||||
script_version
|
||||
exit ;;
|
||||
|
||||
S)
|
||||
echo -e "\n ${YEL}Updating script...${CRS}"
|
||||
dependency_check
|
||||
update_script
|
||||
exit_clean
|
||||
exit ;;
|
||||
|
||||
h)
|
||||
help
|
||||
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
|
||||
exit;;
|
||||
|
||||
|
|
@ -392,6 +398,4 @@ local_check
|
|||
update_helium
|
||||
|
||||
## CLEAN
|
||||
clean_tmp
|
||||
|
||||
exit 0
|
||||
exit_clean
|
||||
|
|
|
|||
51
test.sh
51
test.sh
|
|
@ -1,33 +1,36 @@
|
|||
#!/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}')
|
||||
LOCAL_VERSION=$($INSTALL_PATH/helium-browser.AppImage --version | awk '{print $2}')
|
||||
else
|
||||
echo "$PACKAGE" >> $TMP/missingDeps
|
||||
|
||||
LOCAL_VERSION_NUM=$(echo $LOCAL_VERSION | tr -d .)
|
||||
GIT_VERSION_NUM=$(echo $GIT_VERSION | tr -d .)
|
||||
fi
|
||||
}
|
||||
|
||||
echo $GIT_VERSION
|
||||
echo $LOCAL_VERSION
|
||||
echo
|
||||
echo $GIT_VERSION_NUM
|
||||
echo $LOCAL_VERSION_NUM
|
||||
for PACKAGE in "${DEPENDENCIES[@]}" ; do
|
||||
cmd_query "$PACKAGE"
|
||||
|
||||
if [ "$GIT_VERSION_NUM" -eq "$LOCAL_VERSION_NUM" ] ; then
|
||||
echo "Version is equal"
|
||||
exit 0
|
||||
done
|
||||
|
||||
elif [ "$GIT_VERSION_NUM" -gt "$LOCAL_VERSION_NUM" ] ; then
|
||||
echo "Version is more recent"
|
||||
exit 0
|
||||
if ! [ -f "$TMP/missingDeps" ] ; then
|
||||
:
|
||||
|
||||
elif [ "$GIT_VERSION_NUM" -lt "$LOCAL_VERSION_NUM" ] ; then
|
||||
echo "Version is older"
|
||||
exit 0
|
||||
else
|
||||
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
|
||||
echo "Something's fishy... EXITING"
|
||||
exit 1
|
||||
|
||||
fi
|
||||
fi
|
||||
)
|
||||
|
||||
dependency_check
|
||||
rm -rf $TMP
|
||||
exit
|
||||
13
todo.md
13
todo.md
|
|
@ -4,11 +4,18 @@
|
|||
- Improved Version comparasing
|
||||
- Added options [ -i | -u | -c | -s | -h ]
|
||||
- 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
|
||||
- Internet connectivity check in [Auto Update Script](https://lab.c95.org/fr4nz/shell-scripts/src/branch/main/helium-browser/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 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)
|
||||
- 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/helium-helper/src/branch/main/helium_helper.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
|
||||
- Architecture detection
|
||||
- Uninstaller --> Partially done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue