2018-12-03 09:41:12 +01:00
|
|
|
#!/bin/bash
|
2018-12-03 15:22:12 +01:00
|
|
|
set -euo pipefail
|
2018-12-03 09:41:12 +01:00
|
|
|
|
2018-12-05 12:17:45 +01:00
|
|
|
req_restart_prefix=(
|
2018-12-11 17:00:04 +01:00
|
|
|
glibc
|
2018-12-05 12:17:45 +01:00
|
|
|
linux
|
|
|
|
systemd
|
|
|
|
)
|
2018-12-03 09:41:12 +01:00
|
|
|
|
2018-12-05 12:17:45 +01:00
|
|
|
function get_grep() {
|
|
|
|
local IFS_bak="${IFS}"
|
|
|
|
IFS="|"
|
|
|
|
echo "${req_restart_prefix[*]}"
|
|
|
|
IFS="${IFS_bak}"
|
|
|
|
}
|
|
|
|
|
|
|
|
updates=$(checkupdates)
|
|
|
|
|
2018-12-11 17:16:04 +01:00
|
|
|
num=$(echo "${updates}" | grep -c -- '->' || true)
|
2018-12-05 12:17:45 +01:00
|
|
|
|
2018-12-11 17:16:04 +01:00
|
|
|
# No updates: Gray
|
|
|
|
color="#7f7f7f"
|
|
|
|
display_num=""
|
2018-12-05 12:17:45 +01:00
|
|
|
|
2018-12-11 17:16:04 +01:00
|
|
|
# Normal updates: White
|
|
|
|
[ $num -gt 0 ] && {
|
|
|
|
color="#ffffff"
|
2018-12-13 13:23:55 +01:00
|
|
|
display_num=" ${num}"
|
2018-12-11 17:16:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Requires reboot: Red
|
|
|
|
(echo "${updates}" | grep -qE "^($(get_grep))") && color="#dd0000"
|
|
|
|
|
2018-12-13 13:23:55 +01:00
|
|
|
printf '<span color="%s">\uf94f%s</span>' "${color}" "${display_num}"
|