mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 02:12:49 +00:00 
			
		
		
		
	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:
		@@ -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
 | 
			
		||||
  # 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}"
 | 
			
		||||
 | 
			
		||||
    # Install necessary dependencies and figlet
 | 
			
		||||
    if [ -f /etc/debian_version ] || [ -f /etc/lsb-release ]; then
 | 
			
		||||
      apt-get update -y &> /dev/null
 | 
			
		||||
    fi
 | 
			
		||||
    apt-get install -y figlet &> /dev/null
 | 
			
		||||
      apt-get install -y tar build-essential &> /dev/null
 | 
			
		||||
    elif [ -f /etc/alpine-release ]; then
 | 
			
		||||
    # Alpine Linux
 | 
			
		||||
    apk add --no-cache figlet ncurses &> /dev/null
 | 
			
		||||
      apk add --no-cache tar build-base &> /dev/null
 | 
			
		||||
      export TERM=xterm
 | 
			
		||||
    else
 | 
			
		||||
    echo "Unsupported OS"
 | 
			
		||||
      return 1
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
  term_width=$(tput cols 2>/dev/null || echo 120)  # Fallback to 120 columns
 | 
			
		||||
    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.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user