first commit
This commit is contained in:
100
BadAI/banner.sh
Normal file
100
BadAI/banner.sh
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env bash
|
||||
# Lightweight banner for BadAI host system — Ubuntu with AMDGPU drivers
|
||||
|
||||
oem_info() {
|
||||
local v="" m="" d lv lm
|
||||
for d in /sys/class/dmi/id /sys/devices/virtual/dmi/id; do
|
||||
[[ -r "$d/sys_vendor" ]] && v=$(<"$d/sys_vendor")
|
||||
[[ -r "$d/product_name" ]] && m=$(<"$d/product_name")
|
||||
[[ -n "$v" || -n "$m" ]] && break
|
||||
done
|
||||
# ARM/SBC fallback
|
||||
if [[ -z "$v" && -z "$m" && -r /proc/device-tree/model ]]; then
|
||||
tr -d '\0' </proc/device-tree/model
|
||||
return
|
||||
fi
|
||||
lv=$(printf '%s' "$v" | tr '[:upper:]' '[:lower:]')
|
||||
lm=$(printf '%s' "$m" | tr '[:upper:]' '[:lower:]')
|
||||
if [[ -n "$m" && "$lm" == "$lv "* ]]; then
|
||||
printf '%s\n' "$m"
|
||||
else
|
||||
printf '%s %s\n' "${v:-Unknown}" "${m:-Unknown}"
|
||||
fi
|
||||
}
|
||||
|
||||
gpu_name() {
|
||||
local name=""
|
||||
if command -v lspci >/dev/null 2>&1; then
|
||||
name=$(lspci -nn 2>/dev/null | grep -Ei 'vga|display|gpu' | grep -i amd | head -n1 | cut -d: -f3-)
|
||||
fi
|
||||
name=$(printf '%s' "$name" | sed -e 's/^[[:space:]]\+//' -e 's/[[:space:]]\+$//' -e 's/[[:space:]]\{2,\}/ /g')
|
||||
printf '%s\n' "${name:-Unknown AMD GPU}"
|
||||
}
|
||||
|
||||
ubuntu_version() {
|
||||
lsb_release -d 2>/dev/null | cut -f2 || uname -a
|
||||
}
|
||||
|
||||
system_load() {
|
||||
uptime | awk -F'load average:' '{ print $2 }' | sed 's/,//g'
|
||||
}
|
||||
|
||||
memory_usage() {
|
||||
free -h | awk 'NR==2{printf "%.0f%%", $3*100/$2 }'
|
||||
}
|
||||
|
||||
updates_info() {
|
||||
if command -v apt >/dev/null 2>&1; then
|
||||
local upgradable=$(apt list --upgradable 2>/dev/null | grep -v '^Listing' | grep -c '^[^/]*$')
|
||||
local security=$(apt list --upgradable 2>/dev/null | grep -c 'security')
|
||||
printf '%d updates can be applied immediately.\n' "$upgradable"
|
||||
if [[ $security -gt 0 ]]; then
|
||||
printf '%d additional security updates can be applied.\n' "$security"
|
||||
fi
|
||||
else
|
||||
printf 'Updates info not available.\n'
|
||||
fi
|
||||
}
|
||||
|
||||
MACHINE="$(oem_info)"
|
||||
GPU="$(gpu_name)"
|
||||
UBUNTU_VER="$(ubuntu_version)"
|
||||
LOAD="$(system_load)"
|
||||
MEM="$(memory_usage)"
|
||||
|
||||
echo
|
||||
cat <<'ASCII'
|
||||
|
||||
__________ .___ _____ .___
|
||||
\______ \_____ __| _/ / _ \ | |
|
||||
| | _/\__ \ / __ | / /_\ \| |
|
||||
| | \ / __ \_/ /_/ | / | \ |
|
||||
|______ /(____ /\____ | \____|__ /___|
|
||||
\/ \/ \/ \/
|
||||
|
||||
|
||||
B A D A I - H O S T ( U B U N T U , A M D G P U )
|
||||
|
||||
ASCII
|
||||
|
||||
echo "--------------------------------------------------------------------------------"
|
||||
printf 'Machine: %s\n' "$MACHINE"
|
||||
printf 'GPU : %s\n' "$GPU"
|
||||
printf 'OS : %s\n' "$UBUNTU_VER"
|
||||
printf 'Load : %s\n' "$LOAD"
|
||||
printf 'Memory : %s\n' "$MEM"
|
||||
|
||||
echo
|
||||
echo "--------------------------------------------------------------------------------"
|
||||
updates_info
|
||||
|
||||
echo
|
||||
echo "--------------------------------------------------------------------------------"
|
||||
printf 'Usage:\n'
|
||||
printf ' - %-24s → %s\n' "podman ps" "List running containers"
|
||||
printf ' - %-24s → %s\n' "podman logs <name>" "View container logs"
|
||||
printf ' - %-24s → %s\n' "podman exec -it <name> bash" "Access container shell"
|
||||
printf ' - %-24s → %s\n' "radentop" "Monitor AMD GPU usage (if installed)"
|
||||
printf ' - %-24s → %s\n' "htop" "Monitor system processes and resources"
|
||||
printf ' - %-24s → %s\n' "duckai restart" "Restart all services"
|
||||
printf ' - %-24s → %s\n' "duckai help" "Show DuckAI commands"
|
||||
Reference in New Issue
Block a user