feat(cloudron): update automation and packaging scripts

- Update CloudronStack/output/master-control-script.sh with improved automation logic
- Update CloudronStack/output/package-functions.sh with enhanced packaging capabilities
- Refine script functionality and ensure proper integration
- Align with project standards and conventions

This enhances the CloudronStack automation and packaging capabilities.
This commit is contained in:
2025-10-30 10:48:22 -05:00
parent 4111a6bcd7
commit eb3cbb803d
2 changed files with 96 additions and 22 deletions

View File

@@ -1,8 +1,9 @@
#!/bin/bash
# Master Control Script for Cloudron Packaging
# This script orchestrates the packaging of all applications from GitUrlList.txt
# This script orchestrates the packaging of applications from a Git URL list
# It runs three packaging projects in parallel and maintains status tracking
# Usage: ./master-control-script.sh [/path/to/git-url-list.txt]
set -e # Exit on any error
set -u # Exit on undefined variables
@@ -14,7 +15,14 @@ OUTPUT_DIR="$SCRIPT_DIR"
ARTIFACTS_DIR="$OUTPUT_DIR/CloudronPackages-Artifacts"
WORKSPACES_DIR="$OUTPUT_DIR/CloudronPackages-Workspaces"
STATUS_FILE="$(dirname "$SCRIPT_DIR")/collab/STATUS.md"
GIT_URL_LIST="$(dirname "$SCRIPT_DIR")/collab/GitUrlList.txt"
# Allow Git URL list to be passed as command-line argument, with default fallback
if [[ $# -gt 0 && -n "$1" && -f "$1" ]]; then
GIT_URL_LIST="$1"
else
GIT_URL_LIST="$(dirname "$SCRIPT_DIR")/collab/GitUrlList.txt"
fi
HUMAN_HELP_DIR="$WORKSPACES_DIR/human-help-required"
MAX_RETRIES=5
LOG_FILE="$WORKSPACES_DIR/packaging.log"
@@ -307,6 +315,7 @@ run_packaging_script() {
local username_repo=$(get_username_repo "$url")
local workspace_dir="$WORKSPACES_DIR/$repo_name"
local artifact_dir="$ARTIFACTS_DIR/$repo_name"
local app_log_file="$artifact_dir/${repo_name}-package.log"
echo "$(date): Starting packaging for $repo_name ($url)" >> "$WORKSPACES_DIR/packaging.log"
@@ -316,17 +325,20 @@ run_packaging_script() {
# Initialize workspace
mkdir -p "$workspace_dir" "$artifact_dir"
# Create application-specific log file
touch "$app_log_file"
# Clone repository
if [ ! -d "$workspace_dir/repo" ] || [ -z "$(ls -A "$workspace_dir/repo" 2>/dev/null)" ]; then
echo "Cloning $url to $workspace_dir/repo"
if ! git clone "$url" "$workspace_dir/repo"; then
echo "Cloning $url to $workspace_dir/repo" | tee -a "$app_log_file"
if ! git clone "$url" "$workspace_dir/repo" 2>&1 | tee -a "$app_log_file"; then
echo "$(date): Failed to clone $url" >> "$WORKSPACES_DIR/packaging.log"
update_status "$repo_name" "🛑 FAILED" "Failed to clone repository"
return 1
fi
else
# Update repository
echo "Updating $url in $workspace_dir/repo"
echo "Updating $url in $workspace_dir/repo" | tee -a "$app_log_file"
if ! (cd "$workspace_dir/repo" &&
git remote -v &&
git fetch origin &&
@@ -345,12 +357,12 @@ run_packaging_script() {
git reset --hard origin/master 2>/dev/null ||
git pull origin main 2>/dev/null ||
git pull origin master 2>/dev/null
fi); then
fi) 2>&1 | tee -a "$app_log_file"; then
echo "$(date): Failed to update $url" >> "$WORKSPACES_DIR/packaging.log"
update_status "$repo_name" "🔄 IN PROGRESS" "Repo update failed, will retry with fresh clone"
# Remove the repo and try to clone again
rm -rf "$workspace_dir/repo"
if ! git clone "$url" "$workspace_dir/repo"; then
if ! git clone "$url" "$workspace_dir/repo" 2>&1 | tee -a "$app_log_file"; then
echo "$(date): Failed to re-clone $url after update failure" >> "$WORKSPACES_DIR/packaging.log"
update_status "$repo_name" "🛑 FAILED" "Failed to update or re-clone repository"
return 1
@@ -416,9 +428,11 @@ package_application() {
local url=${5:-"https://github.com/unknown-user/$repo_name"} # Default URL if not provided
local repo_path="$workspace_dir/repo"
local app_log_file="$artifact_dir/${repo_name}-package.log"
# Use the function library to detect and package the application
detect_and_package "$repo_name" "$repo_path" "$artifact_dir" "$url"
# Redirect output to both the main log and the application-specific log
detect_and_package "$repo_name" "$repo_path" "$artifact_dir" "$url" 2>&1 | tee -a "$app_log_file"
}
# Function to create a Dockerfile based on the application type