mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-06-30 02:57:38 +00:00
[Core] Better Creation of App Headers for next feature (#1719)
* Update Function to crawl app Headers * Update Function to crawl app Headers
This commit is contained in:
@ -1,33 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
output_file="./misc/.app-headers"
|
||||
> "$output_file" # Clear or create the file
|
||||
|
||||
current_date=$(date +"%m-%d-%Y")
|
||||
# Header with date
|
||||
{
|
||||
echo "### Generated on $current_date"
|
||||
echo "##################################################"
|
||||
echo
|
||||
} >> "$output_file"
|
||||
|
||||
# Find only regular .sh files in ./ct, sort them alphabetically
|
||||
# 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
|
||||
# Generate figlet output
|
||||
figlet_output=$(figlet -f slant "$app_name")
|
||||
{
|
||||
echo "### $(basename "$script")"
|
||||
echo "APP=$app_name"
|
||||
echo "$figlet_output"
|
||||
echo
|
||||
} >> "$output_file"
|
||||
# Define the output file name based on the .sh file
|
||||
output_file="${script%.sh}.app"
|
||||
|
||||
# Check if the output file already exists
|
||||
if [[ ! -f "$output_file" ]]; then
|
||||
# Generate figlet output
|
||||
figlet_output=$(figlet -f slant "$app_name")
|
||||
|
||||
# Write the figlet output to the file
|
||||
echo "$figlet_output" > "$output_file"
|
||||
echo "Generated: $output_file"
|
||||
else
|
||||
echo "Skipped: $output_file already exists"
|
||||
fi
|
||||
else
|
||||
echo "No APP name found in $script, skipping."
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Generated combined file at $output_file"
|
||||
echo "Completed processing .sh files."
|
||||
|
Reference in New Issue
Block a user