Remote script check simplified; Icon added to desktop notification
This commit is contained in:
parent
2f8d7b8246
commit
6dccf9c1e4
1 changed files with 19 additions and 25 deletions
|
|
@ -11,7 +11,7 @@ APP_NAME_LONG="Helium Web Browser"
|
|||
SOURCE="GitHub"
|
||||
SCRIPT_NAME="$APP_NAME quiet updater"
|
||||
SCRIPT_FILE_NAME="helium_auto_update.sh"
|
||||
SCRIPT_VERSION="0.5.5"
|
||||
SCRIPT_VERSION="0.5.6"
|
||||
ALIAS="auto-update-helium"
|
||||
|
||||
## LOCATIONS
|
||||
|
|
@ -22,6 +22,7 @@ BACKUP_PATH=$INSTALL_PATH/assets/backup
|
|||
LOG_PATH=$INSTALL_PATH/assets/logs
|
||||
LOG=$LOG_PATH/log
|
||||
LAUNCHER_PATH=$HOME/.local/share/applications
|
||||
ICON=$CONFIG_PATH/icon/helium.png
|
||||
SCRIPT_PATH=$HOME/.local/bin
|
||||
DATE=$(date)
|
||||
|
||||
|
|
@ -73,35 +74,26 @@ dependency_check () {
|
|||
}
|
||||
|
||||
### UPDATE SCRIPT
|
||||
remote_script_check() {
|
||||
REMOTE_SCRIPT_URL=https://lab.c95.org/fr4nz/helium-helper/raw/branch/main/$SCRIPT_FILE_NAME
|
||||
mkdir -p $TMP
|
||||
wget -P $TMP $REMOTE_SCRIPT_URL -q
|
||||
chmod +x $TMP/$SCRIPT_FILE_NAME
|
||||
}
|
||||
|
||||
update_script() {
|
||||
remote_script_check
|
||||
|
||||
### CHECK FOR LOCAL SCRIPT
|
||||
if ! [ -f "$SCRIPT_PATH/$SCRIPT_FILE_NAME" ] ; then
|
||||
echo "${DATE} | Failed to update script - local file not found" >> $LOG
|
||||
notify-send "Helium Helper" "Script update failed! See log for details"
|
||||
notify-send -i "$ICON" "Helium Helper" "Script update failed! See log for details"
|
||||
exit
|
||||
|
||||
fi
|
||||
|
||||
REMOTE_SCRIPT_VERSION=$($TMP/$SCRIPT_FILE_NAME -s | awk '{print $8}' | tr -d '\n' )
|
||||
REMOTE_SCRIPT_VERSION=$(curl -s https://lab.c95.org/fr4nz/helium-helper/raw/branch/main/$SCRIPT_FILE_NAME | grep -m 1 "SCRIPT_VERSION" | tr -d 'SCRIPT_VERSION="')
|
||||
|
||||
### CHECK FOR EMPTY VERSION TAGS
|
||||
if [ -z "$SCRIPT_VERSION" ] ; then
|
||||
echo "${DATE} | Failed to update script - Empty version tag --> local" >> $LOG
|
||||
notify-send "Helium Helper" "Script update failed! See log for details"
|
||||
notify-send -i "$ICON" "Helium Helper" "Script update failed! See log for details"
|
||||
exit
|
||||
|
||||
elif [ -z "$REMOTE_SCRIPT_VERSION" ] ; then
|
||||
echo "${DATE} | Failed to update script - Empty version tag --> $SOURCE" >> $LOG
|
||||
notify-send "Helium Helper" "Script update failed! See log for details"
|
||||
notify-send -i "$ICON" "Helium Helper" "Script update failed! See log for details"
|
||||
exit
|
||||
|
||||
fi
|
||||
|
|
@ -111,37 +103,38 @@ update_script() {
|
|||
REMOTE_SCRIPT_VERSION_NUM=$(echo $REMOTE_SCRIPT_VERSION | tr -d .)
|
||||
|
||||
if [ "$REMOTE_SCRIPT_VERSION" == "$SCRIPT_VERSION" ] ; then
|
||||
notify-send "Helium Helper" "Script is up-to-date"
|
||||
notify-send -i "$ICON" "Helium Helper" "Script is up-to-date"
|
||||
|
||||
elif [ "$REMOTE_SCRIPT_VERSION_NUM" -gt "$SCRIPT_VERSION_NUM" ] ; then
|
||||
mv $SCRIPT_PATH/$SCRIPT_FILE_NAME $BACKUP_PATH/$SCRIPT_FILE_NAME.old
|
||||
mkdir -p $TMP
|
||||
wget -P $TMP $REMOTE_SCRIPT_URL -q
|
||||
chmod +x $TMP/$SCRIPT_FILE_NAME
|
||||
mv $TMP/$SCRIPT_FILE_NAME $SCRIPT_PATH
|
||||
echo "${DATE} | Script updated" >> $LOG
|
||||
notify-send "Helium Helper" "Script updated"
|
||||
echo "${DATE} | Script updated to $REMOTE_SCRIPT_VERSION" >> $LOG
|
||||
notify-send -i "$ICON" "Helium Helper" "Script updated to $REMOTE_SCRIPT_VERSION"
|
||||
|
||||
else
|
||||
echo "${DATE} | Failed to update - Malformed version tags" >> $LOG
|
||||
notify-send "Helium Helper" "Script update failed! See log for details"
|
||||
notify-send -i "$ICON" "Helium Helper" "Script update failed! See log for details\n$REMOTE_SCRIPT_VERSION $SCRIPT_VERSION"
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
### UPDATE
|
||||
update_helium() {
|
||||
#update_script ### NEEDS REVIEW
|
||||
|
||||
LOCAL_VERSION=$($INSTALL_PATH/$APP_NAME.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 "${DATE} | Failed to update - Empty version tag --> $SOURCE" >> $LOG
|
||||
notify-send "Helium Helper" "Browser update failed! See log for details"
|
||||
notify-send -i "$ICON" "Helium Helper" "Browser update failed! See log for details"
|
||||
exit
|
||||
|
||||
elif [[ -z "$LOCAL_VERSION" ]] ; then
|
||||
echo "${DATE} | Failed to update - Empty version tag --> LOCAL" >> $LOG
|
||||
notify-send "Helium Helper" "Browser update failed! See log for details"
|
||||
notify-send -i "$ICON" "Helium Helper" "Browser update failed! See log for details"
|
||||
exit
|
||||
|
||||
fi
|
||||
|
|
@ -151,7 +144,7 @@ update_helium() {
|
|||
GIT_VERSION_NUM=$(echo $GIT_VERSION | tr -d .)
|
||||
|
||||
if [ "$GIT_VERSION" == "$LOCAL_VERSION" ] ; then
|
||||
notify-send "Helium Helper" "Browser is up-to-date"
|
||||
notify-send -i "$ICON" "Helium Helper" "Browser is up-to-date"
|
||||
|
||||
elif [ "$GIT_VERSION_NUM" -gt "$LOCAL_VERSION_NUM" ] ; then
|
||||
GIT_URL=$(curl -s https://api.github.com/repos/imputnet/helium-linux/releases/latest | grep "browser_download_url" | grep "x86_64.AppImage" | grep -v "zsync" | tr -d \" | awk '{print $2}')
|
||||
|
|
@ -167,11 +160,11 @@ update_helium() {
|
|||
cp $LAUNCHER_PATH/$APP_NAME.desktop $BACKUP_PATH/$APP_NAME.desktop.old
|
||||
sed -i "s|X-AppImage-Version=.*|X-AppImage-Version=$($INSTALL_PATH/$APP_NAME.AppImage --version | awk '{print $2}')|" $LAUNCHER_PATH/$APP_NAME.desktop
|
||||
echo "${DATE} | $APP_NAME updated to ${GIT_VERSION}" >> $LOG
|
||||
notify-send "Helium Helper" "Browser updated to $GIT_VERSION"
|
||||
notify-send -i "$ICON" "Helium Helper" "Browser updated to $GIT_VERSION"
|
||||
|
||||
else
|
||||
echo "${DATE} | Failed to update - Version tags malformed" >> $LOG
|
||||
notify-send "Helium Helper" "Browser update failed! See log for details"
|
||||
notify-send -i "$ICON" "Helium Helper" "Browser update failed! See log for details"
|
||||
exit
|
||||
|
||||
fi
|
||||
|
|
@ -216,6 +209,7 @@ while getopts ":a,:s,:S,:h" OPTION ; do
|
|||
case $OPTION in
|
||||
|
||||
S)
|
||||
dependency_check
|
||||
update_script
|
||||
exit_clean ;;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue