Skip to content

Add nebula sync container - #1424

Closed
gabriel403 wants to merge 9 commits into
community-scripts:mainfrom
gabriel403:add-nebula-sync-container
Closed

Add nebula sync container#1424
gabriel403 wants to merge 9 commits into
community-scripts:mainfrom
gabriel403:add-nebula-sync-container

Conversation

@gabriel403

@gabriel403 gabriel403 commented Feb 6, 2026

Copy link
Copy Markdown

✍️ Description

Adds a new LXC container script for Nebula-Sync (lovelaze/nebula-sync), which synchronizes configuration across multiple Pi-hole v6.x instances (primary → replica).

Included:

  • Host script (ct/nebula-sync.sh): Creates unprivileged Debian 13 LXC (1 CPU, 512 MB RAM, 2 GB disk), tags dns;sync, supports update flow.
  • Install script (install/nebula-sync-install.sh): Downloads latest release binary, prompts for primary and replica Pi-hole URL/IP and API password, sync mode (all or custom selection), and cron interval. Writes /opt/nebula-sync/.env in url|password format (handles special characters), creates wrapper + systemd service, and installs update_nebula-sync.
  • Frontend (frontend/public/json/nebula-sync.json): App metadata, description, and notes for the script’s web page.
  • Header (ct/headers/nebula-sync): ASCII banner for the app.

User-facing notes (in JSON and for docs): Pi-hole must be v6.x with API access; API password is the web interface password; app_sudo = true must be set in /etc/pihole/pihole.toml under [webserver.api] on all Pi-hole instances for sync to work.

🔗 Related Issue

Fixes #

✅ Prerequisites (X in brackets)

  • Self-review completed – Code follows project standards.
  • Tested thoroughly – Changes work as expected.
  • No security risks – No hardcoded secrets, unnecessary privilege escalations, or permission issues.

🛠️ Type of Change (X in brackets)

  • 🐞 Bug fix – Resolves an issue without breaking functionality.
  • New feature – Adds new, non-breaking functionality.
  • 💥 Breaking change – Alters existing functionality in a way that may require updates.
  • 🆕 New script – A fully functional and tested script or script set.
  • 🌍 Website update – Changes to website-related JSON files or metadata.
  • 🔧 Refactoring / Code Cleanup – Improves readability or maintainability without changing functionality.
  • 📝 Documentation update – Changes to README, AppName.md, CONTRIBUTING.md, or other docs.

- Host script (ct/nebula-sync.sh) and install script for nebula-sync
- Prompts for primary/replica Pi-hole URL and API password, sync options, cron
- .env with PRIMARY/REPLICAS in url|password format, wrapper and systemd service
- Frontend JSON and header; notes on Pi-hole API and app_sudo requirement
Remove || true error suppression and properly check file/service state before operations
- Remove inline comments from wrapper script heredoc
- Fix env verification to parse lines instead of unsafe shell-loading
- Add standard access URL format to completion block
@greptile-apps

greptile-apps Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

  • Adds a new Nebula-Sync LXC container builder (ct/nebula-sync.sh) with an update path based on update_nebula-sync and a saved version file.
  • Introduces an install script (install/nebula-sync-install.sh) that deploys the upstream release, prompts for Pi-hole endpoints/passwords, writes /opt/nebula-sync/.env, and sets up a systemd service + update helper.
  • Adds frontend metadata (frontend/public/json/nebula-sync.json) and an ASCII header (ct/headers/nebula-sync) to integrate the new app into the project’s UI/catalog.
  • Main required fixes are in install/update robustness (directory creation, wrapper checks, version file guarding) and CT update precheck logic.

Confidence Score: 3/5

  • Moderately safe to merge, but a few install/update edge cases can cause broken installs or noisy update behavior.
  • Core functionality is straightforward and follows existing patterns, but there are still a couple of definite failure modes (missing install dir before writing .env, wrapper not checking binary, version file written even when tag fetch fails) plus one update precheck that can allow a broken update path.
  • install/nebula-sync-install.sh and ct/nebula-sync.sh

Important Files Changed

Filename Overview
ct/headers/nebula-sync Adds ASCII header banner for Nebula-Sync; no functional code.
ct/nebula-sync.sh Adds new CT builder with update flow; update precheck logic should require update script presence to avoid later failures.
frontend/public/json/nebula-sync.json Adds Nebula-Sync frontend metadata JSON with required fields and Debian resources.
install/nebula-sync-install.sh Installs Nebula-Sync and config/service/update scripts; needs install dir creation, wrapper robustness, and version file guarding.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 7 comments

Edit Code Review Agent Settings | Greptile

Comment thread ct/nebula-sync.sh
Comment thread ct/nebula-sync.sh
Comment thread frontend/public/json/nebula-sync.json
Comment thread install/nebula-sync-install.sh
Comment thread install/nebula-sync-install.sh
Comment thread install/nebula-sync-install.sh
Comment thread install/nebula-sync-install.sh

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread ct/nebula-sync.sh

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread install/nebula-sync-install.sh Outdated
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread install/nebula-sync-install.sh
@gabriel403

Copy link
Copy Markdown
Author

@greptileai

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +16 to +21
INSTALL_PATH="/opt/nebula-sync"
ENV_PATH="/opt/nebula-sync/.env"
SERVICE_PATH="/etc/systemd/system/nebula-sync.service"

msg_info "Installing Nebula-Sync"
fetch_and_deploy_gh_release "nebula-sync" "lovelaze/nebula-sync" "prebuild" "latest" "/opt/nebula-sync" "nebula-sync_.*_linux_.*\.tar\.gz"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing install dir

This script writes "$ENV_PATH" (/opt/nebula-sync/.env) but never creates ${INSTALL_PATH} first. If fetch_and_deploy_gh_release doesn’t create the directory on failure (or if it extracts elsewhere), the redirect > "$ENV_PATH" will fail and abort the install.

Suggested change
INSTALL_PATH="/opt/nebula-sync"
ENV_PATH="/opt/nebula-sync/.env"
SERVICE_PATH="/etc/systemd/system/nebula-sync.service"
msg_info "Installing Nebula-Sync"
fetch_and_deploy_gh_release "nebula-sync" "lovelaze/nebula-sync" "prebuild" "latest" "/opt/nebula-sync" "nebula-sync_.*_linux_.*\.tar\.gz"
INSTALL_PATH="/opt/nebula-sync"
ENV_PATH="/opt/nebula-sync/.env"
SERVICE_PATH="/etc/systemd/system/nebula-sync.service"
mkdir -p "$INSTALL_PATH"

Comment on lines +156 to +158
if [[ "$FULL_SYNC" == "false" ]]; then
cat <<EOF>>"$ENV_PATH"
SYNC_CONFIG_DNS=${SYNC_CONFIG_DNS}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heredoc redirection style

Repo style rule requires heredoc delimiter to come before the redirection (i.e., cat <<EOF>>file). This currently uses cat <<EOF>>"$ENV_PATH".

Suggested change
if [[ "$FULL_SYNC" == "false" ]]; then
cat <<EOF>>"$ENV_PATH"
SYNC_CONFIG_DNS=${SYNC_CONFIG_DNS}
cat <<EOF >>"$ENV_PATH"

Context Used: Rule from dashboard - What: Heredoc syntax must come before the output redirection in cat commands.

Why: Placing the here... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread install/nebula-sync-install.sh Outdated
Comment on lines +196 to +200
[[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue
if [[ "$line" =~ ^[A-Z_][A-Z0-9_]*= ]]; then
key="${line%%=*}"
value="${line#*=}"
export "${key}=${value}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapper ignores # lines

The wrapper skips lines matching ^[[:space:]]*#, but the repo rule forbids comments in install/ct scripts; since .env is generated without comments, this is dead code and adds unnecessary complexity. If you keep it, it can also break if a value legitimately starts with #.

Suggested change
[[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue
if [[ "$line" =~ ^[A-Z_][A-Z0-9_]*= ]]; then
key="${line%%=*}"
value="${line#*=}"
export "${key}=${value}"
[[ -z "$line" ]] && continue

Context Used: Rule from dashboard - What: Shell script files in ct/ and /install directories must not contain comments except for file h... (source)

Comment on lines +205 to +206
exec "$BINARY" run
EOFWRAPPER

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No binary existence check

The wrapper unconditionally execs /opt/nebula-sync/nebula-sync. If the release deploy fails or changes asset layout, the service will crash-loop with a less actionable error. Add an explicit check so install/update failures surface clearly.

Suggested change
exec "$BINARY" run
EOFWRAPPER
if [[ ! -x "$BINARY" ]]; then
echo "Nebula-Sync binary not found/executable at $BINARY" >&2
exit 1
fi
exec "$BINARY" run

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread install/nebula-sync-install.sh Outdated
chmod +x /usr/local/bin/update_nebula-sync
msg_ok "Created update script"

echo "$LATEST_RELEASE" > "/opt/nebula-sync_version.txt"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty version on API failure

LATEST_RELEASE is written to /opt/nebula-sync_version.txt without validating it’s non-empty. If the GitHub API call fails or rate-limits, this writes an empty version file and the CT update flow will think an update is always needed. Guard the write.

Suggested change
echo "$LATEST_RELEASE" > "/opt/nebula-sync_version.txt"
if [[ -n "$LATEST_RELEASE" ]]; then
echo "$LATEST_RELEASE" > "/opt/nebula-sync_version.txt"
fi

Comment thread ct/nebula-sync.sh Outdated
Comment on lines +26 to +29
if [[ ! -f /usr/local/bin/update_nebula-sync ]] && [[ ! -f /opt/nebula-sync_version.txt ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update check condition

This if requires both the update script and version file to be missing to error. If either one exists but is stale/broken, the script proceeds and then may fail later. If the intent is “must have update script present for update flow”, check that directly.

Suggested change
if [[ ! -f /usr/local/bin/update_nebula-sync ]] && [[ ! -f /opt/nebula-sync_version.txt ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if [[ ! -f /usr/local/bin/update_nebula-sync ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi

@CrazyWolf13

Copy link
Copy Markdown
Member

@gabriel403 is this ready to review?
Or do you want to close this and open a clean PR once it's ready?

@github-actions

Copy link
Copy Markdown
Contributor

@gabriel403 This PR has been marked as stale. It will be closed if no new commits are added in 7 days.

@github-actions github-actions Bot closed this Feb 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@gabriel403 Closing stale PR due to inactivity (no commits for 7 days after stale label).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants