Files
railiance-cluster/tools/furnish_railiance_repo.sh
tegwick 1eb8559f27
Some checks failed
railiance-tests / smoke (push) Has been cancelled
tools and workplans
2026-05-15 23:03:28 +02:00

200 lines
4.6 KiB
Bash

#!/usr/bin/env bash
# tools/furnish_railiance_repo.sh
# Idempotently "furnishes" the repo with license, readmes, and housekeeping files.
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
ensure_file() { # ensure_file <path> <here-doc label> [mode]
local path="$1"; shift
local label="$1"; shift
local mode="${1:-}"
if [[ -f "${path}" ]]; then
echo "[=] exists: ${path}"
else
echo "[+] create: ${path}"
mkdir -p "$(dirname "${path}")"
eval "cat <<'${label}' > '${path}'"
if [[ -n "${mode}" ]]; then chmod "${mode}" "${path}"; fi
fi
}
append_once() { # append_once <path> <needle> <text>
local path="$1" needle="$2" text="$3"
grep -qF "${needle}" "${path}" 2>/dev/null || { echo "${text}" >> "${path}"; echo "[+] append → ${path}"; }
}
# LICENSE (MIT)
ensure_file "${repo_root}/LICENSE" LIC <<'LIC'
MIT License
Copyright (c) 2025 Railiance Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
LIC
# Root README with badge (only if missing)
ensure_file "${repo_root}/README.md" RREAD <<'RREAD'
# Railiance Bootstrap
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
Railiance is an opinionated **Infrastructure-as-Code framework** —
think *Rails for Ops*: convention over configuration, reproducibility first.
This repo (`railiance-cluster`) is the **cluster runtime entry point**:
from two bare Linux servers, a Git repo, and credentials, you can rebuild
a fully automated Kubernetes-based environment.
RREAD
# docs/README
ensure_file "${repo_root}/docs/README.md" DREAD <<'DREAD'
# Railiance Documentation
Welcome to **Railiance** — an opinionated framework for Infrastructure-as-Code.
Think of it as *Rails for Ops*: convention over configuration, productivity first.
DREAD
# CONTRIBUTING
ensure_file "${repo_root}/docs/CONTRIBUTING.md" CONTRIB <<'CONTRIB'
# Contributing to Railiance
(…short rules: no secrets, LF endings, PRs w/ tests…)
CONTRIB
# .editorconfig
ensure_file "${repo_root}/.editorconfig" ECONF <<'ECONF'
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_style = space
indent_size = 2
[*.sh]
indent_style = space
indent_size = 2
[*.py]
indent_style = space
indent_size = 4
ECONF
# .gitattributes
ensure_file "${repo_root}/.gitattributes" GATTR <<'GATTR'
* text=auto eol=lf
*.sh text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.md text eol=lf
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.svg binary
*.ico binary
*.pdf binary
*.zip binary
*.tar.gz binary
*.tgz binary
.gitattributes text eol=lf
.editorconfig text eol=lf
GATTR
# .gitignore
ensure_file "${repo_root}/.gitignore" GIGN <<'GIGN'
.DS_Store
Thumbs.db
*.swp
*.swo
*.bak
*.tmp
*~
__pycache__/
*.pyc
*.pyo
*.pyd
*.egg-info/
.eggs/
.venv/
venv/
env/
node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log
.pnpm-debug.log
*.retry
inventory/
hosts
.secrets/
.vault_pass.txt
charts/*.tgz
.helm/
kustomize-build/
.kube/
*.kubeconfig
.terraform/
terraform.tfstate
terraform.tfstate.backup
*.tfvars
logs/
*.log
.coverage
coverage.xml
htmlcov/
.junit/
*.out
*.err
.gitattributes.lock
.editorconfig.lock
.railiance_gitea.conf
.vscode/
.idea/
*.iml
GIGN
# tools/README
ensure_file "${repo_root}/tools/README.md" TREAD <<'TREAD'
# Railiance Tools
- `create_railiance_repo.sh` — create a Gitea repo (user/org).
- `furnish_railiance_repo.sh` — idempotently add license/housekeeping to this repo.
- `build_spore.sh` — produce a portable seed bundle (see panspermia model).
- `seed_node.sh` — run on a blank host to kick off biogenesis.
TREAD
echo "[✓] Furnishing complete."