From 4f1d453e9ee42303f60ef2d39f300ded358617f6 Mon Sep 17 00:00:00 2001 From: Fr4nz D13trich Date: Sat, 27 Dec 2025 12:34:17 +0100 Subject: [PATCH] More accessible url variables --- helium_auto_update.sh | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/helium_auto_update.sh b/helium_auto_update.sh index e06b9cd..8077325 100755 --- a/helium_auto_update.sh +++ b/helium_auto_update.sh @@ -25,6 +25,8 @@ LAUNCHER_PATH=$HOME/.local/share/applications ICON=$CONFIG_PATH/icon/helium.png SCRIPT_PATH=$HOME/.local/bin DATE=$(date) +REMOTE_SCRIPT_URL=https://lab.c95.org/fr4nz/helium-helper/raw/branch/main/$SCRIPT_FILE_NAME +SOURCE_URL=https://api.github.com/repos/imputnet/helium-linux/releases/latest ########## FUNCTIONS ########### @@ -49,6 +51,7 @@ dependency_check () { if ! [ -d "$LOG_PATH" ] ; then mkdir -p $LOG_PATH + echo "########## $APP_NAME update log ##########" echo "${DATE} | Log created" >> $LOG fi @@ -75,8 +78,6 @@ dependency_check () { ### UPDATE SCRIPT update_script() { - REMOTE_SCRIPT_URL=https://lab.c95.org/fr4nz/helium-helper/raw/branch/main/$SCRIPT_FILE_NAME - ### CHECK FOR LOCAL SCRIPT if ! [ -f "$SCRIPT_PATH/$SCRIPT_FILE_NAME" ] ; then echo "${DATE} | Failed to update script - local file not found" >> $LOG @@ -85,7 +86,7 @@ update_script() { fi - 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="') + REMOTE_SCRIPT_VERSION=$(curl -s $REMOTE_SCRIPT_URL | grep -m 1 "SCRIPT_VERSION" | tr -d 'SCRIPT_VERSION="') ### CHECK FOR EMPTY VERSION TAGS if [ -z "$SCRIPT_VERSION" ] ; then @@ -125,11 +126,13 @@ update_script() { ### UPDATE update_helium() { + DOWNLOAD_URL=$(curl -s $SOURCE_URL | grep "browser_download_url" | grep "x86_64.AppImage" | grep -v "zsync" | tr -d \" | awk '{print $2}') + SOURCE_FILENAME=$(curl -s $SOURCE_URL | grep "browser_download_url" | grep "x86_64.AppImage" | grep -v "zsync" | tr -d \" | awk '{print $2}' | awk -F'/' '{print $9}') 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}') + SOURCE_VERSION=$(curl -s $SOURCE_URL | grep "tag_name" | tr -d \", | awk '{print $2}') ### CHECK FOR EMPTY VERSION TAGS - if [[ -z "$GIT_VERSION" ]] ; then + if [[ -z "$SOURCE_VERSION" ]] ; then echo "${DATE} | Failed to update - Empty version tag --> $SOURCE" >> $LOG notify-send -i "$ICON" "Helium Helper" "Browser update failed! See log for details" exit @@ -143,26 +146,24 @@ update_helium() { ### COMPARE LOCAL & REMOTE VERSION LOCAL_VERSION_NUM=$(echo $LOCAL_VERSION | tr -d .) - GIT_VERSION_NUM=$(echo $GIT_VERSION | tr -d .) + SOURCE_VERSION_NUM=$(echo $SOURCE_VERSION | tr -d .) - if [ "$GIT_VERSION" == "$LOCAL_VERSION" ] ; then + if [ "$SOURCE_VERSION" == "$LOCAL_VERSION" ] ; then 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}') - GIT_FILENAME=$(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}' | awk -F'/' '{print $9}') + elif [ "$SOURCE_VERSION_NUM" -gt "$LOCAL_VERSION_NUM" ] ; then mkdir -p $TMP $BACKUP_PATH - wget -P $TMP $GIT_URL -q --show-progress - chmod +x $TMP/$GIT_FILENAME + wget -P $TMP $DOWNLOAD_URL -q --show-progress + chmod +x $TMP/$SOURCE_FILENAME if [ -f "$BACKUP_PATH/$APP_NAME.old" ] ; then rm $BACKUP_PATH/$APP_NAME.old fi mv $INSTALL_PATH/$APP_NAME.AppImage $BACKUP_PATH/$APP_NAME.old - mv $TMP/$GIT_FILENAME $INSTALL_PATH/$APP_NAME.AppImage + mv $TMP/$SOURCE_FILENAME $INSTALL_PATH/$APP_NAME.AppImage 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 -i "$ICON" "Helium Helper" "Browser updated to $GIT_VERSION" + echo "${DATE} | $APP_NAME updated to ${SOURCE_VERSION}" >> $LOG + notify-send -i "$ICON" "Helium Helper" "Browser updated to $SOURCE_VERSION" else echo "${DATE} | Failed to update - Version tags malformed" >> $LOG