36 lines
991 B
Bash
36 lines
991 B
Bash
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# Log function
|
|
log() {
|
|
echo "[APT-MODULE] $1"
|
|
}
|
|
|
|
# Check if we have the required environment variables
|
|
if [ -z "${BLUEBUILD_MODULE_CONFIG:-}" ]; then
|
|
log "ERROR: BLUEBUILD_MODULE_CONFIG environment variable is not set"
|
|
exit 1
|
|
fi
|
|
|
|
# Parse the module configuration
|
|
log "Parsing module configuration..."
|
|
CONFIG_FILE=$(echo "$BLUEBUILD_MODULE_CONFIG" | jq -r '.config_file // empty')
|
|
if [ -n "$CONFIG_FILE" ]; then
|
|
log "Using config file: $CONFIG_FILE"
|
|
MODULE_CONFIG=$(cat "$CONFIG_FILE")
|
|
else
|
|
log "Using inline module configuration"
|
|
MODULE_CONFIG="$BLUEBUILD_MODULE_CONFIG"
|
|
fi
|
|
|
|
# Extract module type and validate
|
|
MODULE_TYPE=$(echo "$MODULE_CONFIG" | jq -r '.type // empty')
|
|
if [ "$MODULE_TYPE" != "apt" ]; then
|
|
log "ERROR: Invalid module type: $MODULE_TYPE (expected: apt)"
|
|
exit 1
|
|
fi
|
|
|
|
log "Starting apt module execution..."
|
|
|
|
# Execute the apt wrapper with the configuration
|
|
exec /usr/local/bin/apt-wrapper.sh "$MODULE_CONFIG"
|