ProxmoxVE/.github/workflows/scripts/generate-app-headers.sh

35 lines
979 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2025-01-24 13:47:51 +00:00
# Base directory for headers
headers_dir="./ct/headers"
2025-01-24 13:50:19 +00:00
# Ensure the headers directory exists and clear it
2025-01-24 13:47:51 +00:00
mkdir -p "$headers_dir"
2025-01-24 13:50:19 +00:00
rm -f "$headers_dir"/*
2025-01-24 13:47:51 +00:00
# Find all .sh files in ./ct directory, sorted alphabetically
find ./ct -type f -name "*.sh" | sort | while read -r script; do
# Extract the APP name from the APP line
app_name=$(grep -oP '^APP="\K[^"]+' "$script" 2>/dev/null)
if [[ -n "$app_name" ]]; then
2025-01-24 13:47:51 +00:00
# Define the output file name in the headers directory
output_file="${headers_dir}/$(basename "${script%.*}")"
2025-01-24 13:50:19 +00:00
# Generate figlet output
figlet_output=$(figlet -f slant "$app_name")
2025-01-24 13:50:19 +00:00
# Check if figlet output is not empty
if [[ -n "$figlet_output" ]]; then
echo "$figlet_output" > "$output_file"
echo "Generated: $output_file"
else
2025-01-24 13:50:19 +00:00
echo "Figlet failed for $app_name in $script"
fi
else
echo "No APP name found in $script, skipping."
fi
done
echo "Completed processing .sh files."