Skip to content

Commit

Permalink
Added possibility via config add other products to check BIOS version…
Browse files Browse the repository at this point in the history
…s aswell + fixed url with required language
  • Loading branch information
ldrahnik committed Dec 26, 2024
1 parent b860dff commit 7194cd3
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 55 deletions.
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (simplest configuration)",
"program": "${file}",
"env": {
"BIOS_IS_UPTODATE_SCRIPT_FILE_PATH":"/usr/share/asus-bios-updates-notifier/bios_is_uptodate_script.sh",
"BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH":"/usr/share/asus-bios-updates-notifier/bios_is_upgradable_script.sh",
"CONFIG_DIR_PATH": "/usr/share/asus-bios-updates-notifier/"
}
}
]
}
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

![preview](preview.png)

Included script checks whether is current version of ASUS laptop's BIOS up-to-date every time when the laptop starts via provided systemctl service. Service is designed to wait for connection, then execute check script and be stopped so consumes nothing.
Included script checks every time when laptop starts whether is BIOS version of current ASUS laptop and each ASUS product defined manually in associated config up-to-date. Is used systemctl service.

If you find this project useful, do not forget to give it a [![GitHub stars](https://img.shields.io/github/stars/asus-linux-drivers/asus-bios-updates-notifier.svg?style=social&label=Star&maxAge=2592000)](https://github.com/asus-linux-drivers/asus-bios-updates-notifier/stargazers) People already did!

Expand All @@ -22,6 +22,7 @@ If you find this project useful, do not forget to give it a [![GitHub stars](htt

- Notifier is installed for current user and does not run under `$ sudo`
- Customizable scripts which by default show notification bubbles via `$ notify-send`
- Via config is possible check BIOS version of any Asus product

## Installation

Expand All @@ -48,22 +49,28 @@ $ bash install_service.sh

## Configuration

When is systemctl service installed is check script run immediately and also is run every time when user log in and after every BIOS version check are processed scripts which are located for futher customization here:
Config file with Asus products is located here `/usr/share/asus-bios-updates-notifier/config.ini`. BIOS of the current laptop is checked automatically and do not has to be added in config! (format below)

```
"RT-AX53U"="3.0.0.4.386_69086"
```

When is systemctl service installed check script is run immediately and also is run every time when user log in and after every BIOS version check are processed scripts that are located for futher customization here:

- When is BIOS upgradable (`/usr/share/asus-bios-updates-notifier/bios_is_upgradable_script.sh`)(default content below)

```
#!/bin/bash
#!/usr/bin/env bash
notify-send "BIOS v$BIOS_VERSION is upgradable to v$BIOS_VERSION_LATEST ($BIOS_VERSION_LATEST_RELEASED_DATE)"
notify-send "BIOS v$BIOS_VERSION of product $BIOS_PRODUCT_NAME is upgradable to v$BIOS_VERSION_LATEST ($BIOS_VERSION_LATEST_RELEASED_DATE)"
```

- When is BIOS up-to-date (`/usr/share/asus-bios-updates-notifier/bios_is_uptodate_script.sh`) (default content below)

```
#!/bin/bash
#!/usr/bin/env bash
notify-send "BIOS v$BIOS_VERSION ($BIOS_VERSION_LATEST_RELEASED_DATE) is up-to-date"
notify-send "BIOS v$BIOS_VERSION ($BIOS_VERSION_LATEST_RELEASED_DATE) of product $BIOS_PRODUCT_NAME is up-to-date"
```

## Uninstallation
Expand Down Expand Up @@ -92,4 +99,4 @@ $ bash tests/script.sh

I do not know any.

**Why was this project created?** As a notifier about any released BIOS version.
**Why was this project created?** As a notifier about any released BIOS versions.
1 change: 1 addition & 0 deletions asus_bios_updates_notifier.service
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ TimeoutSec=60
Restart=on-failure
Environment="BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH=$BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH"
Environment="BIOS_IS_UPTODATE_SCRIPT_FILE_PATH=$BIOS_IS_UPTODATE_SCRIPT_FILE_PATH"
Environment="CONFIG_DIR_PATH=$CONFIG_DIR_PATH"
Environment="DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS"

[Install]
Expand Down
2 changes: 1 addition & 1 deletion bios_is_upgradable_script.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

notify-send "BIOS v$BIOS_VERSION is upgradable to v$BIOS_VERSION_LATEST ($BIOS_VERSION_LATEST_RELEASED_DATE)"
notify-send "BIOS v$BIOS_VERSION of product $BIOS_PRODUCT_NAME is upgradable to v$BIOS_VERSION_LATEST ($BIOS_VERSION_LATEST_RELEASED_DATE)"
2 changes: 1 addition & 1 deletion bios_is_uptodate_script.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

notify-send "BIOS v$BIOS_VERSION ($BIOS_VERSION_LATEST_RELEASED_DATE) is up-to-date"
notify-send "BIOS v$BIOS_VERSION ($BIOS_VERSION_LATEST_RELEASED_DATE) of product $BIOS_PRODUCT_NAME is up-to-date"
1 change: 1 addition & 0 deletions config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"RT-AX53U"="3.0.0.4.386_69086"
1 change: 1 addition & 0 deletions configs/default.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"RT-AX53U"="3.0.0.4.386_69086"
32 changes: 32 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,38 @@ LOGS_INSTALL_LOG_FILE_PATH="$LOGS_DIR_PATH/$LOGS_INSTALL_LOG_FILE_NAME"

INSTALL_DIR_PATH="/usr/share/asus-bios-updates-notifier"

echo
echo "Select config:"
echo
echo "Default one contains router RT-AX53U"
echo
PS3='Please enter your choice '
options=($(ls configs) "Quit")
select selected_opt in "${options[@]}"
do
if [ "$selected_opt" = "Quit" ]
then
exit 0
fi

for option in $(ls configs);
do
if [ "$option" = "$selected_opt" ] ; then
layout=${selected_opt%.py}
break
fi
done

if [ -z "$layout" ] ; then
echo "invalid option $REPLY"
else
break
fi
done

echo "Add config with possibility to check bios of another products: $INSTALL_DIR_PATH/config.ini"
cp configs/$layout "$INSTALL_DIR_PATH/config.ini"

sudo mkdir -p "$INSTALL_DIR_PATH"
sudo chown -R $USER "$INSTALL_DIR_PATH"
sudo install script.sh "$INSTALL_DIR_PATH"
Expand Down
7 changes: 5 additions & 2 deletions install_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ fi
if [ -z "$LOGS_DIR_PATH" ]; then
LOGS_DIR_PATH="/var/log/asus-bios-updates-notifier"
fi
if [ -z "$CONFIG_DIR_PATH" ]; then
CONFIG_DIR_PATH="/usr/share/asus-bios-updates-notifier"
fi

echo "Systemctl service"
echo
Expand All @@ -26,7 +29,7 @@ case "$RESPONSE" in [yY][eE][sS]|[yY])
cat "bios_is_upgradable_script.sh" | sudo tee "$BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH" >/dev/null
sudo chmod +x $BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH

BIOS_IS_UPTODATE_SCRIPT_FILE_PATH="$INSTALL_DIR_PATH/bios_is_uptodate_script.sh"
BIOS_IS_UPTODATE_SCRIPT_FILE_PATH="/usr/share/asus-bios-updates-notifier/bios_is_uptodate_script.sh"
cat "bios_is_uptodate_script.sh" | sudo tee "$BIOS_IS_UPTODATE_SCRIPT_FILE_PATH" >/dev/null
sudo chmod +x $BIOS_IS_UPTODATE_SCRIPT_FILE_PATH

Expand All @@ -43,7 +46,7 @@ case "$RESPONSE" in [yY][eE][sS]|[yY])
echo "env var DBUS_SESSION_BUS_ADDRESS: $DBUS_SESSION_BUS_ADDRESS"
echo

cat "$SERVICE_FILE_PATH" | ERROR_LOG_FILE_PATH=$ERROR_LOG_FILE_PATH BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH=$BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH BIOS_IS_UPTODATE_SCRIPT_FILE_PATH=$BIOS_IS_UPTODATE_SCRIPT_FILE_PATH DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS envsubst '$ERROR_LOG_FILE_PATH $BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH $BIOS_IS_UPTODATE_SCRIPT_FILE_PATH $DBUS_SESSION_BUS_ADDRESS' | sudo tee "$SERVICE_INSTALL_DIR_PATH/$SERVICE_INSTALL_FILE_NAME" >/dev/null
cat "$SERVICE_FILE_PATH" | CONFIG_DIR_PATH=$CONFIG_DIR_PATH ERROR_LOG_FILE_PATH=$ERROR_LOG_FILE_PATH BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH=$BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH BIOS_IS_UPTODATE_SCRIPT_FILE_PATH=$BIOS_IS_UPTODATE_SCRIPT_FILE_PATH DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS envsubst '$CONFIG_DIR_PATH $ERROR_LOG_FILE_PATH $BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH $BIOS_IS_UPTODATE_SCRIPT_FILE_PATH $DBUS_SESSION_BUS_ADDRESS' | sudo tee "$SERVICE_INSTALL_DIR_PATH/$SERVICE_INSTALL_FILE_NAME" >/dev/null

if [[ $? != 0 ]]; then
echo "Something went wrong when moving the $SERVICE_FILE_PATH"
Expand Down
Binary file modified preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 46 additions & 30 deletions script.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,40 +1,56 @@
#!/usr/bin/env bash

if [ -z "$BIOS" ]; then
BIOS=$(cat /sys/class/dmi/id/bios_version)
fi

echo

# last cut command for the situation when the command above returns: UN5401QAB_UN5401QA.308
BIOS_PRODUCT_NAME=$(echo $BIOS | cut -d '.' -f 1 | cut -d '_' -f 1)
BIOS_VERSION=$(echo $BIOS | cut -d '.' -f 2)

echo "Detected laptop: $BIOS_PRODUCT_NAME"
echo "Detected BIOS version: $BIOS_VERSION"
function check_bios_update() {
local BIOS_PRODUCT_NAME="$1"
local BIOS_VERSION="$2"

echo
echo "Product: $BIOS_PRODUCT_NAME"
echo "BIOS version: $BIOS_VERSION"

USER_AGENT="user-agent-name-here"
BIOS_PRODUCT_NAME_LOWER=$(echo "$BIOS_PRODUCT_NAME" | tr '[:upper:]' '[:lower:]')
CURL_LAPTOP_SUPPORT_PAGE_URL="https://www.asus.com/us/supportonly/$BIOS_PRODUCT_NAME_LOWER/helpdesk_bios/"
LAPTOP_SUPPORT_PAGE_CURL=$(curl -s --user-agent "$USER_AGENT" "$CURL_LAPTOP_SUPPORT_PAGE_URL")

BIOS_VERSION_LATEST=$(echo "$LAPTOP_SUPPORT_PAGE_CURL" | xmllint --html --xpath "(//div[contains(@class, 'ProductSupportDriverBIOS__fileInfo')])[1]/div[1]/text()" - 2>/dev/null | cut -d ' ' -f 2)
BIOS_VERSION_LATEST_RELEASED_DATE=$(echo "$LAPTOP_SUPPORT_PAGE_CURL" | xmllint --html --xpath "(//div[contains(@class, 'ProductSupportDriverBIOS__fileInfo')])[1]/div[3]/text()" - 2>/dev/null)
BIOS_VERSION_LATEST_RELEASED_DATE=$(echo "$BIOS_VERSION_LATEST_RELEASED_DATE" | xargs)

if [[ "$BIOS_VERSION_LATEST" == "$BIOS_VERSION" ]]; then
echo "BIOS $BIOS_VERSION is up-to-date"

if [ "$BIOS_IS_UPTODATE_SCRIPT_FILE_PATH" ]; then
source "$BIOS_IS_UPTODATE_SCRIPT_FILE_PATH"
fi
else
echo "BIOS is upgradable to: $BIOS_VERSION_LATEST"
echo "Download link: $CURL_LAPTOP_SUPPORT_PAGE_URL"

if [ "$BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH" ]; then
source "$BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH"
fi
fi
}

USER_AGENT="user-agent-name-here"
BIOS_PRODUCT_NAME_LOWER=$(echo $BIOS_PRODUCT_NAME | tr '[:upper:]' '[:lower:]')
CURL_LAPTOP_SUPPORT_PAGE_URL="https://www.asus.com/supportonly/$BIOS_PRODUCT_NAME_LOWER/helpdesk_bios/"
# check current laptop bios
CURRENT_LAPTOP_BIOS=$(cat /sys/class/dmi/id/bios_version)
CURRENT_LAPTOP_BIOS_PRODUCT_NAME=$(echo "$CURRENT_LAPTOP_BIOS" | cut -d '.' -f 1 | cut -d '_' -f 1)
CURRENT_LAPTOP_BIOS_VERSION=$(echo "$CURRENT_LAPTOP_BIOS" | cut -d '.' -f 2)

LAPTOP_SUPPORT_PAGE_CURL=$(curl -s --user-agent "$USER_AGENT" "$CURL_LAPTOP_SUPPORT_PAGE_URL" )
check_bios_update "$CURRENT_LAPTOP_BIOS_PRODUCT_NAME" "$CURRENT_LAPTOP_BIOS_VERSION"

BIOS_VERSION_LATEST=$(echo $LAPTOP_SUPPORT_PAGE_CURL | xmllint --html --xpath "(//div[contains(@class, 'ProductSupportDriverBIOS__fileInfo')])[1]/div[1]/text()" - 2>/dev/null | cut -d ' ' -f 2)
BIOS_VERSION_LATEST_RELEASED_DATE=$(echo $LAPTOP_SUPPORT_PAGE_CURL | xmllint --html --xpath "(//div[contains(@class, 'ProductSupportDriverBIOS__fileInfo')])[1]/div[3]/text()" - 2>/dev/null)
# check bios for each product in the config
if [ -f "$CONFIG_DIR_PATH/config.ini" ]; then

echo
# Loop through each line in the config file
while IFS='=' read -r BIOS_PRODUCT_NAME BIOS_VERSION; do

if [[ "$BIOS_VERSION_LATEST" != "$BIOS_VERSION" ]]; then
echo "BIOS is upgradable to $BIOS_VERSION_LATEST"
echo "Download link: $CURL_LAPTOP_SUPPORT_PAGE_URL"
BIOS_PRODUCT_NAME=$(echo "$BIOS_PRODUCT_NAME" | xargs | tr -d '"' | tr -d '\r')
BIOS_VERSION=$(echo "$BIOS_VERSION" | xargs | tr -d '"' | tr -d '\r')

if [ "$BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH" ]; then
source $BIOS_IS_UPGRADABLE_SCRIPT_FILE_PATH
fi
check_bios_update "$BIOS_PRODUCT_NAME" "$BIOS_VERSION"
done < "$CONFIG_DIR_PATH/config.ini"
else
echo "BIOS $BIOS_VERSION is up-to-date"

if [ "$BIOS_IS_UPTODATE_SCRIPT_FILE_PATH" ]; then
source $BIOS_IS_UPTODATE_SCRIPT_FILE_PATH
fi
echo "not found $CONFIG_DIR_PATH/config.ini"
fi
28 changes: 14 additions & 14 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ LOGS_UNINSTALL_LOG_FILE_PATH="$LOGS_DIR_PATH/$LOGS_UNINSTALL_LOG_FILE_NAME"
touch "$LOGS_UNINSTALL_LOG_FILE_PATH"

{
INSTALL_DIR_PATH="/usr/share/asus-bios-updates-notifier"

sudo rm -rf $INSTALL_DIR_PATH
INSTALL_DIR_PATH="/usr/share/asus-bios-updates-notifier"

if [[ $? != 0 ]]
then
echo "Something went wrong when removing files from the $INSTALL_DIR_PATH"
fi
sudo rm -rf $INSTALL_DIR_PATH

echo "Asus numberpad driver removed"
if [[ $? != 0 ]]
then
echo "Something went wrong when removing files from the $INSTALL_DIR_PATH"
fi

echo
echo "Asus numberpad driver removed"

source uninstall_service.sh
echo

echo
source uninstall_service.sh

echo "Uninstallation finished succesfully"
echo

echo
echo "Uninstallation finished succesfully"

read -r -p "Reboot is required. Do you want reboot now? [y/N]" RESPONSE
echo

read -r -p "Reboot is required. Do you want reboot now? [y/N]" RESPONSE
case "$RESPONSE" in [yY][eE][sS]|[yY])
reboot
;;
Expand Down

0 comments on commit 7194cd3

Please sign in to comment.