Fix cd permission issue and use correct service name (lightdm)
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.
This commit is contained in:
+22
-24
@@ -8523,8 +8523,8 @@ manual_electron_update() {
|
||||
echo "UPDATING ELECTRON"
|
||||
echo "──────────────────────────────────────────────────────────"
|
||||
|
||||
log_info "Stopping kiosk service..."
|
||||
sudo systemctl stop kiosk || true
|
||||
log_info "Stopping kiosk display..."
|
||||
sudo systemctl stop lightdm || true
|
||||
sleep 2
|
||||
|
||||
log_info "Updating Electron to version $LATEST_VERSION..."
|
||||
@@ -8533,22 +8533,21 @@ manual_electron_update() {
|
||||
sudo -u "$KIOSK_USER" sed -i "s/\"electron\": \".*\"/\"electron\": \"^$LATEST_VERSION\"/" "$KIOSK_DIR/package.json"
|
||||
|
||||
# Remove old electron installation
|
||||
if [ -d "$KIOSK_DIR/node_modules/electron" ]; then
|
||||
if sudo test -d "$KIOSK_DIR/node_modules/electron" 2>/dev/null; then
|
||||
log_info "Removing old Electron installation..."
|
||||
sudo -u "$KIOSK_USER" rm -rf "$KIOSK_DIR/node_modules/electron"
|
||||
fi
|
||||
|
||||
# Install new version
|
||||
log_info "Installing Electron $LATEST_VERSION (this may take a few minutes)..."
|
||||
cd "$KIOSK_DIR"
|
||||
|
||||
if sudo -u "$KIOSK_USER" npm install electron@"$LATEST_VERSION" 2>&1 | tee /tmp/electron_install.log; then
|
||||
if sudo -u "$KIOSK_USER" bash -c "cd '$KIOSK_DIR' && npm install electron@'$LATEST_VERSION'" 2>&1 | tee /tmp/electron_install.log; then
|
||||
echo ""
|
||||
log_success "Electron updated successfully to version $LATEST_VERSION"
|
||||
|
||||
# Fix chrome-sandbox permissions
|
||||
local sandbox="$KIOSK_DIR/node_modules/electron/dist/chrome-sandbox"
|
||||
if [ -f "$sandbox" ]; then
|
||||
if sudo test -f "$sandbox" 2>/dev/null; then
|
||||
sudo chown root:root "$sandbox"
|
||||
sudo chmod 4755 "$sandbox"
|
||||
log_success "Fixed chrome-sandbox permissions"
|
||||
@@ -8560,25 +8559,25 @@ manual_electron_update() {
|
||||
log_success "Electron updated from $CURRENT_VERSION to $NEW_VERSION"
|
||||
echo ""
|
||||
|
||||
# Restart kiosk
|
||||
read -r -p "Restart kiosk service now? (y/n): " -n 1
|
||||
# Restart kiosk display
|
||||
read -r -p "Restart kiosk display now? (y/n): " -n 1
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
log_info "Restarting kiosk service..."
|
||||
sudo systemctl start kiosk
|
||||
log_info "Restarting kiosk display..."
|
||||
sudo systemctl start lightdm
|
||||
sleep 3
|
||||
|
||||
if systemctl is-active --quiet kiosk; then
|
||||
log_success "Kiosk service started successfully"
|
||||
if systemctl is-active --quiet lightdm; then
|
||||
log_success "Kiosk display started successfully"
|
||||
else
|
||||
log_error "Kiosk service failed to start"
|
||||
log_error "Check logs with: sudo journalctl -u kiosk -n 50"
|
||||
log_error "Kiosk display failed to start"
|
||||
log_error "Check logs with: sudo journalctl -u lightdm -n 50"
|
||||
echo ""
|
||||
log_warning "You may need to restore from backup"
|
||||
fi
|
||||
else
|
||||
log_info "Kiosk service not started"
|
||||
log_info "Start manually with: sudo systemctl start kiosk"
|
||||
log_info "Kiosk display not started"
|
||||
log_info "Start manually with: sudo systemctl start lightdm"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
@@ -8593,21 +8592,20 @@ manual_electron_update() {
|
||||
log_warning "Attempting to restore from backup..."
|
||||
|
||||
# Restore package.json
|
||||
if [ -f "$backup_dir/package.json" ]; then
|
||||
sudo cp "$backup_dir/package.json" "$KIOSK_DIR/"
|
||||
if sudo test -f "$backup_dir/package.json" 2>/dev/null; then
|
||||
sudo -u "$KIOSK_USER" cp "$backup_dir/package.json" "$KIOSK_DIR/"
|
||||
log_success "Restored package.json"
|
||||
fi
|
||||
|
||||
# Reinstall original version
|
||||
log_info "Reinstalling original Electron version..."
|
||||
cd "$KIOSK_DIR"
|
||||
if sudo -u "$KIOSK_USER" npm install; then
|
||||
if sudo -u "$KIOSK_USER" bash -c "cd '$KIOSK_DIR' && npm install"; then
|
||||
log_success "Restored original Electron installation"
|
||||
|
||||
# Restart kiosk
|
||||
log_info "Restarting kiosk service..."
|
||||
sudo systemctl start kiosk
|
||||
log_success "Kiosk service restarted"
|
||||
# Restart kiosk display
|
||||
log_info "Restarting kiosk display..."
|
||||
sudo systemctl start lightdm
|
||||
log_success "Kiosk display restarted"
|
||||
else
|
||||
log_error "Failed to restore original installation"
|
||||
log_error "Manual intervention required"
|
||||
|
||||
+20
-22
@@ -254,8 +254,8 @@ update_electron() {
|
||||
local target_version="$2"
|
||||
local kiosk_owner="$3"
|
||||
|
||||
log_info "Stopping kiosk service..."
|
||||
sudo systemctl stop kiosk || true
|
||||
log_info "Stopping kiosk display..."
|
||||
sudo systemctl stop lightdm || true
|
||||
sleep 2
|
||||
|
||||
log_info "Updating Electron to version $target_version..."
|
||||
@@ -264,21 +264,20 @@ update_electron() {
|
||||
sudo -u "$kiosk_owner" sed -i "s/\"electron\": \".*\"/\"electron\": \"^$target_version\"/" "$kiosk_dir/package.json"
|
||||
|
||||
# Remove old electron installation
|
||||
if [ -d "$kiosk_dir/node_modules/electron" ]; then
|
||||
if sudo test -d "$kiosk_dir/node_modules/electron" 2>/dev/null; then
|
||||
log_info "Removing old Electron installation..."
|
||||
sudo -u "$kiosk_owner" rm -rf "$kiosk_dir/node_modules/electron"
|
||||
fi
|
||||
|
||||
# Install new version
|
||||
log_info "Installing Electron $target_version (this may take a few minutes)..."
|
||||
cd "$kiosk_dir"
|
||||
|
||||
if sudo -u "$kiosk_owner" npm install electron@"$target_version" 2>&1 | tee /tmp/electron_install.log; then
|
||||
if sudo -u "$kiosk_owner" bash -c "cd '$kiosk_dir' && npm install electron@'$target_version'" 2>&1 | tee /tmp/electron_install.log; then
|
||||
log_success "Electron updated successfully to version $target_version"
|
||||
|
||||
# Fix chrome-sandbox permissions
|
||||
local sandbox="$kiosk_dir/node_modules/electron/dist/chrome-sandbox"
|
||||
if [ -f "$sandbox" ]; then
|
||||
if sudo test -f "$sandbox" 2>/dev/null; then
|
||||
sudo chown root:root "$sandbox"
|
||||
sudo chmod 4755 "$sandbox"
|
||||
log_success "Fixed chrome-sandbox permissions"
|
||||
@@ -435,26 +434,26 @@ main() {
|
||||
log_success "Electron updated from $CURRENT_VERSION to $NEW_VERSION"
|
||||
echo ""
|
||||
|
||||
# Restart kiosk
|
||||
read -p "Restart kiosk service now? (y/n): " -n 1 -r
|
||||
# Restart kiosk display
|
||||
read -p "Restart kiosk display now? (y/n): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
log_info "Restarting kiosk service..."
|
||||
sudo systemctl start kiosk
|
||||
log_info "Restarting kiosk display..."
|
||||
sudo systemctl start lightdm
|
||||
sleep 3
|
||||
|
||||
if systemctl is-active --quiet kiosk; then
|
||||
log_success "Kiosk service started successfully"
|
||||
if systemctl is-active --quiet lightdm; then
|
||||
log_success "Kiosk display started successfully"
|
||||
else
|
||||
log_error "Kiosk service failed to start"
|
||||
log_error "Check logs with: sudo journalctl -u kiosk -n 50"
|
||||
log_error "Kiosk display failed to start"
|
||||
log_error "Check logs with: sudo journalctl -u lightdm -n 50"
|
||||
echo ""
|
||||
log_warning "You may need to restore from backup"
|
||||
show_restore_instructions "$BACKUP_DIR"
|
||||
fi
|
||||
else
|
||||
log_info "Kiosk service not started"
|
||||
log_info "Start manually with: sudo systemctl start kiosk"
|
||||
log_info "Kiosk display not started"
|
||||
log_info "Start manually with: sudo systemctl start lightdm"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
@@ -476,14 +475,13 @@ main() {
|
||||
|
||||
# Reinstall original version
|
||||
log_info "Reinstalling original Electron version..."
|
||||
cd "$KIOSK_DIR"
|
||||
if sudo -u "$KIOSK_OWNER" npm install; then
|
||||
if sudo -u "$KIOSK_OWNER" bash -c "cd '$KIOSK_DIR' && npm install"; then
|
||||
log_success "Restored original Electron installation"
|
||||
|
||||
# Restart kiosk
|
||||
log_info "Restarting kiosk service..."
|
||||
sudo systemctl start kiosk
|
||||
log_success "Kiosk service restarted"
|
||||
# Restart kiosk display
|
||||
log_info "Restarting kiosk display..."
|
||||
sudo systemctl start lightdm
|
||||
log_success "Kiosk display restarted"
|
||||
else
|
||||
log_error "Failed to restore original installation"
|
||||
log_error "Manual intervention required"
|
||||
|
||||
Reference in New Issue
Block a user