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:
@@ -75,40 +75,53 @@ update_status() {
|
||||
local notes=${3:-""}
|
||||
|
||||
# Escape special characters for sed
|
||||
local escaped_app_name=$(echo "$app_name" | sed 's/[[\.*^$()+?{|]/\\&/g')
|
||||
local escaped_status=$(echo "$new_status" | sed 's/[[\.*^$()+?{|]/\\&/g')
|
||||
local escaped_notes=$(echo "$notes" | sed 's/[[\.*^$()+?{|]/\\&/g' | sed 's/&/&/g; s/</</g; s/>/>/g')
|
||||
local escaped_app_name=$(printf '%s\n' "$app_name" | sed 's/[[\.*^$()+?{|]/\\&/g')
|
||||
local escaped_status=$(printf '%s\n' "$new_status" | sed 's/[[\.*^$()+?{|]/\\&/g')
|
||||
local escaped_notes=$(printf '%s\n' "$notes" | sed 's/[[\.*^$()+?{|]/\\&/g' | sed 's/&/&/g; s/</</g; s/>/>/g')
|
||||
|
||||
# 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"
|
||||
|
||||
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
|
||||
get_repo_name() {
|
||||
local url=$1
|
||||
if [[ "$url" == *"github.com"* ]]; then
|
||||
echo "${url##*/}" | sed 's/\.git$//'
|
||||
elif [[ "$url" == *"gitlab.com"* ]]; then
|
||||
echo "${url##*/}" | sed 's/\.git$//'
|
||||
else
|
||||
echo "${url##*/}" | sed 's/\.git$//'
|
||||
if [[ -z "$url" ]]; then
|
||||
log_message "ERROR" "URL is empty in get_repo_name function"
|
||||
return 1
|
||||
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
|
||||
get_username_repo() {
|
||||
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
|
||||
# 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
|
||||
# Extract username/repo from GitLab URL
|
||||
echo "${url#*gitlab.com/}" | sed 's/\.git$//'
|
||||
local path=${url#*gitlab.com/}
|
||||
path=${path%.git}
|
||||
echo "$path"
|
||||
else
|
||||
# For other URLs, just return the repo name
|
||||
echo "$(get_repo_name "$url")"
|
||||
get_repo_name "$url"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -290,7 +303,7 @@ EOF
|
||||
|
||||
# Main function to process all applications
|
||||
main() {
|
||||
echo "$(date): Starting Cloudron packaging process" >> "$WORKSPACES_DIR/packaging.log"
|
||||
log_message "INFO" "Starting Cloudron packaging process"
|
||||
|
||||
# Read URLs from GitUrlList.txt
|
||||
local urls=()
|
||||
@@ -300,25 +313,30 @@ main() {
|
||||
fi
|
||||
done < "$GIT_URL_LIST"
|
||||
|
||||
local total=${#urls[@]}
|
||||
log_message "INFO" "Found $total URLs to process"
|
||||
|
||||
# Process applications in batches of 3 for parallel execution
|
||||
local i=0
|
||||
local total=${#urls[@]}
|
||||
|
||||
while [ $i -lt $total ]; do
|
||||
# Process up to 3 applications in parallel
|
||||
local end=$((i + 3))
|
||||
[ $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
|
||||
echo "$(date): Starting packaging for ${urls[$j]}" >> "$WORKSPACES_DIR/packaging.log"
|
||||
log_message "INFO" "Starting packaging for ${urls[$j]}"
|
||||
run_packaging_script "${urls[$j]}" &
|
||||
done
|
||||
|
||||
# Wait for all background processes to complete
|
||||
wait
|
||||
|
||||
# Perform audit after each batch
|
||||
perform_audit
|
||||
|
||||
# Update i for the next batch
|
||||
i=$end
|
||||
|
||||
@@ -346,7 +364,9 @@ $(date)
|
||||
EOF
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user