From d81d52ba9735a693d2747474ddf97654510b035c Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Sat, 31 Aug 2024 15:56:01 +0200 Subject: [PATCH] Cosmetic adjustement of profile.d scripts to align with motd --- .../common/etc/default/armbian-motd.dpkg-dist | 2 +- .../armbian-activate-profile-sync-daemon.sh | 4 +- .../armbian-check-first-login-reboot.sh | 6 +-- .../etc/update-motd.d/10-armbian-header | 30 +++++++------- .../etc/update-motd.d/30-armbian-sysinfo | 39 ++++++++++++------- .../common/etc/update-motd.d/35-armbian-tips | 4 +- .../bsp/common/etc/update-motd.d/41-commands | 29 ++++++++++---- 7 files changed, 69 insertions(+), 45 deletions(-) diff --git a/packages/bsp/common/etc/default/armbian-motd.dpkg-dist b/packages/bsp/common/etc/default/armbian-motd.dpkg-dist index 3dfad79f3d7b..da1dbb0b1e69 100644 --- a/packages/bsp/common/etc/default/armbian-motd.dpkg-dist +++ b/packages/bsp/common/etc/default/armbian-motd.dpkg-dist @@ -6,7 +6,7 @@ MOTD_DISABLE="" ONE_WIRE="" -HIDE_IP_PATTERN="^dummy0|^lo" +HIDE_IP_PATTERN="^dummy0|^lo|^docker" PRIMARY_INTERFACE="$(ip route | grep '^default' | sed "s/.*dev //" | cut -d" " -f1)" PRIMARY_DIRECTION="rx" STORAGE=/dev/sda1 diff --git a/packages/bsp/common/etc/profile.d/armbian-activate-profile-sync-daemon.sh b/packages/bsp/common/etc/profile.d/armbian-activate-profile-sync-daemon.sh index 9f0b86523b9f..63f9d163776a 100644 --- a/packages/bsp/common/etc/profile.d/armbian-activate-profile-sync-daemon.sh +++ b/packages/bsp/common/etc/profile.d/armbian-activate-profile-sync-daemon.sh @@ -18,10 +18,10 @@ if [ -f "${HOME}/.activate_psd" ]; then sed -i 's/#USE_OVERLAYFS=.*/USE_OVERLAYFS="yes"/' "${config_file}" case $(/usr/bin/psd p 2>/dev/null | grep Overlayfs) in *active*) - echo -e "\nConfigured profile sync daemon with overlayfs." + echo -e "\n Configured profile sync daemon with overlayfs." ;; *) - echo -e "\nConfigured profile sync daemon." + echo -e "\n Configured profile sync daemon." sed -i 's/USE_OVERLAYFS="yes"/#USE_OVERLAYFS="no"/' "${config_file}" ;; esac diff --git a/packages/bsp/common/etc/profile.d/armbian-check-first-login-reboot.sh b/packages/bsp/common/etc/profile.d/armbian-check-first-login-reboot.sh index 175c2a9e99a4..dd67df3d116a 100644 --- a/packages/bsp/common/etc/profile.d/armbian-check-first-login-reboot.sh +++ b/packages/bsp/common/etc/profile.d/armbian-check-first-login-reboot.sh @@ -10,15 +10,15 @@ if [ "$-" != "${-#*i}" ]; then OutstandingPackages="$(grep -Ev "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" + printf "\n \e[0;91mKernel 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="$(grep -Ev "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" + 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" + printf "\n\e[0;91m Some packages require a reboot since more than 1 day (${Packages})\x1B[0m\n\n" fi fi fi diff --git a/packages/bsp/common/etc/update-motd.d/10-armbian-header b/packages/bsp/common/etc/update-motd.d/10-armbian-header index 1aeefe41d7e4..92a3f8db7984 100755 --- a/packages/bsp/common/etc/update-motd.d/10-armbian-header +++ b/packages/bsp/common/etc/update-motd.d/10-armbian-header @@ -47,28 +47,28 @@ done KERNELID=$(uname -r) # Display software vendor logo -echo -e "\e[0;91m$(figlet -f small " $VENDOR")\e[0m"; +echo -e "\e[1;91m$(figlet -f small " $VENDOR")\e[0m"; # Display version, board, and kernel version -echo -e " \e[1;91mv${VERSION}\x1B[0m for \e[1;93m$BOARD_NAME \x1B[0mrunning \e[1;91mArmbian Linux\x1B[0m \e[1;93m${KERNELID^}\x1B[0m" +echo -e " \e[0;92mv${VERSION}\x1B[0m for $BOARD_NAME running Armbian Linux \e[0;92m${KERNELID^}\x1B[0m" # render image and board type if [[ "$IMAGE_TYPE" != "stable" ]]; then - [[ "$IMAGE_TYPE" == "user-built" ]] && HARDWARE_STATUS="\e[1;91mnot supported\x1B[0m (custom image)" - [[ "$IMAGE_TYPE" == "nightly" ]] && HARDWARE_STATUS="\e[1;91mfor advanced users\x1B[0m (rolling release)" + [[ "$IMAGE_TYPE" == "user-built" ]] && HARDWARE_STATUS="\e[0;91mDIY\x1B[0m (custom image)\x1B[0m" + [[ "$IMAGE_TYPE" == "nightly" ]] && HARDWARE_STATUS="\e[0;91mfor advanced users\x1B[0m (rolling release)\x1B[0m" else - [[ "$BOARD_TYPE" == "csc" || "$BOARD_TYPE" == "tvb" ]] && HARDWARE_STATUS="Community maintained" - [[ "$BOARD_TYPE" == "wip" ]] && HARDWARE_STATUS="\e[1;91mfor advanced users\x1B[0m (work in progress)" - [[ "$BOARD_TYPE" == "eos" ]] && HARDWARE_STATUS="\e[1;91mend of life\x1B[0m" + [[ "$BOARD_TYPE" == "csc" || "$BOARD_TYPE" == "tvb" ]] && HARDWARE_STATUS="\e[0;91mDIY (community maintained)\x1B[0m" + [[ "$BOARD_TYPE" == "wip" ]] && HARDWARE_STATUS="\e[0;91mfor advanced users\x1B[0m (work in progress)\x1B[0m" + [[ "$BOARD_TYPE" == "eos" ]] && HARDWARE_STATUS="\e[0;91mend of life\x1B[0m" fi # render distribution status if [[ $DISTRIBUTION_STATUS == supported ]]; then - DISTRO_STATUS="\e[1;92mstable\e[0m ($DISTRIBUTION_CODENAME)" + DISTRO_STATUS="\e[0;92mstable\e[0m ($DISTRIBUTION_CODENAME)" elif [[ $DISTRIBUTION_STATUS == eos ]]; then - DISTRO_STATUS="\e[1;91mend of life\e[0m ($DISTRIBUTION_CODENAME)" + DISTRO_STATUS="\e[0;91mend of life\e[0m ($DISTRIBUTION_CODENAME)" else - DISTRO_STATUS="\e[1;93mrolling\e[0m ($DISTRIBUTION_CODENAME)" + DISTRO_STATUS="\e[0;93mrolling\e[0m ($DISTRIBUTION_CODENAME)" fi # read packages update status @@ -76,11 +76,11 @@ NUM_UPDATES=0 NUM_UPDATES_ONHOLD=0 NUM_SECURITY_UPDATES=0 [[ -f /var/cache/apt/archives/updates.number ]] && . /var/cache/apt/archives/updates.number -if [[ $NUM_UPDATES -gt 0 ]] && grep -q linux /var/cache/apt/archives/updates.list 2>/dev/null; then - if [[ $NUM_UPDATES_ONHOLD -gt 0 ]]; then - UPDATE_STATUS="FW upgrade \e[1;91mdisabled\e[0m" +if [[ $NUM_UPDATES -gt 0 ]]; then + if apt-mark showhold | grep -q linux-image 2>/dev/null; then + UPDATE_STATUS="Kernel upgrade \e[0;91mdisabled\e[0m" else - UPDATE_STATUS="FW upgrade \e[1;92menabled\e[0m" + UPDATE_STATUS="Kernel upgrade \e[0;92menabled\e[0m" fi UPDATE_STATUS+=" and \e[1;92m$NUM_UPDATES\e[0m package" # Cosmetic is important @@ -88,8 +88,6 @@ if [[ $NUM_UPDATES -gt 0 ]] && grep -q linux /var/cache/apt/archives/updates.lis UPDATE_STATUS+=" available for upgrade\e[0m " fi -# draw a line to start this section -#printf "\e[0;90m OS "; printf '%.s─' $(seq 1 76); echo -e " \x1B[0m" echo "" # Display packages status diff --git a/packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo b/packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo index 9d8f4fe82b12..4ce2ae7c46e1 100755 --- a/packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo +++ b/packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo @@ -19,7 +19,7 @@ MOTD_DISABLE="" PRIMARY_INTERFACE="eth0" PRIMARY_DIRECTION="rx" STORAGE=/dev/sda1 -HIDE_IP_PATTERN="^dummy0|^lo" +HIDE_IP_PATTERN="^dummy0|^lo|^docker" CPU_TEMP_LIMIT=60 # Temperature offset in Celcius degrees CPU_TEMP_OFFSET=0 @@ -53,6 +53,10 @@ function display() { fi } # display +function get_wan_address(){ +curl -s http://whatismyip.akamai.com/ +} + function get_ip_addresses() { local ips=() for f in /sys/class/net/*; do @@ -91,6 +95,7 @@ function storage_info() { # Works only with ambienttemp and batteryinfo since A20 is slow enough :) amb_temp=$(ambienttemp &) ip_address=$(get_ip_addresses &) +wan_ip_address=$(get_wan_address &) batteryinfo storage_info getboardtemp @@ -126,9 +131,15 @@ swap_total=$(awk '{print $(2)}' <<<${swap_info}) # draw a line to start this section -#printf "\e[0;90m Sysinfo "; printf '%.s─' $(seq 1 71); echo -e " \x1B[0m" +#echo "" +echo -en " IP addresses: \x1B[93m(LAN)\x1B[0m \x1B[92m$ip_address\x1B[0m " +if [[ -n $wan_ip_address ]]; then +echo -e "\x1B[93m(WAN)\x1B[0m $wan_ip_address" +fi +echo "" +printf "\e[0;90m Performance: \x1B[0m" +echo "" # fixed newline echo "" - display " Load" "${load%% *}" "${critical_load}" "0" "%" "" printf "Up time: \x1B[92m%s\x1B[0m\t" "$time" @@ -148,8 +159,6 @@ fi display " Memory usage" "$memory_usage" "70" "0" "%" " of ${memory_total}" display "Zram usage" "$swap_usage" "75" "0" "%" " of ${swap_total}" -printf "IP: " -printf "\x1B[92m%s\x1B[0m" "$ip_address" echo "" # fixed newline display " CPU temp" "$board_temp" $CPU_TEMP_LIMIT "0" "°C" "" display "Ambient temp" "$amb_temp" $AMB_TEMP_LIMIT "0" "°C" "" @@ -164,21 +173,23 @@ display "Battery" "$battery_percent" "20" "1" "%" "$status_battery_text" ; a=$(( line=0 if [[ -n "$PRIMARY_INTERFACE" ]] && vnstat -i "$PRIMARY_INTERFACE" &> /dev/null; then traffic=$(vnstat -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/') + traffic_rx=$(echo $traffic | cut -d";" -f1,1 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/' | cut -d" " -f1 | cut -d"," -f1) + traffic_rx_unit=$(echo $traffic | cut -d";" -f1,1 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/' | cut -d" " -f2) + traffic_tx=$(echo $traffic | cut -d";" -f2,2 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/' | cut -d" " -f1 | cut -d"," -f1) + traffic_tx_unit=$(echo $traffic | cut -d";" -f2,2 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/' | cut -d" " -f2) [[ "$traffic" == *"Not enough"* ]] && { traffic_tx="n/a "; traffic_rx="n/a "; } case $PRIMARY_DIRECTION in tx) - printf " TX today: \x1B[92m%s\x1B[0m \t" "$traffic_tx" + display " TX today" "$traffic_tx" 500 0 " $traffic_tx_unit" "" line=$((line+1)) ;; rx) - printf " RX today: \x1B[92m%s\x1B[0m \t" "$traffic_rx" + display " RX today" "$traffic_rx" 500 0 " $traffic_rx_unit" "" line=$((line+1)) ;; both) - printf " TX today: \x1B[92m%s\x1B[0m \t" "$traffic_tx" - printf " RX today: \x1B[92m%s\x1B[0m \t" "$traffic_rx" + display " TX today" "$traffic_tx" 500 0 " $traffic_tx_unit" "" + display "RX today" "$traffic_rx" 500 0 " $traffic_rx_unit" "" line=$((line+1)) ;; *) #off or whatever @@ -191,15 +202,15 @@ if [[ $(command -v zpool) ]]; then if [[ -n $(echo $zpoolstatus | grep 'not loaded') ]]; then : elif [[ -n $(echo $zpoolstatus | grep 'degraded\|OFFLINE') ]]; then - printf " ZFS pool: " + printf " ZFS pool: " echo -ne "\e[0;91mDegraded\x1B[0m" line=$((line+1)) elif [[ -n $(echo $zpoolstatus | grep 'no pools available') ]]; then - printf " ZFS pool: " + printf " ZFS pool: " echo -ne "n/a" line=$((line+1)) else - printf " ZFS pool: " + printf " ZFS pool: " echo -ne "\e[0;92mOnline\x1B[0m" line=$((line+1)) fi diff --git a/packages/bsp/common/etc/update-motd.d/35-armbian-tips b/packages/bsp/common/etc/update-motd.d/35-armbian-tips index 6afe203ba88d..c1b6067abc7a 100755 --- a/packages/bsp/common/etc/update-motd.d/35-armbian-tips +++ b/packages/bsp/common/etc/update-motd.d/35-armbian-tips @@ -25,8 +25,8 @@ if [[ -f $quotes && $(( $RANDOM % 1 )) == 0 ]]; then DUE_DATE=$(echo $quote | cut -d"|" -f1) SELECTED_QUOTE=$(echo $quote | cut -d"|" -f2) if [[ -n $SELECTED_QUOTE && $(date +'%Y-%m-%d') < $(date -d $DUE_DATE +"%Y-%m-%d") ]]; then - # draw a line to start this section - printf "\n\e[0;90m Tips:\x1B[0m\n " #; printf '%.s─' $(seq 1 5); echo -e " \x1B[0m" + printf "\e[0;90m Tips:\x1B[0m\n " #; printf '%.s─' $(seq 1 5); echo -e " \x1B[0m" echo -e "\n$SELECTED_QUOTE" | fold -w 79 -s | sed 's/^/ /' + echo "" fi fi diff --git a/packages/bsp/common/etc/update-motd.d/41-commands b/packages/bsp/common/etc/update-motd.d/41-commands index e5ae79de2c9b..457093edd305 100755 --- a/packages/bsp/common/etc/update-motd.d/41-commands +++ b/packages/bsp/common/etc/update-motd.d/41-commands @@ -18,14 +18,29 @@ for f in $MOTD_DISABLE; do [[ $f == $THIS_SCRIPT ]] && exit 0 done +printf "\e[0;90m Commands: \x1B[0m\n" #; printf '%.s─' $(seq 1 39); echo -e "\x1B[0m" echo "" -printf "\e[0;90m Commands: \e[0;90m\n" #; printf '%.s─' $(seq 1 39); echo -e "\x1B[0m" -echo "" -echo -e " \e[1;93mUpdate\e[1;39m: sudo apt update ; sudo apt upgrade" -echo -e " \e[1;93mSystem config\e[1;39m: sudo armbian-config" + +list=( + "System config ","sudo ","armbian-config" + "System monitor ","","htop" +) + +# just for easier coloring +yellow() { printf '%s' $'\e[1;33m' "$*" $'\e[0m'; } + +for l in "${list[@]}" +do + name=$(echo $l | cut -d"," -f1) + sudo=$(echo $l | cut -d"," -f2) + command=$(echo $l | cut -d"," -f3) + + if command -v $command &> /dev/null + then + printf "$(yellow " %-26s %-0s"): $sudo$command\n" "$name" + fi +done + echo -e "\033[0m" -#printf "\e[0;90m www.armbian.com/donate "; printf '%.s─' $(seq 1 21); echo -e "\x1B[0m" -#echo "" exit 0 -