Skip to content

Commit fc91a2d

Browse files
authored
Merge pull request #21 from coelacant1/testing
V2.1.6 - Bug fixes, username support, and validation improvements ### Added - **Username Configuration** - Support for specifying SSH usernames per node - Added `username` field to nodes.json configuration - Username prompts in all node configuration flows (manual entry, saved nodes, IP ranges, VMID ranges) - Default username is "root" with option to specify alternatives - Display format changed to `username@ip` throughout GUI - **Dependency Checking** - Runtime validation before remote execution - `__check_remote_dependencies__()` function checks for sshpass and jq - Helpful error messages with installation commands for all major distros - Notes that sshpass is not required when using SSH keys - **Syntax Validation** - Basic shell syntax checking added to validation suite - New Check 1a. in `_RunChecks.sh` runs `bash -n` on all .sh files - Catches structural errors and orphaned code blocks - Shows file names and line numbers for syntax errors - **Enhanced Source Verification** - Improved validation of shellcheck directives - `VerifySourceCalls.py` now validates shellcheck comments have matching source statements - Detects orphaned shellcheck directives within 5 lines - Prevents mismatched documentation and code ### Changed - **Remote Execution UI** - Scripts hidden in remote mode for better UX - GUI.sh and CCPVE.sh hidden from root menu when in remote execution mode - Prevents accidental execution of control scripts on remote nodes - Scripts still shown in local mode and subdirectories - **README.md** - Clarified dependency requirements - Updated installation command to include `jq` and `sshpass` - Documented that sshpass is only needed for password-based authentication - Separated build-time tools from runtime dependencies ### Fixed - **Critical: Orphaned Error Handler** - Fixed syntax error in `Host/HostInfo.sh` - Removed orphaned error handler code block (lines 34-36) - File had error message without matching source statement - Bug prevented script execution on remote nodes - **Username Hardcoding** - Removed hardcoded "root@" from all remote operations - Updated all SSH/SCP operations in `RemoteExecutor.sh` to use configured username - `__ssh_exec__`, `__scp_exec__`, `__scp_exec_recursive__`, `__scp_download__` now accept username parameter - `ConfigManager.sh` tracks username per node in `NODE_USERNAMES` associative array - **Missing Validation** - Syntax check gap closed - `_RunChecks.sh` never validated basic syntax :C - Now catches structural errors that bash -n would detect - Prevents orphaned code and malformed control structures from entering repository ### Technical Details - `nodes.json.template` - Added username field with "root" default - `Utilities/ConfigManager.sh` - Added NODE_USERNAMES tracking and __get_node_username__() function - `Utilities/RemoteExecutor.sh` - All remote operations parameterized with username - `GUI.sh` - Dependency checking, username prompts, and script filtering - `.check/VerifySourceCalls.py` - Enhanced shellcheck directive validation - `.check/_RunChecks.sh` - Added Check 1a. for syntax validation ### Developer Notes The orphaned error handler bug existed because: - `bash -n` syntax check was not being run in validation suite - `DeadCodeCheck.py` only checks unused functions/variables, not code structure - `VerifySourceCalls.py` didn't validate orphaned error handlers The fix adds syntax validation to prevent similar issues...
2 parents 918e79f + d36fbc4 commit fc91a2d

File tree

13 files changed

+356
-91
lines changed

13 files changed

+356
-91
lines changed

.check/VerifySourceCalls.py

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,27 +138,47 @@ def parse_functions_in_file(filepath):
138138

139139
def parse_script_for_includes_and_local_funcs(script_path):
140140
includes = set()
141+
shellcheck_directives = set()
141142
local_funcs = parse_functions_in_file(script_path)
142143

143144
if not os.path.isfile(script_path):
144145
return includes, local_funcs
145146

146147
with open(script_path, "r", encoding="utf-8", newline='\n') as f:
147-
for line in f:
148-
line_stripped = line.strip()
148+
lines = f.readlines()
149+
150+
for i, line in enumerate(lines):
151+
line_stripped = line.strip()
152+
153+
# Check for shellcheck directive
154+
sc_match = SHELLCHECK_SOURCE_REGEX.search(line_stripped)
155+
if sc_match:
156+
util_name = sc_match.group(1)
157+
shellcheck_directives.add(util_name)
149158

150-
# Check for source statement
151-
s_match = SOURCE_REGEX.search(line_stripped)
152-
if s_match:
153-
# e.g., "Prompts.sh" or "Cluster.sh"
154-
includes.add(s_match.group(1))
159+
# Look for matching source statement in next few lines (max 5)
160+
found_source = False
161+
for j in range(i + 1, min(i + 6, len(lines))):
162+
next_line = lines[j].strip()
163+
s_match = SOURCE_REGEX.search(next_line)
164+
if s_match and s_match.group(1) == util_name:
165+
found_source = True
166+
break
167+
# Stop if we hit another shellcheck or source for different file
168+
if SHELLCHECK_SOURCE_REGEX.search(next_line) or SOURCE_REGEX.search(next_line):
169+
break
170+
171+
if not found_source:
172+
# Orphaned shellcheck directive - don't add to includes
173+
print(f" [WARNING] Orphaned shellcheck directive for {util_name} at line {i+1}")
174+
continue
175+
176+
# Check for source statement
177+
s_match = SOURCE_REGEX.search(line_stripped)
178+
if s_match:
179+
# e.g., "Prompts.sh" or "Cluster.sh"
180+
includes.add(s_match.group(1))
155181

156-
# Also check for shellcheck directive (for consistency checking)
157-
sc_match = SHELLCHECK_SOURCE_REGEX.search(line_stripped)
158-
if sc_match:
159-
# Verify this matches an actual source line
160-
includes.add(sc_match.group(1))
161-
162182
return includes, local_funcs
163183

164184
###############################################################################

.check/_RunChecks.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,33 @@ fi
126126
CHECKS_RUN=$((CHECKS_RUN + 1))
127127
echo ""
128128

129+
# Check 1a: Basic shell syntax validation
130+
echo "1a. Validating shell syntax (bash -n)..."
131+
SYNTAX_ERRORS=0
132+
SYNTAX_FILES=()
133+
while IFS= read -r -d '' file; do
134+
if ! bash -n "$file" 2>/dev/null; then
135+
SYNTAX_ERRORS=$((SYNTAX_ERRORS + 1))
136+
SYNTAX_FILES+=("$file")
137+
fi
138+
done < <(find . -name "*.sh" -not -path "*/.git/*" -not -path "*/.check/*" -print0)
139+
140+
if [ $SYNTAX_ERRORS -eq 0 ]; then
141+
echo "- All shell scripts have valid syntax"
142+
CHECKS_PASSED=$((CHECKS_PASSED + 1))
143+
else
144+
echo "- FAILED: $SYNTAX_ERRORS file(s) with syntax errors"
145+
if [ "$VERBOSE" = true ] || [ $SYNTAX_ERRORS -le 5 ]; then
146+
for file in "${SYNTAX_FILES[@]}"; do
147+
echo " $file"
148+
bash -n "$file" 2>&1 | head -3 | sed 's/^/ /'
149+
done
150+
fi
151+
CHECKS_FAILED=$((CHECKS_FAILED + 1))
152+
fi
153+
CHECKS_RUN=$((CHECKS_RUN + 1))
154+
echo ""
155+
129156
# Check 2: Update function indices
130157
echo "2. Updating function indices..."
131158
python3 .check/UpdateFunctionIndex.py ./ 2>&1 | tail -3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
nodes.json
55
TestConnectionInfo.json
66
.d/
7+
.nfs*
78

89
# Downloaded Proxmox documentation (keep scripts, ignore generated content)
910
.docs/*.html

.site/MultiView.png

182 KB
Loading

.site/MultiView2.png

321 KB
Loading

CHANGELOG.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,68 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.1.6] - 2025-11-25
9+
10+
Bug fixes, username support, and validation improvements
11+
12+
### Added
13+
- **Username Configuration** - Support for specifying SSH usernames per node
14+
- Added `username` field to nodes.json configuration
15+
- Username prompts in all node configuration flows (manual entry, saved nodes, IP ranges, VMID ranges)
16+
- Default username is "root" with option to specify alternatives
17+
- Display format changed to `username@ip` throughout GUI
18+
- **Dependency Checking** - Runtime validation before remote execution
19+
- `__check_remote_dependencies__()` function checks for sshpass and jq
20+
- Helpful error messages with installation commands for all major distros
21+
- Notes that sshpass is not required when using SSH keys
22+
- **Syntax Validation** - Basic shell syntax checking added to validation suite
23+
- New Check 1a. in `_RunChecks.sh` runs `bash -n` on all .sh files
24+
- Catches structural errors and orphaned code blocks
25+
- Shows file names and line numbers for syntax errors
26+
- **Enhanced Source Verification** - Improved validation of shellcheck directives
27+
- `VerifySourceCalls.py` now validates shellcheck comments have matching source statements
28+
- Detects orphaned shellcheck directives within 5 lines
29+
- Prevents mismatched documentation and code
30+
31+
### Changed
32+
- **Remote Execution UI** - Scripts hidden in remote mode for better UX
33+
- GUI.sh and CCPVE.sh hidden from root menu when in remote execution mode
34+
- Prevents accidental execution of control scripts on remote nodes
35+
- Scripts still shown in local mode and subdirectories
36+
- **README.md** - Clarified dependency requirements
37+
- Updated installation command to include `jq` and `sshpass`
38+
- Documented that sshpass is only needed for password-based authentication
39+
- Separated build-time tools from runtime dependencies
40+
41+
### Fixed
42+
- **Critical: Orphaned Error Handler** - Fixed syntax error in `Host/HostInfo.sh`
43+
- Removed orphaned error handler code block (lines 34-36)
44+
- File had error message without matching source statement
45+
- Bug prevented script execution on remote nodes
46+
- **Username Hardcoding** - Removed hardcoded "root@" from all remote operations
47+
- Updated all SSH/SCP operations in `RemoteExecutor.sh` to use configured username
48+
- `__ssh_exec__`, `__scp_exec__`, `__scp_exec_recursive__`, `__scp_download__` now accept username parameter
49+
- `ConfigManager.sh` tracks username per node in `NODE_USERNAMES` associative array
50+
- **Missing Validation** - Syntax check gap closed
51+
- `_RunChecks.sh` never validated basic syntax :C
52+
- Now catches structural errors that bash -n would detect
53+
- Prevents orphaned code and malformed control structures from entering repository
54+
55+
### Technical Details
56+
- `nodes.json.template` - Added username field with "root" default
57+
- `Utilities/ConfigManager.sh` - Added NODE_USERNAMES tracking and __get_node_username__() function
58+
- `Utilities/RemoteExecutor.sh` - All remote operations parameterized with username
59+
- `GUI.sh` - Dependency checking, username prompts, and script filtering
60+
- `.check/VerifySourceCalls.py` - Enhanced shellcheck directive validation
61+
- `.check/_RunChecks.sh` - Added Check 1a. for syntax validation
62+
63+
### Developer Notes
64+
The orphaned error handler bug existed because:
65+
- `bash -n` syntax check was not being run in validation suite
66+
- `DeadCodeCheck.py` only checks unused functions/variables, not code structure
67+
- `VerifySourceCalls.py` didn't validate orphaned error handlers
68+
The fix adds syntax validation to prevent similar issues...
69+
870
## [2.1.5] - 2025-11-24
971

1072
PVE documentation automation and repository cleanup

0 commit comments

Comments
 (0)