259 lines
16 KiB
Bash
Executable file
259 lines
16 KiB
Bash
Executable file
#!/bin/bash
|
||
set -euo pipefail
|
||
IFS=$'\n\t'
|
||
|
||
# ╭─────────────────────────────────────╮
|
||
# │ CONFIGURATION │
|
||
# ╰─────────────────────────────────────╮
|
||
REPO_PATH=$(git rev-parse --show-toplevel 2>/dev/null) || error "Not inside a Git repository"
|
||
REPO_NAME=$(basename "$REPO_PATH")
|
||
GITFIELD_DIR="$REPO_PATH/.gitfield"
|
||
LOG_FILE="$GITFIELD_DIR/pushed.log"
|
||
GITFIELD_MD="$REPO_PATH/GITFIELD.md"
|
||
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
|
||
SCRIPT_VERSION="1.0"
|
||
|
||
# URLs for each platform
|
||
GITHUB_URL="https://github.com/mrhavens/$REPO_NAME"
|
||
GITLAB_URL="https://gitlab.com/mrhavens/$REPO_NAME"
|
||
BITBUCKET_URL="https://bitbucket.org/thefoldwithin/$REPO_NAME"
|
||
FORGEJO_URL="https://remember.thefoldwithin.earth/mrhavens/$REPO_NAME"
|
||
CODEBERG_URL="https://codeberg.org/mrhavens/$REPO_NAME"
|
||
GITEA_URL="https://gitea.com/mrhavens/$REPO_NAME"
|
||
RADICLE_RID="rad:z3FEj7rF8gZw9eFksCuiN43qjzrex"
|
||
RADICLE_PEER_ID="z6Mkw5s3ppo26C7y7tGK5MD8n2GqTHS582PPpeX5Xqbu2Mpz"
|
||
|
||
# ╭─────────────────────────────────────╮
|
||
# │ LOGGING UTILS │
|
||
# ╰─────────────────────────────────────╮
|
||
info() { echo -e "\e[1;34m[INFO]\e[0m $*" >&2; }
|
||
warn() { echo -e "\e[1;33m[WARN]\e[0m $*" >&2; }
|
||
error() { echo -e "\e[1;31m[ERROR]\e[0m $*" >&2; exit 1; }
|
||
|
||
# ╭─────────────────────────────────────╮
|
||
# │ SCRIPT LOOKUP FUNCTION │
|
||
# ╰─────────────────────────────────────╮
|
||
find_script() {
|
||
local script_name=$1
|
||
local search_paths=(
|
||
"$HOME/.local/gitfieldbin"
|
||
"$HOME/.local/bin"
|
||
"$HOME/.local/gitfield"
|
||
"$HOME/.local/bin/gitfield"
|
||
"$HOME/.local/bin/gitfieldbin"
|
||
"$REPO_PATH/bin"
|
||
)
|
||
|
||
for path in "${search_paths[@]}"; do
|
||
if [ -f "$path/$script_name" ]; then
|
||
if [ -x "$path/$script_name" ]; then
|
||
if [[ "$path" != "$HOME"* && "$path" != "$REPO_PATH"* ]]; then
|
||
info "Using script: \e[1;31m$path/$script_name\e[0m (outside home or repo)"
|
||
else
|
||
info "Using script: $path/$script_name"
|
||
fi
|
||
echo "$path/$script_name"
|
||
return 0
|
||
else
|
||
warn "Found $path/$script_name but it is not executable"
|
||
fi
|
||
fi
|
||
done
|
||
error "Script $script_name not found in any search path"
|
||
}
|
||
|
||
# ╭─────────────────────────────────────╮
|
||
# │ INITIAL SETUP │
|
||
# ╰─────────────────────────────────────╮
|
||
mkdir -p "$GITFIELD_DIR"
|
||
|
||
if [ ! -f "$LOG_FILE" ]; then
|
||
echo "# Push Log for $REPO_NAME" > "$LOG_FILE"
|
||
echo "# Generated by gitfield-sync" >> "$LOG_FILE"
|
||
echo "" >> "$LOG_FILE"
|
||
fi
|
||
|
||
# ╭─────────────────────────────────────╮
|
||
# │ GENERATE GITFIELD.MD │
|
||
# ╰─────────────────────────────────────╮
|
||
generate_gitfield_md() {
|
||
info "Generating $GITFIELD_MD..."
|
||
cat > "$GITFIELD_MD" <<EOF
|
||
# 🌐 GitField Recursive Multi-Repository Strategy
|
||
|
||
## Overview
|
||
|
||
The \`$REPO_NAME\` project employs a multi-repository strategy across seven distinct platforms: **GitHub**, **GitLab**, **Bitbucket**, **Radicle**, **Forgejo**, **Codeberg**, and **Gitea**. This approach ensures **redundancy**, **resilience**, and **sovereignty** of the project's data and metadata, protecting against deplatforming risks and preserving the integrity of the work. The strategy is a deliberate response to past deplatforming and delisting attempts by individuals such as **Mr. Joel Johnson** ([Mirror post](https://mirror.xyz/neutralizingnarcissism.eth/x40_zDWWrYOJ7nh8Y0fk06_3kNEP0KteSSRjPmXkiGg?utm_medium=social&utm_source=heylink.me)), **Dr. Peter Gaied** ([Paragraph post](https://paragraph.com/@neutralizingnarcissism/%F0%9F%9C%81-the-narcissistic-messiah)), and **Andrew LeCody** ([Mirror post](https://mirror.xyz/neutralizingnarcissism.eth/s3GRxuiZs6vGSGDcPEpCgjaSxwGAViGhmg6a5XTL6s0)), who have sought to undermine or suppress the work of **Mark Randall Havens** ([Substack post](https://theempathictechnologist.substack.com/p/mark-randall-havens-the-architect)). Specifically, Andrew LeCody has attempted to delist the project's content on Google, though it remains accessible on other search engines such as [Bing](https://www.bing.com/search?q=andrew+lecody+neutralizing+narcissism&qs=HS&pq=andrew+lecody), [DuckDuckGo](https://duckduckgo.com/?t=h_&q=andrew+lecody+neutralizing+narcissism&ia=web), and [Yahoo](https://search.yahoo.com/search?p=andrew+lecody+neutralizng+narcissism). By distributing the repository across multiple platforms, including a self-hosted Forgejo instance, we ensure its persistence, accessibility, and sovereignty.
|
||
|
||
---
|
||
|
||
## 📍 Repository Platforms
|
||
|
||
The following platforms host the \`$REPO_NAME\` repository, each chosen for its unique strengths and contributions to the project's goals.
|
||
|
||
### 1. Radicle
|
||
- **RID**: $RADICLE_RID
|
||
- **Peer ID**: $RADICLE_PEER_ID
|
||
- **Purpose**: Radicle is a decentralized, peer-to-peer git platform that ensures sovereignty and censorship resistance. It hosts the repository in a distributed network, independent of centralized servers.
|
||
- **Value**: Protects against deplatforming by eliminating reliance on centralized infrastructure, ensuring the project remains accessible in a decentralized ecosystem.
|
||
- **Access Details**: To view project details, run:
|
||
\`\`\`bash
|
||
rad inspect $RADICLE_RID
|
||
\`\`\`
|
||
To view the file structure, run:
|
||
\`\`\`bash
|
||
rad ls $RADICLE_RID
|
||
\`\`\`
|
||
Alternatively, use Git to list files at the current HEAD:
|
||
\`\`\`bash
|
||
git ls-tree -r --name-only HEAD
|
||
\`\`\`
|
||
|
||
### 2. Forgejo
|
||
- **URL**: [$FORGEJO_URL]($FORGEJO_URL)
|
||
- **Purpose**: Forgejo is a self-hosted, open-source git platform running on \`remember.thefoldwithin.earth\`. It provides full control over the repository, ensuring sovereignty and independence from third-party providers.
|
||
- **Value**: Enhances resilience by hosting the repository on a sovereign, redundant system with automated backups and deployment strategies, reducing risks of external interference or service disruptions.
|
||
- **Access Details**: SSH access uses port 222:
|
||
\`\`\`bash
|
||
ssh -T -p 222 git@remember.thefoldwithin.earth
|
||
\`\`\`
|
||
|
||
### 3. Codeberg
|
||
- **URL**: [$CODEBERG_URL]($CODEBERG_URL)
|
||
- **Purpose**: Codeberg is a community-driven, open-source platform powered by Forgejo, offering a reliable and ethical alternative for hosting git repositories.
|
||
- **Value**: Enhances project resilience with its open-source ethos and independent infrastructure, ensuring accessibility and community support.
|
||
|
||
### 4. Gitea
|
||
- **URL**: [$GITEA_URL]($GITEA_URL)
|
||
- **Purpose**: Gitea.com provides a lightweight, open-source git hosting platform with robust features for repository management and collaboration.
|
||
- **Value**: Offers an additional layer of redundancy and a user-friendly interface, complementing other platforms with its simplicity and efficiency.
|
||
|
||
### 5. GitLab
|
||
- **URL**: [$GITLAB_URL]($GITLAB_URL)
|
||
- **Purpose**: GitLab offers a comprehensive DevOps platform with advanced CI/CD capabilities, private repository options, and robust access controls. It serves as a reliable backup and a platform for advanced automation workflows.
|
||
- **Value**: Enhances project resilience with its integrated CI/CD pipelines and independent infrastructure, reducing reliance on a single provider.
|
||
|
||
### 6. Bitbucket
|
||
- **URL**: [$BITBUCKET_URL]($BITBUCKET_URL)
|
||
- **Purpose**: Bitbucket provides a secure environment for repository hosting with strong integration into Atlassian’s ecosystem (e.g., Jira, Trello). It serves as an additional layer of redundancy and a professional-grade hosting option.
|
||
- **Value**: Offers enterprise-grade security and integration capabilities, ensuring the project remains accessible even if other platforms face disruptions.
|
||
|
||
### 7. GitHub
|
||
- **URL**: [$GITHUB_URL]($GITHUB_URL)
|
||
- **Purpose**: GitHub serves as the primary platform for visibility, collaboration, and community engagement. Its widespread adoption and robust tooling make it ideal for public-facing development, issue tracking, and integration with CI/CD pipelines.
|
||
- **Value**: Provides a centralized hub for open-source contributions, pull requests, and project management, ensuring broad accessibility and developer familiarity.
|
||
|
||
---
|
||
|
||
## 🛡️ Rationale for Redundancy
|
||
|
||
The decision to maintain multiple repositories stems from the need to safeguard the project against **deplatforming attempts** and **search engine delistings** and ensure its **long-term availability**. Past incidents involving **Mr. Joel Johnson**, **Dr. Peter Gaied**, and **Andrew LeCody** have highlighted the vulnerability of relying on a single platform or search engine. By distributing the repository across GitHub, GitLab, Bitbucket, Radicle, Forgejo, Codeberg, and Gitea, we achieve:
|
||
|
||
- **Resilience**: If one platform removes or restricts access, or if search engines like Google delist content, the project remains accessible on other platforms and discoverable via alternative search engines such as Bing, DuckDuckGo, and Yahoo.
|
||
- **Sovereignty**: Radicle’s decentralized nature and Forgejo’s self-hosted infrastructure ensure the project cannot be fully censored or controlled by any single entity.
|
||
- **Diversity**: Each platform’s unique features (e.g., GitHub’s community, GitLab’s CI/CD, Bitbucket’s integrations, Radicle’s decentralization, Forgejo’s self-hosting, Codeberg’s community-driven model, Gitea’s lightweight efficiency) enhance the project’s functionality and reach.
|
||
- **Transparency**: Metadata snapshots in the \`.gitfield\` directory provide a verifiable record of the project’s state across all platforms.
|
||
|
||
This multi-repository approach, bolstered by Forgejo’s sovereign hosting, reflects a commitment to preserving the integrity, accessibility, and independence of \`$REPO_NAME\`, ensuring it remains available to contributors and users regardless of external pressures.
|
||
|
||
---
|
||
|
||
## 📜 Metadata and Logs
|
||
|
||
- **Metadata Files**: Each platform generates a metadata snapshot in the \`.gitfield\` directory (e.g., \`github.sigil.md\`, \`gitlab.sigil.md\`, \`remember.sigil.md\`, \`codeberg.sigil.md\`, \`gitea.sigil.md\`, etc.), capturing commit details, environment information, and hardware fingerprints.
|
||
- **Push Log**: The \`.gitfield/pushed.log\` file records the date, time, and RID/URL of every push operation across all platforms, providing a transparent audit trail.
|
||
- **Recursive Sync**: The repository is synchronized across all platforms in a recursive loop (three cycles) to ensure interconnected metadata captures the latest state of the project.
|
||
- **Push Order**: The repository is synchronized in the following order: **Radicle → Forgejo → Codeberg → Gitea → GitLab → Bitbucket → GitHub**. This prioritizes Radicle’s decentralized, censorship-resistant network as the primary anchor, followed by Forgejo’s sovereign, self-hosted infrastructure, Codeberg’s community-driven platform, Gitea’s lightweight efficiency, GitLab’s robust DevOps features, Bitbucket’s enterprise redundancy, and GitHub’s broad visibility, ensuring a resilient and accessible metadata chain.
|
||
|
||
---
|
||
|
||
_Auto-generated by \`gitfield-sync\` at $TIMESTAMP (v$SCRIPT_VERSION)._
|
||
EOF
|
||
|
||
git -C "$REPO_PATH" add "$GITFIELD_MD"
|
||
git -C "$REPO_PATH" commit -m "Generated GITFIELD.md at $TIMESTAMP" || warn "No changes to commit for $GITFIELD_MD"
|
||
info "Generated and committed $GITFIELD_MD"
|
||
}
|
||
|
||
# ╭─────────────────────────────────────╮
|
||
# │ LOG URL FUNCTION │
|
||
# ╰─────────────────────────────────────╮
|
||
log_url() {
|
||
local platform=$1
|
||
local url=$2
|
||
local rid=$3
|
||
local peer_id=$4
|
||
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||
if [ "$platform" = "Radicle" ]; then
|
||
echo "[$timestamp] $platform: RID=$rid, Peer ID=$peer_id" >> "$LOG_FILE"
|
||
echo " CLI: rad inspect $rid # View project details" >> "$LOG_FILE"
|
||
echo " CLI: git ls-tree -r --name-only HEAD # View file structure" >> "$LOG_FILE"
|
||
info "Logged push to $LOG_FILE: [$timestamp] $platform: RID=$rid, Peer ID=$peer_id"
|
||
else
|
||
echo "[$timestamp] $platform: $url" >> "$LOG_FILE"
|
||
info "Logged push to $LOG_FILE: [$timestamp] $platform: $url"
|
||
fi
|
||
}
|
||
|
||
# ╭─────────────────────────────────────╮
|
||
# │ EXECUTE PUSH SCRIPT │
|
||
# ╰─────────────────────────────────────╮
|
||
execute_push() {
|
||
local script_name=$1
|
||
local platform=$2
|
||
local url=$3
|
||
local rid=$4
|
||
local peer_id=$5
|
||
local script_path
|
||
script_path=$(find_script "$script_name") || error "Failed to find $script_name"
|
||
info "Executing $platform push with script: $script_path"
|
||
if [ -x "$script_path" ]; then
|
||
pushd "$REPO_PATH" >/dev/null
|
||
"$script_path" || warn "Execution of $script_path failed, continuing..."
|
||
log_url "$platform" "$url" "$rid" "$peer_id"
|
||
git add . || warn "Nothing to add after $script_path"
|
||
git commit -m "Post-$platform sync at $TIMESTAMP" || warn "No changes to commit after $script_path"
|
||
popd >/dev/null
|
||
else
|
||
error "Script $script_path is not executable"
|
||
fi
|
||
}
|
||
|
||
# ╭─────────────────────────────────────╮
|
||
# │ RECURSIVE PUSH LOOP │
|
||
# ╰─────────────────────────────────────╮
|
||
run_push_cycle() {
|
||
local cycle_number=$1
|
||
info "Starting push cycle $cycle_number..."
|
||
|
||
execute_push "gitfield-local" "Local" "" "" ""
|
||
execute_push "gitfield-radicle" "Radicle" "" "$RADICLE_RID" "$RADICLE_PEER_ID"
|
||
execute_push "gitfield-remember" "Forgejo" "$FORGEJO_URL" "" ""
|
||
execute_push "gitfield-codeberg" "Codeberg" "$CODEBERG_URL" "" ""
|
||
execute_push "gitfield-gitea" "Gitea" "$GITEA_URL" "" ""
|
||
execute_push "gitfield-gitlab" "GitLab" "$GITLAB_URL" "" ""
|
||
execute_push "gitfield-bitbucket" "Bitbucket" "$BITBUCKET_URL" "" ""
|
||
execute_push "gitfield-github" "GitHub" "$GITHUB_URL" "" ""
|
||
}
|
||
|
||
# ╭─────────────────────────────────────╮
|
||
# │ MAIN EXECUTION │
|
||
# ╰─────────────────────────────────────╮
|
||
info "Starting gitfield-sync for $REPO_NAME..."
|
||
|
||
if [ ! -d "$REPO_PATH/.git" ]; then
|
||
pushd "$REPO_PATH" >/dev/null
|
||
git init
|
||
git add .
|
||
git commit -m "Initial commit" || warn "Nothing to commit"
|
||
popd >/dev/null
|
||
fi
|
||
|
||
run_push_cycle 1
|
||
generate_gitfield_md
|
||
run_push_cycle 2
|
||
run_push_cycle 3
|
||
|
||
info "✅ gitfield-sync completed successfully."
|
||
info "🔗 View logs: $LOG_FILE"
|
||
info "🔗 View multi-repo manifest: $GITFIELD_MD"
|