Merge pull request #63 from outis1one/claude/fix-kiosk-issues-qlxTc
Claude/fix kiosk issues qlx tc
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
#!/bin/bash
|
||||
################################################################################
|
||||
### Ubuntu Based Kiosk (UBK) v0.9.8 ###
|
||||
### Ubuntu Based Kiosk (UBK) v0.9.9 ###
|
||||
################################################################################
|
||||
#
|
||||
# RELEASE v0.9.9 - Settings Export/Import & Bug Fixes
|
||||
# - Added Export/Import All Settings feature (Advanced menu)
|
||||
# Backs up: sites, schedules, Squeezelite, VNC, Easy Asterisk configs
|
||||
# - Fixed power button not showing power menu (added SIGUSR1 handler)
|
||||
# - Fixed pause dialog staying open indefinitely (added 30s auto-close)
|
||||
# - Added PipeWire noise cancellation for microphone (reduces static)
|
||||
#
|
||||
# RELEASE v0.9.8 - Named Sites & Navigation Menu
|
||||
# - Added named websites feature for user-friendly site identification
|
||||
# - Added navigation menu with key icon (top left hot corner)
|
||||
@@ -40,7 +47,7 @@ set -euo pipefail
|
||||
### SECTION 1: CONSTANTS & GLOBALS
|
||||
################################################################################
|
||||
|
||||
SCRIPT_VERSION="0.9.8.1"
|
||||
SCRIPT_VERSION="0.9.9"
|
||||
KIOSK_USER="kiosk"
|
||||
BUILD_USER="${SUDO_USER:-$(whoami)}"
|
||||
KIOSK_HOME="/home/${KIOSK_USER}"
|
||||
@@ -4003,7 +4010,7 @@ const path=require('path');
|
||||
const os=require('os');
|
||||
|
||||
const CONFIG_FILE=path.join(__dirname,'config.json');
|
||||
const VERSION='0.9.8.1';
|
||||
const VERSION='0.9.9';
|
||||
|
||||
let mainWindow,views=[],hiddenViews=[],tabs=[],currentIndex=0,showingHidden=false;
|
||||
let pinWindow=null,promptWindow=null,pauseWindow=null,htmlKeyboardWindow=null;
|
||||
@@ -10076,24 +10083,330 @@ factory_reset() {
|
||||
pause
|
||||
}
|
||||
|
||||
export_config() {
|
||||
export_settings() {
|
||||
echo
|
||||
echo "══════════════════════════════════════════════════════════"
|
||||
echo " EXPORT ALL SETTINGS "
|
||||
echo "══════════════════════════════════════════════════════════"
|
||||
echo
|
||||
echo "This will export:"
|
||||
echo " • Core configuration (sites, touch controls, passwords)"
|
||||
echo " • Schedules (power, display, quiet hours)"
|
||||
echo " • Addon settings (Squeezelite, VNC, Easy Asterisk)"
|
||||
echo " • VPN configs (WireGuard, Netbird, OpenVPN)"
|
||||
echo
|
||||
|
||||
local export_dir="/tmp/kiosk-backup-$(date +%Y%m%d-%H%M%S)"
|
||||
mkdir -p "$export_dir"
|
||||
|
||||
echo "[1/7] Exporting core configuration..."
|
||||
if [[ -f "$CONFIG_PATH" ]]; then
|
||||
sudo -u "$KIOSK_USER" cp "$CONFIG_PATH" "$export_dir/config.json"
|
||||
log_success "Core config exported"
|
||||
else
|
||||
log_warning "No core config found"
|
||||
fi
|
||||
|
||||
echo "[2/7] Exporting schedule timers..."
|
||||
local timer_count=0
|
||||
mkdir -p "$export_dir/timers"
|
||||
for timer in kiosk-shutdown kiosk-display-off kiosk-display-on kiosk-quiet-start kiosk-quiet-end kiosk-electron-reload; do
|
||||
if [[ -f "/etc/systemd/system/${timer}.timer" ]]; then
|
||||
sudo cp "/etc/systemd/system/${timer}.timer" "$export_dir/timers/"
|
||||
sudo cp "/etc/systemd/system/${timer}.service" "$export_dir/timers/" 2>/dev/null
|
||||
((timer_count++))
|
||||
fi
|
||||
done
|
||||
[[ $timer_count -gt 0 ]] && log_success "Exported $timer_count schedule timers" || log_info "No schedules configured"
|
||||
|
||||
echo "[3/7] Exporting Squeezelite config..."
|
||||
if [[ -f /usr/local/bin/squeezelite-start.sh ]]; then
|
||||
sudo cp /usr/local/bin/squeezelite-start.sh "$export_dir/"
|
||||
log_success "Squeezelite config exported"
|
||||
else
|
||||
log_info "Squeezelite not installed"
|
||||
fi
|
||||
|
||||
echo "[4/7] Exporting VNC config..."
|
||||
if [[ -f /etc/systemd/system/x11vnc.service ]]; then
|
||||
sudo cp /etc/systemd/system/x11vnc.service "$export_dir/"
|
||||
# Also copy password file if it exists
|
||||
if [[ -f "$KIOSK_HOME/.vnc/passwd" ]]; then
|
||||
mkdir -p "$export_dir/vnc"
|
||||
sudo cp "$KIOSK_HOME/.vnc/passwd" "$export_dir/vnc/"
|
||||
fi
|
||||
log_success "VNC config exported"
|
||||
else
|
||||
log_info "VNC not installed"
|
||||
fi
|
||||
|
||||
echo "[5/7] Exporting Easy Asterisk client config..."
|
||||
if [[ -d "$KIOSK_HOME/.baresip" ]]; then
|
||||
mkdir -p "$export_dir/baresip"
|
||||
sudo cp -r "$KIOSK_HOME/.baresip/"* "$export_dir/baresip/" 2>/dev/null
|
||||
log_success "Easy Asterisk client config exported"
|
||||
else
|
||||
log_info "Easy Asterisk client not installed"
|
||||
fi
|
||||
|
||||
echo "[6/7] Exporting VPN configurations..."
|
||||
local vpn_count=0
|
||||
mkdir -p "$export_dir/vpn"
|
||||
|
||||
# WireGuard configs
|
||||
if [[ -d /etc/wireguard ]] && ls /etc/wireguard/*.conf &>/dev/null; then
|
||||
mkdir -p "$export_dir/vpn/wireguard"
|
||||
sudo cp /etc/wireguard/*.conf "$export_dir/vpn/wireguard/" 2>/dev/null
|
||||
log_success "WireGuard config exported"
|
||||
((vpn_count++))
|
||||
fi
|
||||
|
||||
# Netbird config and state
|
||||
if command -v netbird &>/dev/null; then
|
||||
mkdir -p "$export_dir/vpn/netbird"
|
||||
# Config file
|
||||
[[ -f /etc/netbird/config.json ]] && sudo cp /etc/netbird/config.json "$export_dir/vpn/netbird/" 2>/dev/null
|
||||
# State directory (contains machine keys, etc.)
|
||||
if [[ -d /var/lib/netbird ]]; then
|
||||
sudo cp -r /var/lib/netbird "$export_dir/vpn/netbird/state" 2>/dev/null
|
||||
fi
|
||||
# Also check for user config
|
||||
[[ -d "$KIOSK_HOME/.netbird" ]] && sudo cp -r "$KIOSK_HOME/.netbird" "$export_dir/vpn/netbird/user-config" 2>/dev/null
|
||||
log_success "Netbird config exported"
|
||||
((vpn_count++))
|
||||
fi
|
||||
|
||||
# OpenVPN configs
|
||||
if [[ -d /etc/openvpn ]] && [[ -n "$(ls -A /etc/openvpn 2>/dev/null)" ]]; then
|
||||
mkdir -p "$export_dir/vpn/openvpn"
|
||||
sudo cp -r /etc/openvpn/* "$export_dir/vpn/openvpn/" 2>/dev/null
|
||||
log_success "OpenVPN config exported"
|
||||
((vpn_count++))
|
||||
fi
|
||||
|
||||
# Tailscale - just note if installed (requires re-auth)
|
||||
if command -v tailscale &>/dev/null; then
|
||||
local ts_name=$(tailscale status --json 2>/dev/null | jq -r '.Self.HostName' 2>/dev/null || echo "")
|
||||
echo "tailscale_installed=true" > "$export_dir/vpn/tailscale-info.txt"
|
||||
[[ -n "$ts_name" ]] && echo "hostname=$ts_name" >> "$export_dir/vpn/tailscale-info.txt"
|
||||
log_info "Tailscale installed (requires re-authentication after restore)"
|
||||
((vpn_count++))
|
||||
fi
|
||||
|
||||
[[ $vpn_count -eq 0 ]] && log_info "No VPN configurations found"
|
||||
|
||||
echo "[7/7] Exporting quiet hours config..."
|
||||
if [[ -f /usr/local/bin/kiosk-quiet-start.sh ]]; then
|
||||
sudo cp /usr/local/bin/kiosk-quiet-start.sh "$export_dir/"
|
||||
sudo cp /usr/local/bin/kiosk-quiet-end.sh "$export_dir/" 2>/dev/null
|
||||
# Extract quiet mode from script
|
||||
local qmode=$(grep "^QUIET_MODE=" /usr/local/bin/kiosk-quiet-start.sh 2>/dev/null | cut -d'=' -f2)
|
||||
[[ -n "$qmode" ]] && echo "$qmode" > "$export_dir/quiet-mode.txt"
|
||||
log_success "Quiet hours config exported"
|
||||
fi
|
||||
|
||||
# Create archive
|
||||
local archive_name="kiosk-backup-$(date +%Y%m%d-%H%M%S).tar.gz"
|
||||
local home_dir=$(eval echo ~$SUDO_USER)
|
||||
|
||||
# Fix permissions for tar
|
||||
sudo chmod -R 644 "$export_dir"/* 2>/dev/null
|
||||
sudo chmod -R 755 "$export_dir" 2>/dev/null
|
||||
find "$export_dir" -type d -exec chmod 755 {} \; 2>/dev/null
|
||||
|
||||
tar -czf "$home_dir/$archive_name" -C /tmp "$(basename $export_dir)"
|
||||
sudo rm -rf "$export_dir"
|
||||
|
||||
echo
|
||||
log_success "Settings exported to: $home_dir/$archive_name"
|
||||
echo
|
||||
echo "To transfer this file, use:"
|
||||
echo " scp $USER@$(hostname -I | awk '{print $1}'):$home_dir/$archive_name ."
|
||||
echo
|
||||
local export_file="kiosk-config-$(date +%Y%m%d-%H%M%S).json"
|
||||
sudo -u "$KIOSK_USER" cp "$CONFIG_PATH" "/tmp/$export_file" 2>/dev/null
|
||||
sudo chmod 644 "/tmp/$export_file"
|
||||
log_success "Config exported to /tmp/$export_file"
|
||||
pause
|
||||
}
|
||||
|
||||
import_config() {
|
||||
import_settings() {
|
||||
echo
|
||||
read -r -p "Path to config file: " import_file
|
||||
if [[ -f "$import_file" ]]; then
|
||||
sudo -u "$KIOSK_USER" cp "$import_file" "$CONFIG_PATH"
|
||||
log_success "Config imported"
|
||||
else
|
||||
log_error "File not found"
|
||||
echo "══════════════════════════════════════════════════════════"
|
||||
echo " IMPORT SETTINGS "
|
||||
echo "══════════════════════════════════════════════════════════"
|
||||
echo
|
||||
echo "This will restore settings from a previous export."
|
||||
echo "Current settings will be OVERWRITTEN."
|
||||
echo
|
||||
|
||||
# List available backups
|
||||
local home_dir=$(eval echo ~$SUDO_USER)
|
||||
local backups=$(ls -1 "$home_dir"/kiosk-backup-*.tar.gz 2>/dev/null | head -10)
|
||||
|
||||
if [[ -n "$backups" ]]; then
|
||||
echo "Found backup files in $home_dir:"
|
||||
echo "$backups" | nl
|
||||
echo
|
||||
fi
|
||||
|
||||
read -r -p "Path to backup file (.tar.gz): " import_file
|
||||
|
||||
if [[ ! -f "$import_file" ]]; then
|
||||
log_error "File not found: $import_file"
|
||||
pause
|
||||
return
|
||||
fi
|
||||
|
||||
echo
|
||||
read -r -p "This will overwrite current settings. Continue? (yes/no): " confirm
|
||||
[[ "$confirm" != "yes" ]] && return
|
||||
|
||||
local import_dir="/tmp/kiosk-import-$$"
|
||||
mkdir -p "$import_dir"
|
||||
|
||||
echo
|
||||
echo "Extracting backup..."
|
||||
tar -xzf "$import_file" -C "$import_dir"
|
||||
|
||||
# Find the extracted directory
|
||||
local backup_dir=$(find "$import_dir" -maxdepth 1 -type d -name "kiosk-backup-*" | head -1)
|
||||
[[ -z "$backup_dir" ]] && backup_dir="$import_dir"
|
||||
|
||||
echo "[1/7] Importing core configuration..."
|
||||
if [[ -f "$backup_dir/config.json" ]]; then
|
||||
sudo -u "$KIOSK_USER" cp "$backup_dir/config.json" "$CONFIG_PATH"
|
||||
sudo chown "$KIOSK_USER:$KIOSK_USER" "$CONFIG_PATH"
|
||||
log_success "Core config restored"
|
||||
fi
|
||||
|
||||
echo "[2/7] Importing schedule timers..."
|
||||
if [[ -d "$backup_dir/timers" ]]; then
|
||||
local timer_count=0
|
||||
for timer_file in "$backup_dir/timers"/*.timer; do
|
||||
[[ -f "$timer_file" ]] || continue
|
||||
local timer_name=$(basename "$timer_file" .timer)
|
||||
sudo cp "$timer_file" /etc/systemd/system/
|
||||
local service_file="${timer_file%.timer}.service"
|
||||
[[ -f "$service_file" ]] && sudo cp "$service_file" /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable "${timer_name}.timer" 2>/dev/null
|
||||
sudo systemctl start "${timer_name}.timer" 2>/dev/null
|
||||
((timer_count++))
|
||||
done
|
||||
[[ $timer_count -gt 0 ]] && log_success "Restored $timer_count schedule timers"
|
||||
fi
|
||||
|
||||
echo "[3/7] Importing Squeezelite config..."
|
||||
if [[ -f "$backup_dir/squeezelite-start.sh" ]]; then
|
||||
sudo cp "$backup_dir/squeezelite-start.sh" /usr/local/bin/
|
||||
sudo chmod +x /usr/local/bin/squeezelite-start.sh
|
||||
log_success "Squeezelite config restored"
|
||||
fi
|
||||
|
||||
echo "[4/7] Importing VNC config..."
|
||||
if [[ -f "$backup_dir/x11vnc.service" ]]; then
|
||||
sudo cp "$backup_dir/x11vnc.service" /etc/systemd/system/
|
||||
if [[ -f "$backup_dir/vnc/passwd" ]]; then
|
||||
sudo mkdir -p "$KIOSK_HOME/.vnc"
|
||||
sudo cp "$backup_dir/vnc/passwd" "$KIOSK_HOME/.vnc/"
|
||||
sudo chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.vnc"
|
||||
fi
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable x11vnc 2>/dev/null
|
||||
log_success "VNC config restored"
|
||||
fi
|
||||
|
||||
echo "[5/7] Importing Easy Asterisk client config..."
|
||||
if [[ -d "$backup_dir/baresip" ]]; then
|
||||
sudo mkdir -p "$KIOSK_HOME/.baresip"
|
||||
sudo cp -r "$backup_dir/baresip/"* "$KIOSK_HOME/.baresip/"
|
||||
sudo chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.baresip"
|
||||
log_success "Easy Asterisk client config restored"
|
||||
fi
|
||||
|
||||
echo "[6/7] Importing VPN configurations..."
|
||||
local vpn_restored=false
|
||||
|
||||
# WireGuard
|
||||
if [[ -d "$backup_dir/vpn/wireguard" ]]; then
|
||||
sudo mkdir -p /etc/wireguard
|
||||
for wg_conf in "$backup_dir/vpn/wireguard"/*.conf; do
|
||||
[[ -f "$wg_conf" ]] || continue
|
||||
local wg_name=$(basename "$wg_conf" .conf)
|
||||
sudo cp "$wg_conf" /etc/wireguard/
|
||||
sudo chmod 600 "/etc/wireguard/${wg_name}.conf"
|
||||
sudo systemctl enable "wg-quick@${wg_name}" 2>/dev/null
|
||||
sudo systemctl start "wg-quick@${wg_name}" 2>/dev/null
|
||||
done
|
||||
log_success "WireGuard config restored"
|
||||
vpn_restored=true
|
||||
fi
|
||||
|
||||
# Netbird
|
||||
if [[ -d "$backup_dir/vpn/netbird" ]]; then
|
||||
# Restore config file
|
||||
if [[ -f "$backup_dir/vpn/netbird/config.json" ]]; then
|
||||
sudo mkdir -p /etc/netbird
|
||||
sudo cp "$backup_dir/vpn/netbird/config.json" /etc/netbird/
|
||||
fi
|
||||
# Restore state directory (contains machine keys)
|
||||
if [[ -d "$backup_dir/vpn/netbird/state" ]]; then
|
||||
sudo cp -r "$backup_dir/vpn/netbird/state" /var/lib/netbird
|
||||
sudo chown -R root:root /var/lib/netbird
|
||||
fi
|
||||
# Restore user config
|
||||
if [[ -d "$backup_dir/vpn/netbird/user-config" ]]; then
|
||||
sudo cp -r "$backup_dir/vpn/netbird/user-config" "$KIOSK_HOME/.netbird"
|
||||
sudo chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.netbird"
|
||||
fi
|
||||
if command -v netbird &>/dev/null; then
|
||||
sudo systemctl enable netbird 2>/dev/null
|
||||
sudo systemctl start netbird 2>/dev/null
|
||||
log_success "Netbird config restored"
|
||||
else
|
||||
log_warning "Netbird config restored but netbird not installed"
|
||||
echo " Install with: curl -fsSL https://pkgs.netbird.io/install.sh | sudo bash"
|
||||
fi
|
||||
vpn_restored=true
|
||||
fi
|
||||
|
||||
# OpenVPN
|
||||
if [[ -d "$backup_dir/vpn/openvpn" ]]; then
|
||||
sudo mkdir -p /etc/openvpn
|
||||
sudo cp -r "$backup_dir/vpn/openvpn/"* /etc/openvpn/
|
||||
log_success "OpenVPN config restored"
|
||||
vpn_restored=true
|
||||
fi
|
||||
|
||||
# Tailscale info
|
||||
if [[ -f "$backup_dir/vpn/tailscale-info.txt" ]]; then
|
||||
if command -v tailscale &>/dev/null; then
|
||||
log_info "Tailscale installed - run 'sudo tailscale up' to reconnect"
|
||||
else
|
||||
log_warning "Tailscale was configured but is not installed"
|
||||
echo " Install with: curl -fsSL https://tailscale.com/install.sh | sh"
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ "$vpn_restored" == "false" ]] && log_info "No VPN configs in backup"
|
||||
|
||||
echo "[7/7] Importing quiet hours config..."
|
||||
if [[ -f "$backup_dir/kiosk-quiet-start.sh" ]]; then
|
||||
sudo cp "$backup_dir/kiosk-quiet-start.sh" /usr/local/bin/
|
||||
sudo chmod +x /usr/local/bin/kiosk-quiet-start.sh
|
||||
[[ -f "$backup_dir/kiosk-quiet-end.sh" ]] && {
|
||||
sudo cp "$backup_dir/kiosk-quiet-end.sh" /usr/local/bin/
|
||||
sudo chmod +x /usr/local/bin/kiosk-quiet-end.sh
|
||||
}
|
||||
log_success "Quiet hours config restored"
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
sudo rm -rf "$import_dir"
|
||||
|
||||
echo
|
||||
log_success "Settings import complete!"
|
||||
echo
|
||||
echo "Restart kiosk to apply changes:"
|
||||
echo " sudo systemctl restart kiosk"
|
||||
echo
|
||||
pause
|
||||
}
|
||||
|
||||
@@ -10459,7 +10772,7 @@ advanced_menu() {
|
||||
echo " ADVANCED OPTIONS "
|
||||
echo "══════════════════════════════════════════════════════════"
|
||||
echo
|
||||
|
||||
|
||||
echo "Options:"
|
||||
echo " 1. Manual Electron Update"
|
||||
echo " 2. System Diagnostics"
|
||||
@@ -10468,11 +10781,13 @@ advanced_menu() {
|
||||
echo " 5. Fix Squeezelite Audio"
|
||||
echo " 6. Factory Reset Config"
|
||||
echo " 7. Virtual Consoles (Ctrl+Alt+F1-F8)"
|
||||
echo " 9. Emergency Hotspot"
|
||||
echo " 10. Network Test"
|
||||
echo " 8. Export All Settings"
|
||||
echo " 9. Import Settings"
|
||||
echo " 10. Emergency Hotspot"
|
||||
echo " 11. Network Test"
|
||||
echo " 0. Return"
|
||||
echo
|
||||
read -r -p "Choose [0-10]: " choice
|
||||
read -r -p "Choose [0-11]: " choice
|
||||
|
||||
case "$choice" in
|
||||
1) manual_electron_update ;;
|
||||
@@ -10482,8 +10797,10 @@ advanced_menu() {
|
||||
5) fix_squeezelite_audio ;;
|
||||
6) factory_reset ;;
|
||||
7) configure_virtual_consoles ;;
|
||||
9) configure_emergency_hotspot ;;
|
||||
10) network_test ;;
|
||||
8) export_settings ;;
|
||||
9) import_settings ;;
|
||||
10) configure_emergency_hotspot ;;
|
||||
11) network_test ;;
|
||||
0) return ;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user