Add settings export/import feature for easy backup/restore
- Added export_settings: backs up all config to timestamped .tar.gz - Core config (sites, touch controls, passwords) - Schedule timers (power, display, quiet hours) - Addon configs (Squeezelite, VNC, Easy Asterisk) - Added import_settings: restores from backup file - Lists available backups in home directory - Enables timers and sets permissions automatically - Added to Advanced menu (options 8 and 9) - Bump version to 0.9.9
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,216 @@ 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
|
||||
|
||||
local export_dir="/tmp/kiosk-backup-$(date +%Y%m%d-%H%M%S)"
|
||||
mkdir -p "$export_dir"
|
||||
|
||||
echo "[1/6] 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/6] 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/6] 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/6] 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/6] 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/6] 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 755 "$export_dir" "$export_dir/timers" "$export_dir/vnc" "$export_dir/baresip" 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/6] 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/6] 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/6] 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/6] 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/6] 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/6] 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 +10658,7 @@ advanced_menu() {
|
||||
echo " ADVANCED OPTIONS "
|
||||
echo "══════════════════════════════════════════════════════════"
|
||||
echo
|
||||
|
||||
|
||||
echo "Options:"
|
||||
echo " 1. Manual Electron Update"
|
||||
echo " 2. System Diagnostics"
|
||||
@@ -10468,11 +10667,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 +10683,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