Merge pull request #64 from outis1one/claude/fix-kiosk-issues-qlxTc
Claude/fix kiosk issues qlx tc
This commit is contained in:
+166
-17
@@ -10114,7 +10114,7 @@ export_settings() {
|
||||
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++))
|
||||
timer_count=$((timer_count + 1))
|
||||
fi
|
||||
done
|
||||
[[ $timer_count -gt 0 ]] && log_success "Exported $timer_count schedule timers" || log_info "No schedules configured"
|
||||
@@ -10158,7 +10158,7 @@ export_settings() {
|
||||
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++))
|
||||
vpn_count=$((vpn_count + 1))
|
||||
fi
|
||||
|
||||
# Netbird config and state
|
||||
@@ -10173,7 +10173,7 @@ export_settings() {
|
||||
# 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++))
|
||||
vpn_count=$((vpn_count + 1))
|
||||
fi
|
||||
|
||||
# OpenVPN configs
|
||||
@@ -10181,7 +10181,7 @@ export_settings() {
|
||||
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++))
|
||||
vpn_count=$((vpn_count + 1))
|
||||
fi
|
||||
|
||||
# Tailscale - just note if installed (requires re-auth)
|
||||
@@ -10190,7 +10190,7 @@ export_settings() {
|
||||
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++))
|
||||
vpn_count=$((vpn_count + 1))
|
||||
fi
|
||||
|
||||
[[ $vpn_count -eq 0 ]] && log_info "No VPN configurations found"
|
||||
@@ -10207,21 +10207,33 @@ export_settings() {
|
||||
|
||||
# Create archive
|
||||
local archive_name="kiosk-backup-$(date +%Y%m%d-%H%M%S).tar.gz"
|
||||
local home_dir=$(eval echo ~$SUDO_USER)
|
||||
# Determine home directory - check SUDO_USER first, then USER, then fallback to /tmp
|
||||
local home_dir=""
|
||||
if [[ -n "${SUDO_USER:-}" ]]; then
|
||||
home_dir=$(eval echo "~$SUDO_USER")
|
||||
elif [[ -n "${USER:-}" ]]; then
|
||||
home_dir=$(eval echo "~$USER")
|
||||
else
|
||||
home_dir="/tmp"
|
||||
fi
|
||||
# Validate home_dir exists and is writable
|
||||
if [[ ! -d "$home_dir" ]] || [[ ! -w "$home_dir" ]]; then
|
||||
home_dir="/tmp"
|
||||
fi
|
||||
|
||||
# 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)"
|
||||
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 " scp $(whoami)@$(hostname -I | awk '{print $1}'):$home_dir/$archive_name ."
|
||||
echo
|
||||
pause
|
||||
}
|
||||
@@ -10236,8 +10248,15 @@ import_settings() {
|
||||
echo "Current settings will be OVERWRITTEN."
|
||||
echo
|
||||
|
||||
# List available backups
|
||||
local home_dir=$(eval echo ~$SUDO_USER)
|
||||
# List available backups - determine home directory
|
||||
local home_dir=""
|
||||
if [[ -n "${SUDO_USER:-}" ]]; then
|
||||
home_dir=$(eval echo "~$SUDO_USER")
|
||||
elif [[ -n "${USER:-}" ]]; then
|
||||
home_dir=$(eval echo "~$USER")
|
||||
else
|
||||
home_dir="/tmp"
|
||||
fi
|
||||
local backups=$(ls -1 "$home_dir"/kiosk-backup-*.tar.gz 2>/dev/null | head -10)
|
||||
|
||||
if [[ -n "$backups" ]]; then
|
||||
@@ -10288,7 +10307,7 @@ import_settings() {
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable "${timer_name}.timer" 2>/dev/null
|
||||
sudo systemctl start "${timer_name}.timer" 2>/dev/null
|
||||
((timer_count++))
|
||||
timer_count=$((timer_count + 1))
|
||||
done
|
||||
[[ $timer_count -gt 0 ]] && log_success "Restored $timer_count schedule timers"
|
||||
fi
|
||||
@@ -10410,6 +10429,134 @@ import_settings() {
|
||||
pause
|
||||
}
|
||||
|
||||
upgrade_kiosk() {
|
||||
clear
|
||||
echo "══════════════════════════════════════════════════════════"
|
||||
echo " UPGRADE KIOSK APP (v$SCRIPT_VERSION) "
|
||||
echo "══════════════════════════════════════════════════════════"
|
||||
echo
|
||||
echo "This will upgrade the kiosk application while preserving:"
|
||||
echo " • All your site configurations"
|
||||
echo " • Schedules and timers"
|
||||
echo " • Password settings"
|
||||
echo " • Addon configurations (Squeezelite, VNC, VPN, etc.)"
|
||||
echo
|
||||
echo "Process:"
|
||||
echo " 1. Auto-export all settings"
|
||||
echo " 2. Reinstall application files"
|
||||
echo " 3. Auto-import all settings"
|
||||
echo
|
||||
read -r -p "Continue with upgrade? (yes/no): " confirm
|
||||
[[ "$confirm" != "yes" ]] && return
|
||||
|
||||
local backup_file="/tmp/kiosk-upgrade-backup-$$.tar.gz"
|
||||
|
||||
echo
|
||||
echo "[1/4] Exporting current settings..."
|
||||
|
||||
# Create backup directory
|
||||
local export_dir="/tmp/kiosk-upgrade-export-$$"
|
||||
mkdir -p "$export_dir"
|
||||
|
||||
# Export config
|
||||
[[ -f "$CONFIG_PATH" ]] && sudo cp "$CONFIG_PATH" "$export_dir/config.json"
|
||||
|
||||
# Export timers
|
||||
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
|
||||
[[ -f "/etc/systemd/system/${timer}.timer" ]] && sudo cp "/etc/systemd/system/${timer}.timer" "$export_dir/timers/"
|
||||
[[ -f "/etc/systemd/system/${timer}.service" ]] && sudo cp "/etc/systemd/system/${timer}.service" "$export_dir/timers/"
|
||||
done
|
||||
|
||||
# Export other configs
|
||||
[[ -f /usr/local/bin/squeezelite-start.sh ]] && sudo cp /usr/local/bin/squeezelite-start.sh "$export_dir/"
|
||||
[[ -f /usr/local/bin/kiosk-quiet-start.sh ]] && sudo cp /usr/local/bin/kiosk-quiet-start.sh "$export_dir/"
|
||||
[[ -f /usr/local/bin/kiosk-quiet-end.sh ]] && sudo cp /usr/local/bin/kiosk-quiet-end.sh "$export_dir/"
|
||||
|
||||
# Create backup archive
|
||||
tar -czf "$backup_file" -C /tmp "$(basename "$export_dir")" 2>/dev/null
|
||||
rm -rf "$export_dir"
|
||||
log_success "Settings backed up"
|
||||
|
||||
echo "[2/4] Stopping kiosk and removing app files..."
|
||||
sudo systemctl stop kiosk 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
# Remove app files but NOT the whole directory
|
||||
sudo rm -f "$KIOSK_DIR/main.js"
|
||||
sudo rm -f "$KIOSK_DIR/preload.js"
|
||||
sudo rm -f "$KIOSK_DIR/keyboard.html"
|
||||
sudo rm -f "$KIOSK_DIR/keyboard-button.html"
|
||||
sudo rm -f "$KIOSK_DIR/pause-dialog.html"
|
||||
sudo rm -f "$KIOSK_DIR/pin-entry.html"
|
||||
sudo rm -f "$KIOSK_DIR/inactivity-prompt-extended.html"
|
||||
sudo rm -f "$KIOSK_DIR/lockout.html"
|
||||
sudo rm -rf "$KIOSK_DIR/node_modules"
|
||||
sudo rm -f "$KIOSK_DIR/package-lock.json"
|
||||
|
||||
echo "[3/4] Reinstalling application..."
|
||||
echo
|
||||
echo "The installer will now run. When prompted for configuration,"
|
||||
echo "just press Enter to accept defaults - your settings will be"
|
||||
echo "restored automatically afterward."
|
||||
echo
|
||||
read -r -p "Press Enter to continue..."
|
||||
|
||||
# Run the install - it will detect existing partial install
|
||||
first_time_install
|
||||
|
||||
echo "[4/4] Restoring settings..."
|
||||
|
||||
# Extract and restore
|
||||
local restore_dir="/tmp/kiosk-upgrade-restore-$$"
|
||||
mkdir -p "$restore_dir"
|
||||
tar -xzf "$backup_file" -C "$restore_dir" 2>/dev/null
|
||||
|
||||
local backup_dir=$(find "$restore_dir" -maxdepth 1 -type d -name "kiosk-upgrade-*" | head -1)
|
||||
[[ -z "$backup_dir" ]] && backup_dir="$restore_dir"
|
||||
|
||||
# Restore config
|
||||
if [[ -f "$backup_dir/config.json" ]]; then
|
||||
sudo cp "$backup_dir/config.json" "$CONFIG_PATH"
|
||||
sudo chown "$KIOSK_USER:$KIOSK_USER" "$CONFIG_PATH"
|
||||
log_success "Config restored"
|
||||
fi
|
||||
|
||||
# Restore timers
|
||||
if [[ -d "$backup_dir/timers" ]]; then
|
||||
for timer_file in "$backup_dir/timers"/*.timer; do
|
||||
[[ -f "$timer_file" ]] || continue
|
||||
sudo cp "$timer_file" /etc/systemd/system/
|
||||
done
|
||||
for service_file in "$backup_dir/timers"/*.service; do
|
||||
[[ -f "$service_file" ]] || continue
|
||||
sudo cp "$service_file" /etc/systemd/system/
|
||||
done
|
||||
sudo systemctl daemon-reload
|
||||
log_success "Timers restored"
|
||||
fi
|
||||
|
||||
# Restore other scripts
|
||||
[[ -f "$backup_dir/squeezelite-start.sh" ]] && sudo cp "$backup_dir/squeezelite-start.sh" /usr/local/bin/ && sudo chmod +x /usr/local/bin/squeezelite-start.sh
|
||||
[[ -f "$backup_dir/kiosk-quiet-start.sh" ]] && 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
|
||||
|
||||
# Cleanup
|
||||
rm -rf "$restore_dir" "$backup_file"
|
||||
|
||||
echo
|
||||
echo "Restarting kiosk..."
|
||||
sudo systemctl restart kiosk
|
||||
sleep 3
|
||||
|
||||
if systemctl is-active --quiet kiosk; then
|
||||
log_success "Upgrade complete! Kiosk is running with your settings."
|
||||
else
|
||||
log_warning "Kiosk may not have started. Check: journalctl -u kiosk -n 50"
|
||||
fi
|
||||
pause
|
||||
}
|
||||
|
||||
network_test() {
|
||||
echo
|
||||
echo " ═══ NETWORK TEST ═══"
|
||||
@@ -10504,12 +10651,13 @@ core_menu() {
|
||||
echo " 6. Power/Display/Quiet Hours"
|
||||
echo " 7. Optional Features (Pause/Keyboard)"
|
||||
echo " 8. Password Protection & Lockout"
|
||||
echo " 9. Hidden Site PIN" # <- ADD THIS
|
||||
echo " 10. Full reinstall"
|
||||
echo " 11. Complete uninstall"
|
||||
echo " 9. Hidden Site PIN"
|
||||
echo " 10. Upgrade (preserves settings)"
|
||||
echo " 11. Full reinstall"
|
||||
echo " 12. Complete uninstall"
|
||||
echo " 0. Return"
|
||||
echo
|
||||
read -r -p "Choose [0-11]: " choice # <- UPDATE THIS
|
||||
read -r -p "Choose [0-12]: " choice
|
||||
|
||||
case "$choice" in
|
||||
1) configure_timezone; pause ;;
|
||||
@@ -10521,8 +10669,9 @@ core_menu() {
|
||||
7) load_existing_config; if configure_optional_features; then save_config; fi ;;
|
||||
8) load_existing_config; if configure_password_protection; then save_config; fi ;;
|
||||
9) configure_hidden_site_pin ;;
|
||||
10) full_reinstall ;;
|
||||
11) complete_uninstall; return ;;
|
||||
10) upgrade_kiosk ;;
|
||||
11) full_reinstall ;;
|
||||
12) complete_uninstall; return ;;
|
||||
0) return ;;
|
||||
esac
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user