From eb0b2fa767dce9a0cbc183b99009ce16dba74061 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 4 Sep 2024 09:15:38 +0200 Subject: [PATCH 1/7] Hide hassio interface from showing in the armbian motd --- packages/bsp/common/etc/default/armbian-motd.dpkg-dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bsp/common/etc/default/armbian-motd.dpkg-dist b/packages/bsp/common/etc/default/armbian-motd.dpkg-dist index da1dbb0b1e69..612c6982e8fa 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|^docker" +HIDE_IP_PATTERN="^dummy0|^lo|^docker|^hassio" PRIMARY_INTERFACE="$(ip route | grep '^default' | sed "s/.*dev //" | cut -d" " -f1)" PRIMARY_DIRECTION="rx" STORAGE=/dev/sda1 From 772c7534093d0f6eb0c07f6e80a3276dcc0bf777 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 4 Sep 2024 09:49:55 +0200 Subject: [PATCH 2/7] Improve motd command listing to show existing or hides the element if nothing exists --- .../bsp/common/etc/update-motd.d/41-commands | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/bsp/common/etc/update-motd.d/41-commands b/packages/bsp/common/etc/update-motd.d/41-commands index 457093edd305..e060c289be2b 100755 --- a/packages/bsp/common/etc/update-motd.d/41-commands +++ b/packages/bsp/common/etc/update-motd.d/41-commands @@ -18,29 +18,39 @@ 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 "" - list=( "System config ","sudo ","armbian-config" "System monitor ","","htop" ) -# just for easier coloring -yellow() { printf '%s' $'\e[1;33m' "$*" $'\e[0m'; } - +# verify if command exits on the system +cmd_count=0 +output=() 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" + cmd_count=$(( cmd_count +1 )) + output+=("${name},${sudo},${command}") fi done -echo -e "\033[0m" +# show list for existing command only +if [[ "${cmd_count}" -gt 0 ]]; then + + printf "\e[0;90m Commands: \x1B[0m\n" #; printf '%.s─' $(seq 1 39); echo -e "\x1B[0m" + echo "" + for l in "${output[@]}" + do + name=$(echo $l | cut -d"," -f1) + sudo=$(echo $l | cut -d"," -f2) + command=$(echo $l | cut -d"," -f3) + printf " \e[1;33m%-26s\e[0m %-0s: $sudo$command\n" "$name" + done + echo -e "\033[0m" +fi exit 0 From 034c720c144b2862eba9d5ba56afc352faab7e9c Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 4 Sep 2024 09:58:48 +0200 Subject: [PATCH 3/7] When using CLI / minimal image, lets show motd right after initial config is done --- packages/bsp/common/usr/lib/armbian/armbian-firstlogin | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin index 0e849f3377d1..4409e9ce28bf 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin +++ b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin @@ -895,7 +895,10 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then who -la | grep root | grep -q tty1 && exit 1 else - # no display manager detected + # no display manager detected -> clear screen and show motd + clear + run-parts --lsbsysinit /etc/update-motd.d + # Display reboot recommendation if necessary if [[ -f /var/run/resize2fs-reboot ]]; then printf "\n\n\e[0;91mWarning: a reboot is needed to finish resizing the filesystem \x1B[0m \n" From eb176bda9e38bddb744e565991b3b53c45e98cde Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 4 Sep 2024 12:27:51 +0200 Subject: [PATCH 4/7] Add screen clearing routine and improve commands display --- .../bsp/common/etc/update-motd.d/00-clear | 27 +++++++++++++++++++ .../etc/update-motd.d/30-armbian-sysinfo | 2 +- .../bsp/common/etc/update-motd.d/41-commands | 18 ++++++++----- 3 files changed, 39 insertions(+), 8 deletions(-) create mode 100755 packages/bsp/common/etc/update-motd.d/00-clear diff --git a/packages/bsp/common/etc/update-motd.d/00-clear b/packages/bsp/common/etc/update-motd.d/00-clear new file mode 100755 index 000000000000..e20783b23ea7 --- /dev/null +++ b/packages/bsp/common/etc/update-motd.d/00-clear @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Copyright (c) Authors: https://www.armbian.com/authors +# +# This file is licensed under the terms of the GNU General Public +# License version 2. This program is licensed "as is" without any +# warranty of any kind, whether express or implied. + +# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd +# any changes will be lost on board support package update + +THIS_SCRIPT="clear" +MOTD_DISABLE="" + +[[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd + +for f in $MOTD_DISABLE; do + [[ $f == $THIS_SCRIPT ]] && exit 0 +done + +# Clear screen +if [ -f /bin/bash ]; then +export TERM="$(/bin/bash -c 'echo $TERM')" +fi +clear + +exit 0 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 4ce2ae7c46e1..2b52bcf7b58a 100755 --- a/packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo +++ b/packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo @@ -215,4 +215,4 @@ if [[ $(command -v zpool) ]]; then line=$((line+1)) fi fi -if [[ $line -ne 0 ]]; then echo ""; fi +echo "" diff --git a/packages/bsp/common/etc/update-motd.d/41-commands b/packages/bsp/common/etc/update-motd.d/41-commands index e060c289be2b..1db74ae366e8 100755 --- a/packages/bsp/common/etc/update-motd.d/41-commands +++ b/packages/bsp/common/etc/update-motd.d/41-commands @@ -19,12 +19,13 @@ for f in $MOTD_DISABLE; do done list=( - "System config ","sudo ","armbian-config" - "System monitor ","","htop" + "System config","sudo ","armbian-config" + "System monitor","","htop" ) # verify if command exits on the system cmd_count=0 +name_len=0 output=() for l in "${list[@]}" do @@ -33,6 +34,10 @@ do command=$(echo $l | cut -d"," -f3) if command -v $command &> /dev/null then + # seek for maximum description lenght + if [ ${#name} -ge $name_len ]; then + name_len=${#name} + fi cmd_count=$(( cmd_count +1 )) output+=("${name},${sudo},${command}") fi @@ -40,15 +45,14 @@ done # show list for existing command only if [[ "${cmd_count}" -gt 0 ]]; then - printf "\e[0;90m Commands: \x1B[0m\n" #; printf '%.s─' $(seq 1 39); echo -e "\x1B[0m" echo "" for l in "${output[@]}" do - name=$(echo $l | cut -d"," -f1) - sudo=$(echo $l | cut -d"," -f2) - command=$(echo $l | cut -d"," -f3) - printf " \e[1;33m%-26s\e[0m %-0s: $sudo$command\n" "$name" + name=$(echo $l | cut -d"," -f1) + sudo=$(echo $l | cut -d"," -f2) + command=$(echo $l | cut -d"," -f3) + printf " \e[1;33m%-${name_len}s\e[0m %-0s: $sudo$command\n" "$name" done echo -e "\033[0m" fi From 603943fac3101e135a1d2644526037e917bca4ee Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 4 Sep 2024 19:48:13 +0200 Subject: [PATCH 5/7] Set default hostname to Armbian --- lib/functions/configuration/main-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functions/configuration/main-config.sh b/lib/functions/configuration/main-config.sh index 8df5570373b6..b417d1d07d2e 100644 --- a/lib/functions/configuration/main-config.sh +++ b/lib/functions/configuration/main-config.sh @@ -94,7 +94,7 @@ function do_main_configuration() { USEALLCORES=yes # Use all CPU cores for compiling [[ -z $EXIT_PATCHING_ERROR ]] && EXIT_PATCHING_ERROR="" # exit patching if failed - [[ -z $HOST ]] && HOST="$BOARD" # set hostname to the board + [[ -z $HOST ]] && HOST="armbian" cd "${SRC}" || exit [[ -z "${CHROOT_CACHE_VERSION}" ]] && CHROOT_CACHE_VERSION=7 From 64dfa074823cbae029f4fd11f99c7ade4608bc69 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 4 Sep 2024 22:15:21 +0200 Subject: [PATCH 6/7] MOTD: display rolling release instead of 0.trunk.$number ... this info doesn't need to be here --- packages/bsp/common/etc/update-motd.d/10-armbian-header | 1 + 1 file changed, 1 insertion(+) 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 92a3f8db7984..bac5b464efd8 100755 --- a/packages/bsp/common/etc/update-motd.d/10-armbian-header +++ b/packages/bsp/common/etc/update-motd.d/10-armbian-header @@ -50,6 +50,7 @@ KERNELID=$(uname -r) echo -e "\e[1;91m$(figlet -f small " $VENDOR")\e[0m"; # Display version, board, and kernel version +[[ $VERSION == *trunk* ]] && VERSION=$(echo -e $VERSION | cut -d"." -f1-2 | sed "s/\$/ rolling/") 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 From 65153eba765e18b81545f5a7c99f571fb3e93545 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Fri, 6 Sep 2024 08:12:17 +0200 Subject: [PATCH 7/7] Revert setting default hostname to Armbian --- lib/functions/configuration/main-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functions/configuration/main-config.sh b/lib/functions/configuration/main-config.sh index b417d1d07d2e..d58ae8ff6519 100644 --- a/lib/functions/configuration/main-config.sh +++ b/lib/functions/configuration/main-config.sh @@ -94,7 +94,7 @@ function do_main_configuration() { USEALLCORES=yes # Use all CPU cores for compiling [[ -z $EXIT_PATCHING_ERROR ]] && EXIT_PATCHING_ERROR="" # exit patching if failed - [[ -z $HOST ]] && HOST="armbian" + [[ -z $HOST ]] && HOST="$BOARD" cd "${SRC}" || exit [[ -z "${CHROOT_CACHE_VERSION}" ]] && CHROOT_CACHE_VERSION=7