diff --git a/misc/build.func b/misc/build.func index 1fe025a2..93a8519e 100644 --- a/misc/build.func +++ b/misc/build.func @@ -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 <