Skip to content

Commit

Permalink
Show running Docker containers in the MOTD
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Feb 8, 2025
1 parent 287853f commit d96e048
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
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="clear"
ONE_WIRE=""
HIDE_IP_PATTERN="^dummy0|^lo|^docker|^hassio|^br-|^veth"
HIDE_IP_PATTERN="^dummy0|^lo|^docker|^hassio|^br-|^veth|^vnet|^virbr"
PRIMARY_INTERFACE="$(ip route | grep '^default' | sed "s/.*dev //" | cut -d" " -f1)"
PRIMARY_DIRECTION="rx"
STORAGE=/dev/sda1
Expand Down
15 changes: 12 additions & 3 deletions packages/bsp/common/etc/update-motd.d/10-armbian-header
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

THIS_SCRIPT="header"
MOTD_DISABLE=""
HIDE_IP_PATTERN="^dummy0|^lo|^docker|^hassio|^br-|^veth"
HIDE_IP_PATTERN="^dummy0|^lo|^docker|^hassio|^br-|^veth|^vnet|^virbr"

# Read image configuration
[[ -f /etc/armbian-image-release ]] && . /etc/armbian-image-release
Expand Down Expand Up @@ -76,8 +76,7 @@ function get_ip_addresses() {
[[ -n $ipv6 ]] && ipv6s+=("$ipv6")
fi
done

echo "${ipv4s[@]}|${ipv6s[@]}"
echo "${ipv4s[*]}|${ipv6s[*]}"
} # get_ip_addresses

# Read Armbian kernel version
Expand Down Expand Up @@ -134,6 +133,11 @@ if [[ $NUM_UPDATES -gt 0 ]]; then
UPDATE_STATUS+=" available for upgrade\e[0m "
fi

# read running Docker containers if any
if systemctl is-active docker >/dev/null; then
CONTAINERS_STATUS=$(docker ps --format "{{.Names}}" | tr '\n' ',' | sed 's/,/, /g' | sed 's/, $//')
fi

echo ""

# Display packages status
Expand All @@ -160,6 +164,11 @@ if [[ -n $wan_ip_address ]]; then
echo -e "\x1B[93m(WAN)\x1B[0m $wan_ip_address"
fi

# Display running docker containers
if [[ -n "${CONTAINERS_STATUS}" ]]; then
echo -e " Containers: \x1B[92m$CONTAINERS_STATUS\x1B[0m"
fi

# Display hostapd
if [[ -n $ssid ]]; then
echo -e " WiFi AP: SSID: (\x1B[91m$ssid\x1B[0m), $(iw $interface info | grep channel | xargs)"
Expand Down

0 comments on commit d96e048

Please sign in to comment.