Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Userspace: UX changes at MOTD and first login #7174

Merged
merged 7 commits into from
Sep 8, 2024
Merged
2 changes: 1 addition & 1 deletion lib/functions/configuration/main-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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="$BOARD"
cd "${SRC}" || exit

[[ -z "${CHROOT_CACHE_VERSION}" ]] && CHROOT_CACHE_VERSION=7
Expand Down
2 changes: 1 addition & 1 deletion packages/bsp/common/etc/default/armbian-motd.dpkg-dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions packages/bsp/common/etc/update-motd.d/00-clear
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions packages/bsp/common/etc/update-motd.d/10-armbian-header
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ if [[ $(command -v zpool) ]]; then
line=$((line+1))
fi
fi
if [[ $line -ne 0 ]]; then echo ""; fi
echo ""
36 changes: 25 additions & 11 deletions packages/bsp/common/etc/update-motd.d/41-commands
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,43 @@ 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"
"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
name_len=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"
# 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
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%-${name_len}s\e[0m %-0s: $sudo$command\n" "$name"
done
echo -e "\033[0m"
fi

exit 0
5 changes: 4 additions & 1 deletion packages/bsp/common/usr/lib/armbian/armbian-firstlogin
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down