1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-04-20 12:28:08 +00:00

[core]: Remove Figlet | Get Headers by Repo & Store Local (#1802)

* [core]: Remove Figlet | Get Headers by Repo & Store Local

* change repo
This commit is contained in:
CanbiZ 2025-01-28 12:07:39 +01:00 committed by GitHub
parent 84b982ffa8
commit ff06d417b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -233,65 +233,41 @@ update_motd_ip() {
fi fi
} }
# This function sets the APP-Name into an ASCII Header in Slant, figlet needed on proxmox main node. # Function to download & save header files
header_info() { get_header() {
# Helper function: Install FIGlet and download fonts local app_name=$(echo ${APP,,} | tr -d ' ')
install_figlet() { local header_url="https://github.com/community-scripts/ProxmoxVE/raw/main/ct/headers/${app_name}"
echo -e "${INFO}${BOLD}${DGN}Installing FIGlet...${CL}" local local_header_path="/usr/local/community-scripts/headers/${app_name}"
temp_dir=$(mktemp -d) mkdir -p "/usr/local/community-scripts/headers"
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
make >/dev/null
if [ -f "figlet" ]; then # Check if local file already present
chmod +x figlet if [ ! -f "$local_header_path" ]; then
mv figlet /usr/local/bin/ wget -qO "$local_header_path" "$header_url"
mkdir -p /usr/local/share/figlet if [ $? -ne 0 ]; then
cp -r /tmp/figlet/fonts/*.flf /usr/local/share/figlet/ echo -e "${WARN}${BOLD}${YLW}Failed to download header for ${app_name}. No header will be displayed.${CL}"
echo -e "${CM}${BOLD}${DGN}FIGlet successfully installed.${CL}"
else
echo -e "${ERR}${BOLD}${RED}Failed to install FIGlet.${CL}"
return 1 return 1
fi fi
rm -rf "$temp_dir" fi
cat "$local_header_path"
} }
# Check if figlet and the slant font are available # This function sets the APP-Name into an ASCII Header in Slant, figlet needed on proxmox main node.
if ! figlet -f slant "Test" &>/dev/null; then header_info() {
echo -e "${INFO}${BOLD}${DGN}FIGlet or the slant font is missing. Installing...${CL}" local app_name=$(echo ${APP,,} | tr -d ' ')
local header_content
if [ -f /etc/debian_version ] || [ -f /etc/lsb-release ]; then # Download & save Header-File locally
# Debian/Ubuntu-based systems header_content=$(get_header "$app_name")
apt-get update -y &>/dev/null if [ $? -ne 0 ]; then
apt-get install -y wget build-essential &>/dev/null # Fallback: Doesn't show Header
install_figlet return 0
elif [ -f /etc/alpine-release ]; then
# Alpine-based systems
apk add --no-cache tar xz build-base wget &>/dev/null
export TERM=xterm
install_figlet
else
echo -e "${ERR}${BOLD}${RED}Unsupported operating system.${CL}"
return 1
fi fi
# Ensure the slant font is available # Show ASCII-Header
if [ ! -f "/usr/share/figlet/slant.flf" ]; then
echo -e "${INFO}${BOLD}${DGN}Downloading slant font...${CL}"
wget -qO /usr/share/figlet/slant.flf "http://www.figlet.org/fonts/slant.flf"
fi
fi
# Display ASCII header
term_width=$(tput cols 2>/dev/null || echo 120) term_width=$(tput cols 2>/dev/null || echo 120)
ascii_art=$(figlet -f slant -w "$term_width" "$APP")
clear clear
echo "$ascii_art" echo "$header_content"
} }
# This function checks if the script is running through SSH and prompts the user to confirm if they want to proceed or exit. # This function checks if the script is running through SSH and prompts the user to confirm if they want to proceed or exit.