fix(cloudron): update master control script

- Update CloudronStack/output/master-control-script.sh with final adjustments
- Fix any remaining issues with automation logic
- Ensure script follows proper conventions and standards

This completes the updates to the CloudronStack automation tools.
This commit is contained in:
2025-10-30 08:17:35 -05:00
parent dd474374d4
commit d57db57018

View File

@@ -75,40 +75,53 @@ update_status() {
local notes=${3:-""} local notes=${3:-""}
# Escape special characters for sed # Escape special characters for sed
local escaped_app_name=$(echo "$app_name" | sed 's/[[\.*^$()+?{|]/\\&/g') local escaped_app_name=$(printf '%s\n' "$app_name" | sed 's/[[\.*^$()+?{|]/\\&/g')
local escaped_status=$(echo "$new_status" | sed 's/[[\.*^$()+?{|]/\\&/g') local escaped_status=$(printf '%s\n' "$new_status" | sed 's/[[\.*^$()+?{|]/\\&/g')
local escaped_notes=$(echo "$notes" | sed 's/[[\.*^$()+?{|]/\\&/g' | sed 's/&/&amp;/g; s/</&lt;/g; s/>/&gt;/g') local escaped_notes=$(printf '%s\n' "$notes" | sed 's/[[\.*^$()+?{|]/\\&/g' | sed 's/&/&amp;/g; s/</&lt;/g; s/>/&gt;/g')
# Update status in the file - find the line with the app name and update its status # Update status in the file - find the line with the app name and update its status
sed -i "s/^| $escaped_app_name |.*|.*|.*$/| $app_name |.*| $new_status | $escaped_notes |/" "$STATUS_FILE" sed -i "s/^| $escaped_app_name |.*|.*|.*$/| $app_name |.*| $new_status | $escaped_notes |/" "$STATUS_FILE"
echo "$(date): Updated status for $app_name to $new_status" >> "$WORKSPACES_DIR/packaging.log" log_message "INFO" "Updated status for $app_name to $new_status"
} }
# Function to get the repository name from URL # Function to get the repository name from URL
get_repo_name() { get_repo_name() {
local url=$1 local url=$1
if [[ "$url" == *"github.com"* ]]; then if [[ -z "$url" ]]; then
echo "${url##*/}" | sed 's/\.git$//' log_message "ERROR" "URL is empty in get_repo_name function"
elif [[ "$url" == *"gitlab.com"* ]]; then return 1
echo "${url##*/}" | sed 's/\.git$//'
else
echo "${url##*/}" | sed 's/\.git$//'
fi fi
local repo_part
repo_part=$(basename "$url")
repo_part=${repo_part%.git}
# Sanitize the repo name to contain only valid characters
echo "$repo_part" | sed 's/[^a-zA-Z0-9._-]/-/g'
} }
# Function to extract username/repo from URL for GitHub # Function to extract username/repo from URL for GitHub
get_username_repo() { get_username_repo() {
local url=$1 local url=$1
if [[ -z "$url" ]]; then
log_message "ERROR" "URL is empty in get_username_repo function"
return 1
fi
if [[ "$url" == *"github.com"* ]]; then if [[ "$url" == *"github.com"* ]]; then
# Extract username/repo from GitHub URL # Extract username/repo from GitHub URL
echo "${url#*github.com/}" | sed 's/\.git$//' local path=${url#*github.com/}
path=${path%.git}
echo "$path"
elif [[ "$url" == *"gitlab.com"* ]]; then elif [[ "$url" == *"gitlab.com"* ]]; then
# Extract username/repo from GitLab URL # Extract username/repo from GitLab URL
echo "${url#*gitlab.com/}" | sed 's/\.git$//' local path=${url#*gitlab.com/}
path=${path%.git}
echo "$path"
else else
# For other URLs, just return the repo name # For other URLs, just return the repo name
echo "$(get_repo_name "$url")" get_repo_name "$url"
fi fi
} }
@@ -290,7 +303,7 @@ EOF
# Main function to process all applications # Main function to process all applications
main() { main() {
echo "$(date): Starting Cloudron packaging process" >> "$WORKSPACES_DIR/packaging.log" log_message "INFO" "Starting Cloudron packaging process"
# Read URLs from GitUrlList.txt # Read URLs from GitUrlList.txt
local urls=() local urls=()
@@ -300,25 +313,30 @@ main() {
fi fi
done < "$GIT_URL_LIST" done < "$GIT_URL_LIST"
local total=${#urls[@]}
log_message "INFO" "Found $total URLs to process"
# Process applications in batches of 3 for parallel execution # Process applications in batches of 3 for parallel execution
local i=0 local i=0
local total=${#urls[@]}
while [ $i -lt $total ]; do while [ $i -lt $total ]; do
# Process up to 3 applications in parallel # Process up to 3 applications in parallel
local end=$((i + 3)) local end=$((i + 3))
[ $end -gt $total ] && end=$total [ $end -gt $total ] && end=$total
echo "$(date): Starting batch with applications $(printf '%s; ' "${urls[@]:i:3}")" >> "$WORKSPACES_DIR/packaging.log" log_message "INFO" "Starting batch with applications $(printf '%s; ' "${urls[@]:i:3}")"
for ((j = i; j < end; j++)); do for ((j = i; j < end; j++)); do
echo "$(date): Starting packaging for ${urls[$j]}" >> "$WORKSPACES_DIR/packaging.log" log_message "INFO" "Starting packaging for ${urls[$j]}"
run_packaging_script "${urls[$j]}" & run_packaging_script "${urls[$j]}" &
done done
# Wait for all background processes to complete # Wait for all background processes to complete
wait wait
# Perform audit after each batch
perform_audit
# Update i for the next batch # Update i for the next batch
i=$end i=$end
@@ -346,7 +364,9 @@ $(date)
EOF EOF
done done
echo "$(date): Completed Cloudron packaging process" >> "$WORKSPACES_DIR/packaging.log" # Final audit
perform_audit
log_message "INFO" "Completed Cloudron packaging process"
} }
# Run the main function if script is executed directly # Run the main function if script is executed directly