Skip to content

Commit 938f0f7

Browse files
authored
Add Figlet into Repo | Creation of local ASCII Header (#1072)
* Add Figlet into Repo | Creation of local ASCII Header * update develop > main
1 parent 611a14b commit 938f0f7

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

misc/build.func

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -189,28 +189,44 @@ update_motd_ip() {
189189

190190
# This function sets the APP-Name into an ASCII Header in Slant, figlet needed on proxmox main node.
191191
header_info() {
192-
if [ -f /etc/debian_version ]; then
193-
# Debian/Ubuntu
194-
if ! grep -q "^deb http://ftp.debian.org/debian bookworm main contrib" /etc/apt/sources.list; then
195-
echo "deb http://ftp.debian.org/debian bookworm main contrib" >> /etc/apt/sources.list
192+
# Check if figlet is installed
193+
if ! command -v figlet &> /dev/null; then
194+
echo -e "${INFO}${BOLD}${DGN}Figlet for ASCII-Header not found. Installing... ${CL}"
195+
196+
# Install necessary dependencies and figlet
197+
if [ -f /etc/debian_version ] || [ -f /etc/lsb-release ]; then
196198
apt-get update -y &> /dev/null
199+
apt-get install -y tar build-essential &> /dev/null
200+
elif [ -f /etc/alpine-release ]; then
201+
apk add --no-cache tar build-base &> /dev/null
202+
export TERM=xterm
203+
else
204+
return 1
197205
fi
198-
apt-get install -y figlet &> /dev/null
199-
elif [ -f /etc/alpine-release ]; then
200-
# Alpine Linux
201-
apk add --no-cache figlet ncurses &> /dev/null
202-
export TERM=xterm
203-
else
204-
echo "Unsupported OS"
205-
return 1
206+
temp_dir=$(mktemp -d)
207+
curl -sL https://github.com/community-scripts/ProxmoxVE/raw/refs/heads/main/misc/figlet.tar.xz -o "$temp_dir/figlet.tar.xz"
208+
mkdir -p /tmp/figlet
209+
tar -xf "$temp_dir/figlet.tar.xz" -C /tmp/figlet --strip-components=1
210+
cd /tmp/figlet
211+
# Run make to compile the figlet binary
212+
make >/dev/null
213+
# Check if the figlet binary exists
214+
if [ -f "figlet" ]; then
215+
chmod +x figlet
216+
# Move figlet to /usr/local/bin if not already there
217+
if [ ! -e /usr/local/bin/figlet ]; then
218+
mv figlet /usr/local/bin/
219+
mkdir -p /usr/local/share/figlet
220+
cp -r /tmp/figlet/fonts/*.flf /usr/local/share/figlet/
221+
fi
222+
echo -e "${CM}${BOLD}${DGN}Figlet successfully installed. ${CL}"
223+
fi
224+
rm -rf "$temp_dir"
206225
fi
207-
208-
term_width=$(tput cols 2>/dev/null || echo 120) # Fallback to 120 columns
226+
term_width=$(tput cols 2>/dev/null || echo 120)
209227
ascii_art=$(figlet -f slant -w "$term_width" "$APP")
210228
clear
211-
cat <<EOF
212-
$ascii_art
213-
EOF
229+
echo "$ascii_art"
214230
}
215231

216232
# 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

Comments
 (0)