@@ -233,65 +233,41 @@ update_motd_ip() {
233233 fi
234234}
235235
236- # This function sets the APP-Name into an ASCII Header in Slant, figlet needed on proxmox main node.
237- header_info() {
238- # Helper function: Install FIGlet and download fonts
239- install_figlet() {
240- echo -e "${INFO}${BOLD}${DGN}Installing FIGlet...${CL}"
241-
242- temp_dir=$(mktemp -d)
243- curl -sL https://github.com/community-scripts/ProxmoxVE/raw/refs/heads/main/misc/figlet.tar.xz -o "$temp_dir/figlet.tar.xz"
244- mkdir -p /tmp/figlet
245- tar -xf "$temp_dir/figlet.tar.xz" -C /tmp/figlet --strip-components=1
246- cd /tmp/figlet
247- make >/dev/null
248-
249- if [ -f "figlet" ]; then
250- chmod +x figlet
251- mv figlet /usr/local/bin/
252- mkdir -p /usr/local/share/figlet
253- cp -r /tmp/figlet/fonts/*.flf /usr/local/share/figlet/
254- echo -e "${CM}${BOLD}${DGN}FIGlet successfully installed.${CL}"
255- else
256- echo -e "${ERR}${BOLD}${RED}Failed to install FIGlet.${CL}"
257- return 1
258- fi
259- rm -rf "$temp_dir"
260- }
261-
262- # Check if figlet and the slant font are available
263- if ! figlet -f slant "Test" &>/dev/null; then
264- echo -e "${INFO}${BOLD}${DGN}FIGlet or the slant font is missing. Installing...${CL}"
265-
266- if [ -f /etc/debian_version ] || [ -f /etc/lsb-release ]; then
267- # Debian/Ubuntu-based systems
268- apt-get update -y &>/dev/null
269- apt-get install -y wget build-essential &>/dev/null
270- install_figlet
236+ # Function to download & save header files
237+ get_header() {
238+ local app_name=$(echo ${APP,,} | tr -d ' ')
239+ local header_url="https://github.com/community-scripts/ProxmoxVE/raw/main/ct/headers/${app_name}"
240+ local local_header_path="/usr/local/community-scripts/headers/${app_name}"
271241
272- elif [ -f /etc/alpine-release ]; then
273- # Alpine-based systems
274- apk add --no-cache tar xz build-base wget &>/dev/null
275- export TERM=xterm
276- install_figlet
242+ mkdir -p "/usr/local/community-scripts/headers"
277243
278- else
279- echo -e "${ERR}${BOLD}${RED}Unsupported operating system.${CL}"
244+ # Check if local file already present
245+ if [ ! -f "$local_header_path" ]; then
246+ wget -qO "$local_header_path" "$header_url"
247+ if [ $? -ne 0 ]; then
248+ echo -e "${WARN}${BOLD}${YLW}Failed to download header for ${app_name}. No header will be displayed.${CL}"
280249 return 1
281250 fi
251+ fi
252+ cat "$local_header_path"
253+ }
282254
283- # Ensure the slant font is available
284- if [ ! -f "/usr/share/figlet/slant.flf" ]; then
285- echo -e "${INFO}${BOLD}${DGN}Downloading slant font...${CL}"
286- wget -qO /usr/share/figlet/slant.flf "http://www.figlet.org/fonts/slant.flf"
287- fi
255+ # This function sets the APP-Name into an ASCII Header in Slant, figlet needed on proxmox main node.
256+ header_info() {
257+ local app_name=$(echo ${APP,,} | tr -d ' ')
258+ local header_content
259+
260+ # Download & save Header-File locally
261+ header_content=$(get_header "$app_name")
262+ if [ $? -ne 0 ]; then
263+ # Fallback: Doesn't show Header
264+ return 0
288265 fi
289266
290- # Display ASCII header
267+ # Show ASCII-Header
291268 term_width=$(tput cols 2>/dev/null || echo 120)
292- ascii_art=$(figlet -f slant -w "$term_width" "$APP")
293269 clear
294- echo "$ascii_art "
270+ echo "$header_content "
295271}
296272
297273# This function checks if the script is running through SSH and prompts the user to confirm if they want to proceed or exit.
0 commit comments