Add wild-init script.

This commit is contained in:
2025-06-07 12:08:11 -07:00
parent 2b61491b0a
commit 6bc0b07003
9 changed files with 127 additions and 39 deletions

View File

@@ -1,36 +0,0 @@
# Basic configuration
DOMAIN=example.com
EMAIL=your.email@example.com
USE_HOSTNAME=your-hostname
KUBECONFIG=/etc/rancher/k3s/k3s.yaml
ENVIRONMENT=prod
# Dynamic DNS configuration for external access
DYNAMIC_DNS=your-dynamic-dns.example.com
# Dashboard access
ADMIN_USERNAME=admin
# PostgreSQL configuration
POSTGRES_NAMESPACE=postgres
POSTGRES_RELEASE_NAME=postgresql
POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your-secure-password
POSTGRES_STORAGE=10Gi
# MariaDB configuration
MARIADB_NAMESPACE=mariadb
MARIADB_RELEASE_NAME=mariadb
MARIADB_ROOT_PASSWORD=your-root-password
MARIADB_USER=app
MARIADB_PASSWORD=your-secure-password
MARIADB_DATABASE=app_database
MARIADB_STORAGE=8Gi
MARIADB_TAG=11.4.5
# Cert Manager configuration
CERT_MANAGER_NAMESPACE=cert-manager
CERT_MANAGER_RELEASE_NAME=cert-manager
CERT_ISSUERS_RELEASE_NAME=cert-issuers
CLOUDFLARE_API_TOKEN=your-cloudflare-api-token-here # Required for wildcard certificates

118
bin/wild-init Executable file
View File

@@ -0,0 +1,118 @@
#!/bin/bash
set -e
set -o pipefail
# Source environment variables
source "${BASH_SOURCE%/*}/../load-env.sh" 2>/dev/null || true
UPDATE=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--update)
UPDATE=true
shift
;;
-h|--help)
echo "Usage: $0 [--update]"
echo ""
echo "Initialize a new Wild-Cloud project by copying scaffold files."
echo ""
echo "Options:"
echo " --update Update existing files with scaffold files (overwrite)"
echo " -h, --help Show this help message"
echo ""
echo "By default, this script will only run in an empty directory."
echo "Use --update to overwrite existing scaffold files while preserving other files."
exit 0
;;
-*)
echo "Unknown option $1"
echo "Usage: $0 [--update]"
exit 1
;;
*)
echo "Unexpected argument: $1"
echo "Usage: $0 [--update]"
exit 1
;;
esac
done
# Get the path to the Wild-Cloud repository (where this script is located)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WILDCLOUD_REPO="$(dirname "${SCRIPT_DIR}")"
SCAFFOLD_DIR="${WILDCLOUD_REPO}/my-scaffold"
if [ ! -d "${SCAFFOLD_DIR}" ]; then
echo "Error: Scaffold directory not found at ${SCAFFOLD_DIR}"
exit 1
fi
# Check if current directory is empty (unless --update is used)
if [ "${UPDATE}" = false ]; then
# Check if directory has any files (including hidden files, excluding . and ..)
if [ -n "$(find . -maxdepth 1 -name ".*" -o -name "*" | grep -v "^\.$" | head -1)" ]; then
echo "Error: Current directory is not empty"
echo "Use --update flag to overwrite existing scaffold files while preserving other files"
exit 1
fi
fi
echo "Initializing Wild-Cloud project in $(pwd)"
if [ "${UPDATE}" = true ]; then
echo "Updating scaffold files (preserving existing non-scaffold files)"
else
echo "Copying scaffold files to empty directory"
fi
# Function to copy files and directories
copy_scaffold() {
local src_dir="$1"
local dest_dir="$2"
# Create destination directory if it doesn't exist
mkdir -p "${dest_dir}"
# Copy directory structure
find "${src_dir}" -type d | while read -r src_subdir; do
rel_path="${src_subdir#${src_dir}}"
rel_path="${rel_path#/}" # Remove leading slash if present
if [ -n "${rel_path}" ]; then
mkdir -p "${dest_dir}/${rel_path}"
fi
done
# Copy files
find "${src_dir}" -type f | while read -r src_file; do
rel_path="${src_file#${src_dir}}"
rel_path="${rel_path#/}" # Remove leading slash if present
dest_file="${dest_dir}/${rel_path}"
# Ensure destination directory exists
dest_file_dir=$(dirname "${dest_file}")
mkdir -p "${dest_file_dir}"
if [ "${UPDATE}" = true ] && [ -f "${dest_file}" ]; then
echo "Updating: ${rel_path}"
else
echo "Creating: ${rel_path}"
fi
cp "${src_file}" "${dest_file}"
done
}
# Copy scaffold files to current directory
copy_scaffold "${SCAFFOLD_DIR}" "."
echo ""
echo "Wild-Cloud project initialized successfully!"
echo ""
echo "Next steps:"
echo "1. Review and customize the configuration files"
echo "2. Set up your .wildcloud/config.yaml with your Wild-Cloud repository path"
echo "3. Start using wild-app-* commands to manage your applications"

2
my-scaffold/.env.example Normal file
View File

@@ -0,0 +1,2 @@
KUBECONFIG=~/.kube/config
export KUBECONFIG

View File

@@ -22,13 +22,14 @@ cloud:
cluster:
endpoint: computer-01
endpointIp: 192.168.8.241
kubeConfig: /home/adam/.kube/config
kubernetes:
config: /home/adam/.kube/config
context: default
loadBalancerRange: 192.168.8.240-192.168.8.250
dashboard:
adminUsername: admin
certManager:
namespace: cert-manager
cloudflare:
apiToken: <cloudflare api token>
domain: adam.tld
ownerId: cloud-adam-cluster

View File

@@ -0,0 +1,4 @@
cluster:
certManager:
cloudflare:
apiToken: <cloudflare api token>

View File

@@ -1 +0,0 @@
cloudflareApiToken: <your-cloudflare-api-token>