Adding MOTD support for vnstat and ZFS and fix minor bugs (#2402)
* Move default values where they should be and fix for updates not showing up * Add support for vnstat and ZFS * Cosmetical * Put defaults back * Update data displaying * Add support for displaying "reboot required" when regular packages like e.g. dbus requires a reboot * Add dependency problem check * Also add storage to user defaults
This commit is contained in:
parent
514b5f1535
commit
d00410d1c3
@ -1,6 +1,14 @@
|
||||
# add space-separated list of MOTD script names (without number) to exclude them from MOTD
|
||||
# Example:
|
||||
# MOTD_DISABLE="header tips updates"
|
||||
# ONE_WIRE="yes" show 1-wire temperature sensor if attached
|
||||
|
||||
MOTD_DISABLE=""
|
||||
ONE_WIRE="" # yes = show 1-wire temperature sensor if attached
|
||||
ONE_WIRE=""
|
||||
SHOW_IP_PATTERN="^bond.*|^[ewr].*|^br.*|^lt.*|^umts.*|^lan.*"
|
||||
PRIMARY_INTERFACE="$(ls -1 /sys/class/net/ | grep -v lo | sed -n -e 'H;${x;s/\n/+/g;s/^+//;p;}')"
|
||||
PRIMARY_DIRECTION="rx"
|
||||
STORAGE=/dev/sda1
|
||||
CPU_TEMP_LIMIT=60
|
||||
HDD_TEMP_LIMIT=60
|
||||
AMB_TEMP_LIMIT=40
|
||||
|
||||
@ -8,7 +8,17 @@
|
||||
|
||||
# only do this for interactive shells
|
||||
if [ "$-" != "${-#*i}" ]; then
|
||||
OutstandingPackages="$(egrep -v "linux-base|linux-image" /var/run/reboot-required.pkgs 2>/dev/null)"
|
||||
if [ -f "/var/run/.reboot_required" ]; then
|
||||
printf "\n[\e[0;91m Kernel was updated, please reboot\x1B[0m ]\n\n"
|
||||
elif [ "X${OutstandingPackages}" != "X" ]; then
|
||||
# No kernel update involved, just regular packages like e.g. dbus require a reboot
|
||||
Packages="$(egrep -v "linux-base|linux-image" /var/run/reboot-required.pkgs | sort | uniq | tr '\n' ',' | sed -e 's/,/, /g' -e 's/,\ $//')"
|
||||
OlderThanOneDay=$(find /var/run/reboot-required -mtime +1)
|
||||
if [ "X${OlderThanOneDay}" = "X" ]; then
|
||||
printf "\n[\e[0;92m some packages require a reboot (${Packages})\x1B[0m ]\n\n"
|
||||
else
|
||||
printf "\n[\e[0;91m some packages require a reboot since more than 1 day (${Packages})\x1B[0m ]\n\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -11,12 +11,15 @@
|
||||
# generate system information
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
THIS_SCRIPT="sysinfo"
|
||||
|
||||
# don't change default values - they are lost on upgrades. Use /etc/default/armbian-motd for your values
|
||||
|
||||
MOTD_DISABLE=""
|
||||
PRIMARY_INTERFACE="eth0"
|
||||
PRIMARY_DIRECTION="rx"
|
||||
STORAGE=/dev/sda1
|
||||
SHOW_IP_PATTERN="^bond.*|^[ewr].*|^br.*|^lt.*|^umts.*|^lan.*"
|
||||
|
||||
CPU_TEMP_LIMIT=60
|
||||
HDD_TEMP_LIMIT=60
|
||||
AMB_TEMP_LIMIT=40
|
||||
@ -225,4 +228,34 @@ display "storage/" "$storage_usage" "90" "1" "%" " of $storage_total"
|
||||
display "storage temp" "$storage_temp" $HDD_TEMP_LIMIT "0" "°C" "" ; a=$?
|
||||
display "Battery" "$battery_percent" "20" "1" "%" "$status_battery_text"
|
||||
echo ""
|
||||
line=0
|
||||
if [[ $(command -v vnstat) ]]; then
|
||||
line=$((line+1))
|
||||
traffic=$(vnstat -d 1 -i $PRIMARY_INTERFACE --oneline | cut -d";" -f4,5)
|
||||
traffic_rx=$(echo $traffic | cut -d";" -f1,1 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/')
|
||||
traffic_tx=$(echo $traffic | cut -d";" -f2,2 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/')
|
||||
printf "${PRIMARY_DIRECTION^^} yesterday: "
|
||||
if [[ $PRIMARY_DIRECTION == tx ]]; then
|
||||
printf "\x1B[92m%s\x1B[0m" "$traffic_tx"
|
||||
else
|
||||
printf "\x1B[92m%s\x1B[0m" "$traffic_rx"
|
||||
fi
|
||||
printf "\t"
|
||||
fi
|
||||
|
||||
if [[ $(command -v zpool) ]]; then
|
||||
zpoolstatus="$(zpool status </dev/stdin 2>&1 )"
|
||||
if [[ -n $(echo $zpoolstatus | grep 'not loaded') ]]; then
|
||||
:
|
||||
elif [[ -n $(echo $zpoolstatus | grep 'degraded\|OFFLINE') ]]; then
|
||||
printf "ZFS pool: "
|
||||
echo -ne "\e[0;91mDegraded\x1B[0m"
|
||||
line=$((line+1))
|
||||
else
|
||||
printf "ZFS pool: "
|
||||
echo -ne "\e[0;92mOnline\x1B[0m"
|
||||
line=$((line+1))
|
||||
fi
|
||||
fi
|
||||
[[ $line -ne 0 ]] && echo ""
|
||||
echo ""
|
||||
|
||||
@ -28,7 +28,10 @@ else
|
||||
fi
|
||||
|
||||
# give up if packages are broken
|
||||
[[ ! $(dpkg -l | grep ^..r) ]] && exit 0
|
||||
[[ $(dpkg -l | grep ^..r) ]] && exit 0
|
||||
|
||||
# give up if there is a dependency problem
|
||||
[[ "$((apt-get upgrade -s -qq) 2>&1)" == *"Unmet dependencies"* ]] && exit 0
|
||||
|
||||
myfile="/var/cache/apt/archives/updates.number"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user