Update generate-app-headers.sh
This commit is contained in:
parent
a44a13f81b
commit
0dd24be0be
@ -1,25 +1,31 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Base directory for headers
|
# Function for generating Figlet headers
|
||||||
headers_dir="./ct/headers"
|
generate_headers() {
|
||||||
|
local base_dir=$1
|
||||||
|
local target_subdir=$2
|
||||||
|
local search_pattern=$3
|
||||||
|
|
||||||
# Ensure the headers directory exists and clear it
|
local headers_dir="${base_dir}/headers"
|
||||||
mkdir -p "$headers_dir"
|
mkdir -p "$headers_dir"
|
||||||
rm -f "$headers_dir"/*
|
rm -f "$headers_dir"/*
|
||||||
|
|
||||||
# Find all .sh files in ./ct directory, sorted alphabetically
|
# Recursive or non-recursive search
|
||||||
find ./ct -type f -name "*.sh" | sort | while read -r script; do
|
if [[ "$search_pattern" == "**" ]]; then
|
||||||
# Extract the APP name from the APP line
|
shopt -s globstar nullglob
|
||||||
|
file_list=("${base_dir}"/**/*.sh)
|
||||||
|
shopt -u globstar
|
||||||
|
else
|
||||||
|
file_list=("${base_dir}"/*.sh)
|
||||||
|
fi
|
||||||
|
|
||||||
|
for script in "${file_list[@]}"; do
|
||||||
|
[[ -f "$script" ]] || continue
|
||||||
|
|
||||||
app_name=$(grep -oP '^APP="\K[^"]+' "$script" 2>/dev/null)
|
app_name=$(grep -oP '^APP="\K[^"]+' "$script" 2>/dev/null)
|
||||||
|
|
||||||
if [[ -n "$app_name" ]]; then
|
if [[ -n "$app_name" ]]; then
|
||||||
# Define the output file name in the headers directory
|
|
||||||
output_file="${headers_dir}/$(basename "${script%.*}")"
|
output_file="${headers_dir}/$(basename "${script%.*}")"
|
||||||
|
|
||||||
# Generate figlet output
|
|
||||||
figlet_output=$(figlet -w 500 -f slant "$app_name")
|
figlet_output=$(figlet -w 500 -f slant "$app_name")
|
||||||
|
|
||||||
# Check if figlet output is not empty
|
|
||||||
if [[ -n "$figlet_output" ]]; then
|
if [[ -n "$figlet_output" ]]; then
|
||||||
echo "$figlet_output" >"$output_file"
|
echo "$figlet_output" >"$output_file"
|
||||||
echo "Generated: $output_file"
|
echo "Generated: $output_file"
|
||||||
@ -30,5 +36,15 @@ find ./ct -type f -name "*.sh" | sort | while read -r script; do
|
|||||||
echo "No APP name found in $script, skipping."
|
echo "No APP name found in $script, skipping."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
echo "Completed processing .sh files."
|
# ct
|
||||||
|
generate_headers "./ct" "headers" "*"
|
||||||
|
|
||||||
|
# tools (addon, pve, ...)
|
||||||
|
generate_headers "./tools" "headers" "**"
|
||||||
|
|
||||||
|
# vm
|
||||||
|
generate_headers "./vm" "headers" "*"
|
||||||
|
|
||||||
|
echo "Completed processing all sections."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user