]> git.ipfire.org Git - people/ms/firmware-update.git/commitdiff
Add info command
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Mar 2019 09:52:39 +0000 (10:52 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 Mar 2019 09:52:39 +0000 (10:52 +0100)
This command shows information about the board and the BIOS
that is currently running

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/firmware-update.in

index 3b7d02db5c80a84cba82b998d144585dc922b4df..b635ba442b1e601cd63289a712c834b363e2552d 100644 (file)
 PACKAGE_NAME="@PACKAGE_NAME@"
 PACKAGE_VERSION="@PACKAGE_VERSION@"
 
+read_dmi() {
+       local what="${1}"
+
+       # Return an error when what is empty
+       [ -z "${what}" ] && return 2
+
+       local file="/sys/class/dmi/id/${what}"
+
+       # Read file
+       if [ -r "${file}" ]; then
+               printf "%s" "$(<${file})"
+               return 0
+       fi
+
+       # File could not be read
+       return 1
+}
+
+board_string() {
+       printf "%s %s\n" \
+               "$(read_dmi "board_vendor")" \
+               "$(read_dmi "board_name")"
+}
+
+board_version() {
+       read_dmi "board_version"
+}
+
+board_serial() {
+       read_dmi "board_serial"
+}
+
+bios_version() {
+       read_dmi "bios_version"
+}
+
+bios_date() {
+       read_dmi "bios_date"
+}
+
 main() {
        local action="${1}"
        shift
 
        case "${action}" in
+               info)
+                       printf "%-12s: %s\n" "Board" "$(board_string)"
+                       printf "%-12s: %s\n" "HW Version" "$(board_version)"
+                       printf "%-12s: %s\n" "Serial" "$(board_serial)"
+                       printf "%-12s: %s (%s)\n" "BIOS Version" \
+                               "$(bios_version)" "$(bios_date)"
+                       return 0
+                       ;;
+
                version)
                        echo "${PACKAGE_NAME}: Version ${PACKAGE_VERSION}"
                        return 0