diff --git a/install_kiosk_0.9.2-6.sh b/install_kiosk_0.9.2-6.sh index 00db7ed..f2ff6bd 100755 --- a/install_kiosk_0.9.2-6.sh +++ b/install_kiosk_0.9.2-6.sh @@ -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" diff --git a/update_electron.sh b/update_electron.sh index e46b5a0..d3e2abf 100755 --- a/update_electron.sh +++ b/update_electron.sh @@ -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"