Add Figlet into Repo | Creation of local ASCII Header (#1072)

* Add Figlet into Repo | Creation of local ASCII Header

* update develop > main
This commit is contained in:
CanbiZ 2024-12-28 20:59:16 +01:00 committed by GitHub
parent 611a14b55f
commit 938f0f76fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -189,28 +189,44 @@ update_motd_ip() {
# This function sets the APP-Name into an ASCII Header in Slant, figlet needed on proxmox main node.
header_info() {
if [ -f /etc/debian_version ]; then
# Debian/Ubuntu
if ! grep -q "^deb http://ftp.debian.org/debian bookworm main contrib" /etc/apt/sources.list; then
echo "deb http://ftp.debian.org/debian bookworm main contrib" >> /etc/apt/sources.list
apt-get update -y &> /dev/null
fi
apt-get install -y figlet &> /dev/null
elif [ -f /etc/alpine-release ]; then
# Alpine Linux
apk add --no-cache figlet ncurses &> /dev/null
export TERM=xterm
else
echo "Unsupported OS"
return 1
fi
# Check if figlet is installed
if ! command -v figlet &> /dev/null; then
echo -e "${INFO}${BOLD}${DGN}Figlet for ASCII-Header not found. Installing... ${CL}"
term_width=$(tput cols 2>/dev/null || echo 120) # Fallback to 120 columns
# Install necessary dependencies and figlet
if [ -f /etc/debian_version ] || [ -f /etc/lsb-release ]; then
apt-get update -y &> /dev/null
apt-get install -y tar build-essential &> /dev/null
elif [ -f /etc/alpine-release ]; then
apk add --no-cache tar build-base &> /dev/null
export TERM=xterm
else
return 1
fi
temp_dir=$(mktemp -d)
curl -sL https://github.com/community-scripts/ProxmoxVE/raw/refs/heads/main/misc/figlet.tar.xz -o "$temp_dir/figlet.tar.xz"
mkdir -p /tmp/figlet
tar -xf "$temp_dir/figlet.tar.xz" -C /tmp/figlet --strip-components=1
cd /tmp/figlet
# Run make to compile the figlet binary
make >/dev/null
# Check if the figlet binary exists
if [ -f "figlet" ]; then
chmod +x figlet
# Move figlet to /usr/local/bin if not already there
if [ ! -e /usr/local/bin/figlet ]; then
mv figlet /usr/local/bin/
mkdir -p /usr/local/share/figlet
cp -r /tmp/figlet/fonts/*.flf /usr/local/share/figlet/
fi
echo -e "${CM}${BOLD}${DGN}Figlet successfully installed. ${CL}"
fi
rm -rf "$temp_dir"
fi
term_width=$(tput cols 2>/dev/null || echo 120)
ascii_art=$(figlet -f slant -w "$term_width" "$APP")
clear
cat <<EOF
$ascii_art
EOF
echo "$ascii_art"
}
# This function checks if the script is running through SSH and prompts the user to confirm if they want to proceed or exit.