Fixed two critical issues preventing Electron update from completing:
1. cd permission denied error
Problem: Script tried to `cd /home/kiosk/kiosk-app` which failed with
"Permission denied" because the directory has restricted permissions (drwxr-x---)
and the regular user can't enter it.
Fix: Use `sudo -u kiosk bash -c "cd '/home/kiosk/kiosk-app' && npm install ..."`
instead of separate cd + npm commands. This runs both commands as the kiosk
user in a single bash session, avoiding the permission issue.
2. Wrong service name (kiosk vs lightdm)
Problem: Scripts tried to stop/start "kiosk" service which doesn't exist on
the user's system. Their kiosk runs under lightdm service.
Fix: Changed all references from:
- `systemctl stop/start kiosk` → `systemctl stop/start lightdm`
- "Restart kiosk service" → "Restart kiosk display"
- `journalctl -u kiosk` → `journalctl -u lightdm`
Additional fixes:
- Updated file checks: `[ -d ]` → `sudo test -d` for restricted directories
- Applied fixes to both update paths: successful install and failure/restore
- Updated both update_electron.sh and install_kiosk_0.9.2-6.sh
Changes in both scripts:
- update_electron() function: removed cd, added bash -c wrapper, changed service name
- Backup restore paths: same fixes applied
- Success path: updated restart prompts and service checks
- Failure path: fixed restore process with proper directory access
The update should now complete successfully without permission errors.
Fixed two issues preventing the Electron update from working properly:
1. Log messages appearing in version output
- get_latest_electron_version() was outputting log messages to stdout
- These messages were being captured along with the version number
- Result: "Target version: [INFO] Fetching...39.2.3" in output
- Fix: Redirect log_info and log_error to stderr with >&2
- Now only the version number is captured in the variable
2. Backup function permission errors
- stat command needed sudo to read owner of restricted directories
- File checks [ -f ] couldn't access files in drwxr-x--- directories
- mkdir failed with "cannot create directory '/home/kiosk': Permission denied"
- Fix: Use sudo for all file operations in create_backup():
* sudo stat -c '%U' to get directory owner
* sudo test -f/d for file/directory checks
* sudo -u owner for mkdir, cp, and file writes
Changes in both update_electron.sh and install_kiosk_0.9.2-6.sh:
- get_latest_electron_version functions: Added >&2 to log statements
- create_backup functions: Added sudo to stat and all file checks
- Ensures backup works with restricted /home/kiosk permissions
The update process should now complete successfully without permission errors
or garbled version output.
The scripts were failing to find the kiosk installation at /home/kiosk/kiosk-app
because the /home/kiosk directory has restricted permissions (drwxr-x---),
preventing regular users from reading it.
Changes in both update_electron.sh and install_kiosk_0.9.2-6.sh:
1. Updated find_kiosk_dir() to use sudo for all file checks
- sudo test -f for checking if main.js exists
- Prevents "permission denied" errors on restricted directories
2. Added Method 4: Detect from running electron process
- Parses ps output to find electron executable path
- Extracts app directory from the path
- Provides fallback when directory searches fail
3. Updated get_current_electron_version functions
- Use sudo test -f to check if package.json exists
- Use sudo grep to read package.json and get version
- Ensures version detection works with restricted permissions
4. Fixed directory existence checks
- Use sudo test -d for checking kiosk directory
These changes allow the scripts to:
- Find kiosk installations in directories with restricted permissions
- Detect installations even when run as a regular user
- Work correctly with the standard /home/kiosk setup (drwxr-x---)
- Provide better fallback detection using running processes
The scripts will now prompt for sudo password when needed to check
for files in restricted directories, then continue normally.
This new version of the install script includes a completely rewritten
manual Electron update tool that fixes all the issues with the previous version:
NEW FEATURES:
- Smart installation detection across multiple locations
- Verifies Electron is actually running (not just installed)
- Gets current version from both package.json and node_modules
- Fetches latest stable version from npm with multiple fallback methods
- Clear version comparison display (current vs latest)
- Breaking changes warning with direct links to Electron documentation
- Automatic backup creation before any changes
- Provides clear restore instructions
- Multiple user confirmation prompts before making changes
- Automatic rollback if update fails
- Fixes chrome-sandbox permissions after installation
- Manages kiosk service stop/start automatically
FIXES:
- No more "no electron app found" errors
- No more "script just bails" - proper error handling throughout
- Proper detection of running Electron instances
- Network failure handling with multiple fallback methods
- Clear feedback at every step of the process
The enhanced update tool is accessible from:
Advanced Menu → Manual Electron Update
Version updated from 0.9.2 to 0.9.2-6 to reflect the enhancement.