Skip to content

Organize nord files - #7

Merged
terjeinnerdal merged 8 commits into
mainfrom
organize_nord_files
Apr 5, 2026
Merged

Organize nord files#7
terjeinnerdal merged 8 commits into
mainfrom
organize_nord_files

Conversation

@terjeinnerdal

@terjeinnerdal terjeinnerdal commented Apr 2, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a line-counting utility for file analysis.
    • Added NordVPN meshnet configuration and management scripts.
    • Added Raspberry Pi router configuration capability.
  • Documentation

    • Expanded README with a new Bash scripts section.
    • Added NordVPN setup guide documentation including peer network configuration.

@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR introduces NordVPN meshnet configuration restructuring across multiple bash scripts, consolidating peer routing logic, updating nickname handling to accept command-line arguments, and adds documentation and a new line-counting utility script.

Changes

Cohort / File(s) Summary
Documentation & README Updates
README.md, bash/nord/README.me
Added bash scripts section to main README with NordVPN subsection; created new NordVPN setup guide documenting peer identifiers and exit-node configuration.
NordVPN Meshnet Configuration
bash/nord/config.sh, bash/nord/exit_node.sh, bash/nord/mesh.sh
Modified config.sh to accept nickname via command-line argument and updated meshnet auto-connect for specific peers; refactored exit_node.sh to enable meshnet, set nicknames, and configure peer routing allowances instead of exit-node permissions; removed mesh.sh entirely as logic consolidates into other scripts.
New Utility Scripts
bash/countLines.sh, bash/nord/raspberry_router.sh
Added countLines.sh for line-by-line file processing with counter; added raspberry_router.sh to enable peer routing for mesh-dell.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #4: Overlaps with bash/nord script modifications for meshnet and exit-node configuration changes.
  • PR #6: Related to nickname-setting behavior updates in config.sh that now accept command-line parameters.
  • PR #5: Connected to exit_node.sh refactoring and changes to mesh routing permission logic.

Poem

🐰 A meshnet web we weave with care,
Peers connected everywhere!
Exit-nodes routing left and right,
Nicknames passed—a config delight!
Scripts consolidated, clean and bright! 🌐

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Organize nord files' is vague and generic, using non-descriptive language that doesn't convey the specific functional changes being made to the NordVPN configuration and setup. Replace with a more specific title that captures the main functional change, such as 'Refactor NordVPN meshnet configuration with exit-node setup' or 'Update NordVPN peer configuration and mesh routing rules'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch organize_nord_files

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai 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.

Actionable comments posted: 5

🧹 Nitpick comments (4)
bash/nord/nord_watchdog.sh (2)

34-39: IP forwarding change is non-persistent.

The sysctl -w command only sets the value until the next reboot. For persistence, consider adding a note or configuring /etc/sysctl.conf or a file in /etc/sysctl.d/.

📝 Add persistence note or command
 # 5. Ensure IP Forwarding is active in the kernel
 IF_FORWARD=$(cat /proc/sys/net/ipv4/ip_forward)
 if [[ "$IF_FORWARD" -eq 0 ]]; then
     echo "Enabling IP Forwarding..."
     sudo sysctl -w net.ipv4.ip_forward=1
+    # For persistence across reboots, uncomment:
+    # echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/99-ip-forward.conf
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/nord_watchdog.sh` around lines 34 - 39, The current block that
reads IF_FORWARD and runs `sysctl -w net.ipv4.ip_forward=1` only makes a
transient change; update the watchdog to persist the setting by writing the
net.ipv4.ip_forward=1 into system sysctl configuration (e.g., `/etc/sysctl.conf`
or a file under `/etc/sysctl.d/`) and reload sysctl so the kernel picks it up
permanently; modify the section that checks IF_FORWARD (variable IF_FORWARD and
the `sysctl -w` call) to also ensure the persistent configuration contains the
setting and call the appropriate reload/apply step.

15-19: Login check may not reliably detect authentication state.

The nordvpn status command outputs "Status:" even when disconnected but logged in. When not logged in, it typically shows a different message. Consider checking for specific error messages like "You are not logged in" instead.

♻️ Proposed more reliable login check
 # 2. Check if logged in (Exits if not)
-if ! nordvpn status | grep -q "Status:"; then
+if nordvpn account 2>&1 | grep -q "You are not logged in"; then
     echo "Error: NordVPN is not logged in. Please login manually once."
     exit 1
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/nord_watchdog.sh` around lines 15 - 19, The current login check
uses `nordvpn status | grep -q "Status:"` which can be true even when
disconnected; change the check in the if-block that runs `nordvpn status` so it
captures the command output into a variable and tests for the specific "You are
not logged in" (or similar non-authenticated) message instead of just "Status:".
Update the conditional that currently references `nordvpn status | grep -q
"Status:"` to grep or test the captured output for "You are not logged in" (and
keep the same echo and exit 1 behavior) so the script reliably detects an
unauthenticated session.
bash/countLines.sh (1)

1-8: Add input validation to handle missing or invalid arguments.

The script will fail ungracefully if no argument is provided or if the file doesn't exist. Also, the read loop won't process the last line if it lacks a trailing newline.

♻️ Proposed fix with validation and last-line handling
 #! /usr/bin/bash
-FILENAME="$1"
-echo "$FILENAME"
+
+if [[ -z "$1" ]]; then
+    echo "Usage: $0 <filename>" >&2
+    exit 1
+fi
+
+FILENAME="$1"
+
+if [[ ! -f "$FILENAME" ]]; then
+    echo "Error: File '$FILENAME' not found." >&2
+    exit 1
+fi
+
+echo "$FILENAME"
 COUNTER=0
-while IFS= read -r line; do
+while IFS= read -r line || [[ -n "$line" ]]; do
     echo "$COUNTER": "$line"
     ((COUNTER++))
 done < "$FILENAME"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/countLines.sh` around lines 1 - 8, Add argument validation and robust
file reading: check that FILENAME (the "$1" argument) is provided and that the
file exists and is readable, otherwise print a brief usage message and exit with
a non-zero status; then modify the read loop that uses COUNTER and "while IFS=
read -r line; do" so it also processes a final line without a trailing newline
by using the read-or-last-line pattern (e.g., read ... || [ -n "$line" ]),
preserving COUNTER semantics and error handling.
bash/nord/exit_node.sh (1)

11-14: Multiple peer naming conventions across scripts.

This script uses DELL and Pixel, while routing.sh uses DellNord, and mesh.sh sets nickname to mesh-dell. Consider documenting or standardizing peer naming to avoid confusion about which device each name refers to.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/exit_node.sh` around lines 11 - 14, The peer names are inconsistent
across scripts (exit_node.sh uses "DELL"/"Pixel", routing.sh uses "DellNord",
mesh.sh sets "mesh-dell"); standardize or document a single canonical peer
nickname and update all nordvpn meshnet peer routing allow lines to use that
canonical name (or add a clear comment mapping aliases to the canonical name) so
references like DELL, Pixel, DellNord, and mesh-dell are unambiguous across
exit_node.sh, routing.sh, and mesh.sh.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bash/nord/exit_node.sh`:
- Line 3: The script uses the wrong NordVPN CLI subcommand; in exit_node.sh
replace the command invocation that currently says "nordvpn set mesh on" with
the correct "nordvpn set meshnet on" so the Meshnet feature is enabled properly
(look for the exact string "nordvpn set mesh on" in the file and update it to
use "meshnet").

In `@bash/nord/nord_watchdog.sh`:
- Around line 27-32: The script currently uses the nonexistent subcommand
`nordvpn meshnet peer allow-exit-node set "$USER_EMAIL"` to grant exit-node
permission; replace it with the correct command `nordvpn meshnet peer routing
allow <device>` and pass the peer's Nord name, nickname, or Meshnet IP (as
obtained from `nordvpn meshnet peer list`) instead of an email; update the
conditional that checks for "Allowing to use as exit node: yes" to extract the
device identifier (e.g., nickname or IP) from `nordvpn meshnet peer list` and
use that identifier in the `nordvpn meshnet peer routing allow` command so the
permission is applied correctly.

In `@bash/nord/routing.sh`:
- Around line 1-3: The peer name is inconsistent across scripts (DellNord in
routing.sh, mesh-dell in routing.sh.save and mesh.sh, and DELL in exit_node.sh);
pick a single canonical peer identifier (e.g., mesh-dell) and update all
references to that exact string and casing so they match: change the nordvpn
command in routing.sh (nordvpn meshnet peer routing allow DellNord) to use the
chosen name, update mesh.sh and routing.sh.save to the same identifier, and
align any environment variable or constant like DELL in exit_node.sh to the same
canonical name to ensure consistency.

In `@bash/nord/routing.sh.save`:
- Around line 1-4: Remove the editor backup file routing.sh.save from the
repository and stop tracking it; delete the file from Git and add a .save or
editor backup pattern (e.g., *.save or common editor backups) to .gitignore so
similar files are ignored in future. Verify the intended script is preserved
under the correct name (e.g., routing.sh) if that command "nordvpn meshnet peer
routing allow mesh-dell" should exist in a committed script, and ensure only the
canonical script is tracked.

In `@README.md`:
- Around line 9-11: Replace the informal NordVPN section text ("Make me an
exit_node god damn it!") with a concise, professional description of the
scripts’ purpose; update the NordVPN section under the "### NordVPN" heading to
something like "Scripts for configuring NordVPN Meshnet and exit node
functionality" (or similar wording that clearly states what the scripts do).

---

Nitpick comments:
In `@bash/countLines.sh`:
- Around line 1-8: Add argument validation and robust file reading: check that
FILENAME (the "$1" argument) is provided and that the file exists and is
readable, otherwise print a brief usage message and exit with a non-zero status;
then modify the read loop that uses COUNTER and "while IFS= read -r line; do" so
it also processes a final line without a trailing newline by using the
read-or-last-line pattern (e.g., read ... || [ -n "$line" ]), preserving COUNTER
semantics and error handling.

In `@bash/nord/exit_node.sh`:
- Around line 11-14: The peer names are inconsistent across scripts
(exit_node.sh uses "DELL"/"Pixel", routing.sh uses "DellNord", mesh.sh sets
"mesh-dell"); standardize or document a single canonical peer nickname and
update all nordvpn meshnet peer routing allow lines to use that canonical name
(or add a clear comment mapping aliases to the canonical name) so references
like DELL, Pixel, DellNord, and mesh-dell are unambiguous across exit_node.sh,
routing.sh, and mesh.sh.

In `@bash/nord/nord_watchdog.sh`:
- Around line 34-39: The current block that reads IF_FORWARD and runs `sysctl -w
net.ipv4.ip_forward=1` only makes a transient change; update the watchdog to
persist the setting by writing the net.ipv4.ip_forward=1 into system sysctl
configuration (e.g., `/etc/sysctl.conf` or a file under `/etc/sysctl.d/`) and
reload sysctl so the kernel picks it up permanently; modify the section that
checks IF_FORWARD (variable IF_FORWARD and the `sysctl -w` call) to also ensure
the persistent configuration contains the setting and call the appropriate
reload/apply step.
- Around line 15-19: The current login check uses `nordvpn status | grep -q
"Status:"` which can be true even when disconnected; change the check in the
if-block that runs `nordvpn status` so it captures the command output into a
variable and tests for the specific "You are not logged in" (or similar
non-authenticated) message instead of just "Status:". Update the conditional
that currently references `nordvpn status | grep -q "Status:"` to grep or test
the captured output for "You are not logged in" (and keep the same echo and exit
1 behavior) so the script reliably detects an unauthenticated session.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cf737460-c7ef-4316-9a91-5d5a13e3f9b1

📥 Commits

Reviewing files that changed from the base of the PR and between 50c5974 and a4da5a2.

📒 Files selected for processing (8)
  • README.md
  • bash/countLines.sh
  • bash/nord/config.sh
  • bash/nord/exit_node.sh
  • bash/nord/mesh.sh
  • bash/nord/nord_watchdog.sh
  • bash/nord/routing.sh
  • bash/nord/routing.sh.save

Comment thread bash/nord/exit_node.sh Outdated
Comment thread bash/nord/nord_watchdog.sh Outdated
Comment on lines +27 to +32
# 4. Ensure Exit Node permission is ACTIVE
# We check if the email is in the allowed list
if ! nordvpn meshnet peer list | grep -A 5 "This device" | grep -q "Allowing to use as exit node: yes"; then
echo "Setting Exit Node permissions for $USER_EMAIL..."
nordvpn meshnet peer allow-exit-node set "$USER_EMAIL"
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

NordVPN meshnet peer allow-exit-node command syntax and usage

💡 Result:

The NordVPN Meshnet CLI command to allow a peer device to use your device as an exit node (i.e., route traffic through it) is nordvpn meshnet peer routing allow <device>. Syntax: nordvpn meshnet peer routing allow <device> - Replace <device> with the peer's Nord name, nickname, or Meshnet IP address. Usage: 1. List peers: nordvpn meshnet peer list 2. Allow routing for a specific peer: nordvpn meshnet peer routing allow happy.matterhorn.nord (example) 3. To deny: nordvpn meshnet peer routing deny <device> This enables the "traffic routing through your device" permission on Linux, allowing the peer to connect via nordvpn meshnet peer connect <device> on their end. Note: there is no exact "allow-exit-node" command; "routing allow" is the equivalent for enabling a peer as an exit node host. Use tab completion for device names. For full help: nordvpn meshnet peer --help

Citations:


Use correct command syntax for granting exit-node permission.

The command nordvpn meshnet peer allow-exit-node set "$USER_EMAIL" is incorrect. The correct command is:

nordvpn meshnet peer routing allow <device>

Replace <device> with the peer's Nord name, nickname, or Meshnet IP address (obtained from nordvpn meshnet peer list). The subcommand allow-exit-node does not exist; use routing allow instead, and pass a device identifier, not an email address.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/nord_watchdog.sh` around lines 27 - 32, The script currently uses
the nonexistent subcommand `nordvpn meshnet peer allow-exit-node set
"$USER_EMAIL"` to grant exit-node permission; replace it with the correct
command `nordvpn meshnet peer routing allow <device>` and pass the peer's Nord
name, nickname, or Meshnet IP (as obtained from `nordvpn meshnet peer list`)
instead of an email; update the conditional that checks for "Allowing to use as
exit node: yes" to extract the device identifier (e.g., nickname or IP) from
`nordvpn meshnet peer list` and use that identifier in the `nordvpn meshnet peer
routing allow` command so the permission is applied correctly.

Comment thread bash/nord/routing.sh Outdated
Comment on lines +1 to +3
#! /usr/bin/bash

nordvpn meshnet peer routing allow DellNord

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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for peer name references across nord scripts
echo "=== Peer names used in nord scripts ==="
rg -n "mesh-dell|DellNord|DELL" bash/nord/

Repository: terjeinnerdal/scripts

Length of output: 369


Verify peer name consistency across nord scripts.

The script references peer DellNord, but the previous version (routing.sh.save) and mesh.sh both use mesh-dell. Additionally, exit_node.sh uses DELL for what appears to be a similar peer reference. Clarify whether the peer was renamed or if these scripts should use consistent naming—currently three different identifiers are used across the codebase (DellNord, mesh-dell, DELL).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/routing.sh` around lines 1 - 3, The peer name is inconsistent
across scripts (DellNord in routing.sh, mesh-dell in routing.sh.save and
mesh.sh, and DELL in exit_node.sh); pick a single canonical peer identifier
(e.g., mesh-dell) and update all references to that exact string and casing so
they match: change the nordvpn command in routing.sh (nordvpn meshnet peer
routing allow DellNord) to use the chosen name, update mesh.sh and
routing.sh.save to the same identifier, and align any environment variable or
constant like DELL in exit_node.sh to the same canonical name to ensure
consistency.

Comment thread bash/nord/raspberry_router.sh Outdated
Comment on lines +1 to +4
#! /usr/bin/bash

nordvpn meshnet peer routing allow mesh-dell

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.

⚠️ Potential issue | 🟡 Minor

Remove editor backup file from repository.

The .save extension typically indicates an editor backup file (e.g., from nano). This file should likely be removed from the repository and added to .gitignore.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/routing.sh.save` around lines 1 - 4, Remove the editor backup file
routing.sh.save from the repository and stop tracking it; delete the file from
Git and add a .save or editor backup pattern (e.g., *.save or common editor
backups) to .gitignore so similar files are ignored in future. Verify the
intended script is preserved under the correct name (e.g., routing.sh) if that
command "nordvpn meshnet peer routing allow mesh-dell" should exist in a
committed script, and ensure only the canonical script is tracked.

Comment thread README.md
Comment on lines +9 to +11
### NordVPN

Make me an exit_node god damn it!

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.

⚠️ Potential issue | 🟡 Minor

Consider using more descriptive documentation.

The NordVPN section description "Make me an exit_node god damn it!" is informal. Consider replacing it with a brief explanation of what the scripts do, e.g., "Scripts for configuring NordVPN Meshnet and exit node functionality."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 9 - 11, Replace the informal NordVPN section text
("Make me an exit_node god damn it!") with a concise, professional description
of the scripts’ purpose; update the NordVPN section under the "### NordVPN"
heading to something like "Scripts for configuring NordVPN Meshnet and exit node
functionality" (or similar wording that clearly states what the scripts do).

@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 4 file(s) based on 5 unresolved review comments.

A stacked PR containing fixes has been created.

  • Stacked PR: #8
  • Files modified:
  • README.md
  • bash/nord/exit_node.sh
  • bash/nord/nord_watchdog.sh
  • bash/nord/routing.sh

Time taken: 2m 52s

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
bash/nord/config.sh (1)

21-38: Deduplicate peer lists to prevent configuration drift.

The same peer identifiers are repeated across autoconnect and fileshare/auto-accept blocks. A single array + loop reduces future mismatch risk.

Refactor sketch
+PEERS=(mesh-raspberry mesh-hp mesh-dell mesh-tab8 mesh-pixel)
+
 # Set auto-connect for these devices
-nordvpn set autoconnect on mesh-raspberry
-nordvpn set autoconnect on mesh-hp
-nordvpn set autoconnect on mesh-dell
-nordvpn set autoconnect on mesh-tab8
-nordvpn set autoconnect on mesh-pixel
+for peer in "${PEERS[@]}"; do
+  nordvpn set autoconnect on "$peer"
+done
 
 # Auto-accept files shared from peers
-nordvpn meshnet peer fileshare allow mesh-hp
-nordvpn meshnet peer auto-accept enable mesh-hp
-nordvpn meshnet peer fileshare allow mesh-dell
-nordvpn meshnet peer auto-accept enable mesh-dell
-nordvpn meshnet peer fileshare allow mesh-pixel
-nordvpn meshnet peer auto-accept enable mesh-pixel
-nordvpn meshnet peer fileshare allow mesh-tab8
-nordvpn meshnet peer auto-accept enable mesh-tab8
-nordvpn meshnet peer fileshare allow mesh-raspberry
-nordvpn meshnet peer auto-accept enable mesh-raspberry
+for peer in "${PEERS[@]}"; do
+  nordvpn meshnet peer fileshare allow "$peer"
+  nordvpn meshnet peer auto-accept enable "$peer"
+done
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/config.sh` around lines 21 - 38, Replace repeated per-device
commands with a single peers list and iterate over it: define an array (e.g.
peers=("mesh-raspberry" "mesh-hp" "mesh-dell" "mesh-tab8" "mesh-pixel")) and
loop to run the existing commands instead of repeating them; inside the loop
call the same commands currently seen (nordvpn set autoconnect on <peer>,
nordvpn meshnet peer fileshare allow <peer>, nordvpn meshnet peer auto-accept
enable <peer>) so you maintain behavior but avoid duplication and drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bash/nord/config.sh`:
- Line 13: The unquoted variable in the command "nordvpn meshnet set nickname
$NICKNAME" can cause word-splitting or globbing when NICKNAME contains spaces or
wildcards; update the invocation to quote the expansion (use "$NICKNAME") so the
nickname is passed as a single argument and prevent unintended glob expansion.
- Around line 12-38: This script must stop on the first failed nordvpn command
to avoid partial/invalid state: add a strict shell mode header (e.g., set -euo
pipefail) at the top and validate required vars (e.g., ensure NICKNAME is set
with ${NICKNAME:?}) so the script aborts early, and for any particularly
critical operations (like nordvpn set meshnet on, nordvpn meshnet set nickname
$NICKNAME, and each nordvpn set autoconnect / meshnet peer ... command) either
rely on the global -e or append || exit 1 to make failures explicit; optionally
add a trap to log the failing command for easier debugging.

---

Nitpick comments:
In `@bash/nord/config.sh`:
- Around line 21-38: Replace repeated per-device commands with a single peers
list and iterate over it: define an array (e.g. peers=("mesh-raspberry"
"mesh-hp" "mesh-dell" "mesh-tab8" "mesh-pixel")) and loop to run the existing
commands instead of repeating them; inside the loop call the same commands
currently seen (nordvpn set autoconnect on <peer>, nordvpn meshnet peer
fileshare allow <peer>, nordvpn meshnet peer auto-accept enable <peer>) so you
maintain behavior but avoid duplication and drift.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 37a08a5a-cd2a-445f-8209-3829a608019a

📥 Commits

Reviewing files that changed from the base of the PR and between a4da5a2 and 0749662.

📒 Files selected for processing (3)
  • bash/nord/README.me
  • bash/nord/config.sh
  • bash/nord/exit_node.sh
✅ Files skipped from review due to trivial changes (1)
  • bash/nord/README.me
🚧 Files skipped from review as they are similar to previous changes (1)
  • bash/nord/exit_node.sh

Comment thread bash/nord/config.sh
Comment on lines +12 to +38
nordvpn set meshnet on
nordvpn meshnet set nickname $NICKNAME

nordvpn set notify on
nordvpn set autoconnect on NO

nordvpn set pq off
nordvpn set lan-discovery on
nordvpn set meshnet on
nordvpn set lan-discovery off
nordvpn set technology nordlynx

# Set nickname
nordvpn meshnet peer remove NordDell
nordvpn meshnet set nickname NordDell
# Set auto-connect for these devices
nordvpn set autoconnect on mesh-raspberry
nordvpn set autoconnect on mesh-hp
nordvpn set autoconnect on mesh-dell
nordvpn set autoconnect on mesh-tab8
nordvpn set autoconnect on mesh-pixel

# Auto-accept files shared from peers
nordvpn meshnet peer fileshare allow hp
nordvpn meshnet peer auto-accept enable hp
nordvpn meshnet peer fileshare allow Pixel
nordvpn meshnet peer auto-accept enable Pixel
nordvpn meshnet peer fileshare allow Tab8
nordvpn meshnet peer auto-accept enable Tab8

nordvpn meshnet peer fileshare allow mesh-hp
nordvpn meshnet peer auto-accept enable mesh-hp
nordvpn meshnet peer fileshare allow mesh-dell
nordvpn meshnet peer auto-accept enable mesh-dell
nordvpn meshnet peer fileshare allow mesh-pixel
nordvpn meshnet peer auto-accept enable mesh-pixel
nordvpn meshnet peer fileshare allow mesh-tab8
nordvpn meshnet peer auto-accept enable mesh-tab8
nordvpn meshnet peer fileshare allow mesh-raspberry
nordvpn meshnet peer auto-accept enable mesh-raspberry

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.

⚠️ Potential issue | 🟠 Major

Stop on first failed nordvpn command to avoid partial state.

This script performs many mutating commands, but currently continues after failures. A mid-script failure can leave Meshnet/config in inconsistent state.

Proposed hardening
 #! /usr/bin/bash
+set -e

 if [ -z "$1" ]; then
     echo "Error: No argument provided."
     exit 1
 fi
🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 13-13: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/config.sh` around lines 12 - 38, This script must stop on the first
failed nordvpn command to avoid partial/invalid state: add a strict shell mode
header (e.g., set -euo pipefail) at the top and validate required vars (e.g.,
ensure NICKNAME is set with ${NICKNAME:?}) so the script aborts early, and for
any particularly critical operations (like nordvpn set meshnet on, nordvpn
meshnet set nickname $NICKNAME, and each nordvpn set autoconnect / meshnet peer
... command) either rely on the global -e or append || exit 1 to make failures
explicit; optionally add a trap to log the failing command for easier debugging.

Comment thread bash/nord/config.sh
NICKNAME=$1

nordvpn set meshnet on
nordvpn meshnet set nickname $NICKNAME

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.

⚠️ Potential issue | 🟡 Minor

Quote NICKNAME to avoid word splitting/globbing.

At Line 13, unquoted expansion can pass unintended multiple arguments when nickname contains spaces or wildcard characters.

Proposed fix
-nordvpn meshnet set nickname $NICKNAME
+nordvpn meshnet set nickname "$NICKNAME"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
nordvpn meshnet set nickname $NICKNAME
nordvpn meshnet set nickname "$NICKNAME"
🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 13-13: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bash/nord/config.sh` at line 13, The unquoted variable in the command
"nordvpn meshnet set nickname $NICKNAME" can cause word-splitting or globbing
when NICKNAME contains spaces or wildcards; update the invocation to quote the
expansion (use "$NICKNAME") so the nickname is passed as a single argument and
prevent unintended glob expansion.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant