/home/astronaut-kiosk/.config/plasmanotifyrc
+[DoNotDisturb]
+WhenFullscreen=false
+WhenScreensMirrored=false
+EOF"
+
+# Copy the screensaver config, by default it is off
+su astronaut-kiosk -c "cp /home/astronaut/.astroarch/configs/kscreenlockerrc /home/astronaut-kiosk/.config/kscreenlockerrc"
+
+# Adjustment of user rights
+chmod -R 777 /home/astronaut-kiosk
+chown -R astronaut-kiosk:astronaut-kiosk /home/astronaut-kiosk
+
+# Minimal desktop
+ln -snf /home/astronaut/.astroarch/desktop/astroarch-config-kiosk.desktop /home/astronaut-kiosk/Desktop/Astroarch-config-Kiosk
+
+# Allows access to the astronaut group
+chmod -R 770 /home/astronaut
+
# Disable Kwallet by default
su astronaut -c "echo $'[Wallet]\nEnabled=false' > /home/astronaut/.config/kwalletrc"
# Increases the xrdp buffer
-sudo sed -i 's|#tcp_send_buffer_bytes=32768|tcp_send_buffer_bytes= 4194304|g' /etc/xrdp/xrdp.ini
+sed -i 's|#tcp_send_buffer_bytes=32768|tcp_send_buffer_bytes= 4194304|g' /etc/xrdp/xrdp.ini
# Modprobe brcmfmac
bash -c "echo \"options brcmfmac feature_disable=0x282000\" > /etc/modprobe.d/brcmfmac.conf"
diff --git a/configs/.zshrc b/configs/.zshrc
index db8a57b..02c7964 100755
--- a/configs/.zshrc
+++ b/configs/.zshrc
@@ -75,10 +75,21 @@ function astro-rollback-kstars()
rm -rf ~/.rollback/*
}
+function restore-astroarch() {
+ bash "$HOME/.astroarch/scripts/restore-astroarch.sh"
+}
+
+function backup-astroarch() {
+ bash "$HOME/.astroarch/scripts/backup-astroarch.sh"
+}
+
function update-astroarch()
{
+ backup-astroarch &
+ wait $!
+
# Store actual version
- OLD_VER=$(cat /home/$USER/.astroarch.version)
+ OLD_VER=$(cat "/home/$USER/.astroarch/configs/.astroarch.version" | tr -d '[:space:]')
# Store the current commit hash before the pull
cd /home/$USER/.astroarch
@@ -89,18 +100,50 @@ function update-astroarch()
git pull origin main
cd - > /dev/null 2>&1
- NEW_VER=$(cat /home/$USER/.astroarch/configs/.astroarch.version)
+ # Store new version
+ NEW_VER=$(cat "/home/$USER/.astroarch/configs/.astroarch.version" | tr -d '[:space:]')
+
+ # Function convert to integer for comparison
+ function ver_to_int() {
+ local parts=(${(s:.:)1})
+ echo $(( ${parts[1]:-0} * 10000 + ${parts[2]:-0} * 100 + ${parts[3]:-0} ))
+ }
+
+ old_int=$(ver_to_int "$OLD_VER")
+ new_int=$(ver_to_int "$NEW_VER")
+
+ if [[ $old_int -lt $new_int ]]; then
+ local scripts_to_run=($(ls "/home/$USER/.astroarch/scripts/"*.sh | sort -V))
+ success=true
- if [[ "$OLD_VER" != "$NEW_VER" ]]; then
- zsh /home/$USER/.astroarch/scripts/$NEW_VER.sh
- if [[ $? -ne 0 ]]; then
+ for script_path in "${scripts_to_run[@]}"; do
+ local script_name="${${script_path:t}:r}"
+
+ if [[ "$script_name" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ local script_int=$(ver_to_int "$script_name")
+
+ if (( script_int > old_int && script_int <= new_int )); then
+
+ # Apply scripts less than or equal to new astroarch.version
+ zsh "$script_path"
+
+ if [[ $? -ne 0 ]]; then
+ success=false
+ break
+ fi
+ fi
+ fi
+ done
+
+ if [[ "$success" = false ]]; then
# Revert to the commit stored before the pull
cd /home/$USER/.astroarch
git reset --hard "$CURRENT_COMMIT"
cd - > /dev/null 2>&1
notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Update AstroArch' "Script '$SCRIPT_VER' failed. Reverted to previous state."
+ else
+ notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Update AstroArch' 'All scripts applied successfully'
fi
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Update AstroArch' 'All scripts applied successfully'
fi;
# Temporary fix for kde-portal duplicated conf
@@ -199,8 +242,11 @@ function update-astroarch()
local PROCEED_UPDATE=1
# Test : GUI ?
if [[ -n "$DISPLAY" && -z "$SSH_CLIENT" && -z "$SSH_TTY" ]]; then
- kdialog --title "AstroArch Update - Risk of Addiction" \
- --warningyesno "Warning! The following critical packages will have their dependencies changed:\n\n- $list_str\n\nDo you want to proceed the update anyway?"
+ kdialog --title "AstroArch Update - Risk of Addiction" \
+ --warningyesno "Warning! The following critical packages will have their dependencies changed.\nClick “Yes” if you've made a backup.\n \
+ Click “No” to perform another update with a backup.\nFor more information, see the README on GitHub: \n\n \
+ - $list_str\n\nDo you want to proceed the update anyway?"
+
[[ $? -ne 0 ]] && PROCEED_UPDATE=0
else
# Terminal mode no GUI
diff --git a/configs/default-wifi-powersave-off.conf b/configs/default-wifi-powersave-off.conf
new file mode 100644
index 0000000..111af0b
--- /dev/null
+++ b/configs/default-wifi-powersave-off.conf
@@ -0,0 +1,2 @@
+[connection]
+wifi.powersave = 2
diff --git a/configs/kiosk/.xinitrc b/configs/kiosk/.xinitrc
new file mode 100755
index 0000000..6697f48
--- /dev/null
+++ b/configs/kiosk/.xinitrc
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+export DESKTOP_SESSION=plasma
+export XDG_MENU_PREFIX=plasma-
+export KWIN_X11_NO_QUIRKS=1
+export KWIN_X11_FORCE_SOFTWARE_OPENGL=1
+export KWIN_COMPOSE=N
+export KWIN_X11_NO_QUIRKS=1
+
+rm -f $HOME/.cache/menus/*
+rm -f $HOME/.cache/ksycoca6*
+
+# Set preference for X
+xset s off -dpms s noblank
+
+# Start KDE plasma minimal X window Manager + plasmashell
+kwin_x11 &
+KWIN_PID=$!
+plasmashell &
+SHELL_PID=$!
+
+FLAG_FILE="$HOME/.config/kiosk_setup_done"
+
+if [ ! -f "$FLAG_FILE" ]; then
+ /home/astronaut-kiosk/.local/bin/00-init-layout.sh &
+fi
+
+# App monitoring
+watch_apps() {
+ while true; do
+#pgrep -x kstars > /dev/null || kstars &
+#pgrep -x "phd2.bin" > /dev/null || phd2 &
+#pgrep -x xgps > /dev/null || xgps &
+#pgrep -f AstroDMx-Capture > /dev/null || /opt/AstroDMx-Capture/bin/AstroDMx-Capture &
+ sleep 10
+ done
+}
+
+# Launch and/or restart the apps
+#kstars &
+#phd2 &
+#/opt/AstroDMx-Capture/bin/AstroDMx-Capture &
+#xgps &
+
+watch_apps &
+
+wait $KWIN_PID
+kill $WATCH_PID
+kill $SHELL_PID
+exit 0
diff --git a/configs/kiosk/00-init-layout.sh b/configs/kiosk/00-init-layout.sh
new file mode 100755
index 0000000..97f5791
--- /dev/null
+++ b/configs/kiosk/00-init-layout.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+FLAG_FILE="$HOME/.config/kiosk_setup_done"
+
+if [ -f "$FLAG_FILE" ]; then
+ exit 0
+fi
+
+while ! qdbus6 org.kde.plasmashell /PlasmaShell >/dev/null 2>&1; do
+ sleep 0.5
+done
+
+qdbus6 org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '
+// Apply wallpapers
+var allDesktops = desktops();
+for (var i in allDesktops) {
+ allDesktops[i].wallpaperPlugin = "org.kde.image";
+ allDesktops[i].currentConfigGroup = ["Wallpaper", "org.kde.image", "General"];
+ allDesktops[i].writeConfig("Image", "file:///home/astronaut-kiosk/Pictures/wallpapers/astroarch-kiosk.png");
+ allDesktops[i].writeConfig("FillMode", "0");
+}
+
+// Clean panels
+var panels = panels();
+for (var i in panels) {
+ var widgets = panels[i].widgets();
+ for (var j in widgets) {
+
+ // Kickoff favorites
+ if (widgets[j].type === "org.kde.plasma.kickoff") {
+ widgets[j].currentConfigGroup = ["Configuration", "General"];
+ widgets[j].writeConfig("favorites", []);
+ widgets[j].writeConfig("systemFavorites", false);
+ widgets[j].reloadConfig();
+ }
+
+ // Clear task manager launchers
+ if (widgets[j].type === "org.kde.plasma.icontasks") {
+ widgets[j].currentConfigGroup = ["Configuration", "General"];
+ widgets[j].writeConfig("launchers", "");
+ widgets[j].reloadConfig();
+ }
+ }
+}'
+
+kwriteconfig6 --file kscreenlockerrc --group Daemon --key Autolock false
+kwriteconfig6 --file kscreenlockerrc --group Daemon --key Timeout 0
+qdbus6 org.freedesktop.ScreenSaver /ScreenSaver configure
+
+touch "$FLAG_FILE"
diff --git a/configs/kiosk/45-allow-shutdown-xrdp.rules b/configs/kiosk/45-allow-shutdown-xrdp.rules
new file mode 100755
index 0000000..a7ecfad
--- /dev/null
+++ b/configs/kiosk/45-allow-shutdown-xrdp.rules
@@ -0,0 +1,9 @@
+polkit.addRule(function(action, subject) {
+ if ((action.id == "org.freedesktop.login1.reboot" ||
+ action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
+ action.id == "org.freedesktop.login1.power-off" ||
+ action.id == "org.freedesktop.login1.power-off-multiple-sessions") &&
+ (subject.user == "astronaut" || subject.user == "astronaut-kiosk")) {
+ return polkit.Result.YES;
+ }
+});
diff --git a/configs/kiosk/astroarch-kiosk.png b/configs/kiosk/astroarch-kiosk.png
new file mode 100755
index 0000000..8c82cc6
Binary files /dev/null and b/configs/kiosk/astroarch-kiosk.png differ
diff --git a/configs/kiosk/menus/plasma-applications.menu b/configs/kiosk/menus/plasma-applications.menu
new file mode 100755
index 0000000..ce23357
--- /dev/null
+++ b/configs/kiosk/menus/plasma-applications.menu
@@ -0,0 +1,27 @@
+
+
diff --git a/configs/kiosk/startwm.sh b/configs/kiosk/startwm.sh
new file mode 100755
index 0000000..7f0e9a3
--- /dev/null
+++ b/configs/kiosk/startwm.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+CURRENT_USER="${USER:-${LOGNAME}}"
+export XDG_RUNTIME_DIR="/run/user/$(id -u)"
+
+case "${CURRENT_USER}" in
+ astronaut)
+ STATUS="$(systemctl is-active x0vncserver-xrdp.service)"
+ if [ "${STATUS}" = "active" ]; then
+ exit 1
+ else
+ systemctl --user -M astronaut@ enable x0vncserver-xrdp
+ fi
+ systemctl --user -M astronaut@ start x0vncserver-xrdp && exec dbus-run-session -- startplasma-x11
+ ;;
+
+ astronaut-kiosk)
+ exec dbus-run-session -- /home/astronaut-kiosk/.xinitrc
+ ;;
+esac
diff --git a/configs/startwm.sh b/configs/startwm.sh
index c1a1fb0..7f0e9a3 100755
--- a/configs/startwm.sh
+++ b/configs/startwm.sh
@@ -1,9 +1,19 @@
#!/usr/bin/env bash
-STATUS="$(systemctl is-active x0vncserver-xrdp.service)"
-if [ "${STATUS}" = "active" ]; then
- exit 1
-else
- systemctl --user -M astronaut@ enable x0vncserver-xrdp
-fi
+CURRENT_USER="${USER:-${LOGNAME}}"
+export XDG_RUNTIME_DIR="/run/user/$(id -u)"
-systemctl --user -M astronaut@ start x0vncserver-xrdp && exec dbus-run-session -- startplasma-x11
+case "${CURRENT_USER}" in
+ astronaut)
+ STATUS="$(systemctl is-active x0vncserver-xrdp.service)"
+ if [ "${STATUS}" = "active" ]; then
+ exit 1
+ else
+ systemctl --user -M astronaut@ enable x0vncserver-xrdp
+ fi
+ systemctl --user -M astronaut@ start x0vncserver-xrdp && exec dbus-run-session -- startplasma-x11
+ ;;
+
+ astronaut-kiosk)
+ exec dbus-run-session -- /home/astronaut-kiosk/.xinitrc
+ ;;
+esac
diff --git a/desktop/astroarch-config-kiosk.desktop b/desktop/astroarch-config-kiosk.desktop
new file mode 100755
index 0000000..4cf5a18
--- /dev/null
+++ b/desktop/astroarch-config-kiosk.desktop
@@ -0,0 +1,20 @@
+[Desktop Entry]
+Categories=System
+Comment[fr_CH]=Tools for config AstroArch Kiosk
+Comment=Tools for config AstroArch Kiosk
+Encoding=UTF-8
+Exec=/home/astronaut/.astroarch/scripts/astroarch-config-kiosk.sh
+GenericName[fr_CH]=AstroArch config Kiosk
+GenericName=AstroArch config Kiosk
+Icon=/home/astronaut/.astroarch/assets/icons/novnc-192x192.png
+MimeType=
+Name[fr_CH]=AstroArch config Kiosk
+Name=AstroArch config Kiosk
+Path=
+StartupNotify=true
+Terminal=false
+TerminalOptions=
+Type=Application
+Version=1.0
+X-KDE-SubstituteUID=false
+X-KDE-Username=
diff --git a/scripts/2.0.6.sh b/scripts/2.0.6.sh
index ca4582c..264a6bb 100644
--- a/scripts/2.0.6.sh
+++ b/scripts/2.0.6.sh
@@ -15,5 +15,5 @@ sudo sed -i 's|bulk_compression=true|bulk_compression=false|g' /etc/xrdp/xrdp.in
sudo cp /home/astronaut/.astroarch/configs/99-sysctl.conf /etc/sysctl.d
# NetworkManager WiFi Power Saving
-sudo ln -s /home/astronaut/.astroarch/configs/default-wifi-powersave-on.conf /etc/NetworkManager/conf.d
+sudo ln -s /home/astronaut/.astroarch/configs/default-wifi-powersave-off.conf /etc/NetworkManager/conf.d
diff --git a/scripts/2.0.7.sh b/scripts/2.0.7.sh
new file mode 100644
index 0000000..d6548a0
--- /dev/null
+++ b/scripts/2.0.7.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+# Add drift file for chrony
+sudo pacman -Sy rsync --noconfirm
+
diff --git a/scripts/2.0.8.sh b/scripts/2.0.8.sh
new file mode 100644
index 0000000..4b8a193
--- /dev/null
+++ b/scripts/2.0.8.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+## Add the kiosk session ##
+USERNAME="astronaut-kiosk"
+if ! id "$USERNAME" &>/dev/null; then
+# Add user astronaut-kiosk
+sudo useradd -G wheel -m astronaut-kiosk
+echo "astronaut-kiosk:astro" | sudo chpasswd
+sudo usermod -aG uucp,sys,network,power,audio,input,lp,storage,video,users,astronaut astronaut-kiosk
+sudo usermod -aG astronaut-kiosk astronaut
+sudo chmod -R 770 /home/astronaut-kiosk
+sudo -u astronaut-kiosk LC_ALL=C.UTF-8 xdg-user-dirs-update --force
+sudo mkdir -p /home/astronaut-kiosk/.local/{bin,share,state}
+
+# New Xrdp launcher for astronaut and astronaut-kiosk sessions
+sudo cp /home/astronaut/.astroarch/configs/kiosk/45-allow-shutdown-xrdp.rules /etc/polkit-1/rules.d/
+sudo cp /home/astronaut/.astroarch/configs/startwm.sh /home/astronaut-kiosk/
+sudo cp /home/astronaut/.astroarch/configs/kiosk/.xinitrc /home/astronaut-kiosk/
+
+# Copy wallpapers
+sudo -u astronaut-kiosk mkdir -p /home/astronaut-kiosk/Pictures/wallpapers
+sudo cp /home/astronaut/.astroarch/configs/kiosk/astroarch-kiosk.png /home/astronaut-kiosk/Pictures/wallpapers/
+
+# Config plasma
+sudo cp /home/astronaut/.astroarch/configs/kiosk/00-init-layout.sh /home/astronaut-kiosk/.local/bin/
+
+# Add menu
+sudo cp -r /home/astronaut/.astroarch/configs/kiosk/menus /home/astronaut-kiosk/.config/
+
+# Adjusting user rights for group access
+sudo chmod -R 770 /home/astronaut-kiosk
+sudo chown -R astronaut-kiosk:astronaut-kiosk /home/astronaut-kiosk
+sudo chmod -R 770 /home/astronaut
+
+# Minimal desktop
+sudo ln -snf /home/astronaut/.astroarch/desktop/astroarch-config-kiosk.desktop /home/astronaut-kiosk/Desktop/
+
+fi
diff --git a/scripts/astroarch-config-kiosk.sh b/scripts/astroarch-config-kiosk.sh
new file mode 100755
index 0000000..dc5b561
--- /dev/null
+++ b/scripts/astroarch-config-kiosk.sh
@@ -0,0 +1,304 @@
+#!/bin/bash
+
+# File paths
+XINITRC="/home/astronaut-kiosk/.xinitrc"
+MENU_FILE="/home/astronaut-kiosk/.config/menus/plasma-applications.menu"
+
+DESKTOP_DIR="/home/astronaut-kiosk/Desktop"
+
+declare -A DESKTOP_APPS
+DESKTOP_APPS['APPS\["/usr/share/applications/org.kde.kstars.desktop"\]']="/usr/share/applications/org.kde.kstars.desktop|Kstars"
+DESKTOP_APPS['APPS\["/usr/share/applications/phd2.desktop"\]']="/usr/share/applications/phd2.desktop|PHD2"
+DESKTOP_APPS['APPS\["/usr/share/applications/astrodmx_capture.desktop"\]']="/usr/share/applications/astrodmx_capture.desktop|AstroDMx Capture"
+DESKTOP_APPS['APPS\["/usr/share/applications/xgps.desktop"\]']="/usr/share/applications/xgps.desktop|xgps"
+
+desktop_icon_state() {
+ local key="$1"
+ local data="${DESKTOP_APPS[$key]}"
+ [ -z "$data" ] && return 1
+
+ local src="${data%%|*}"
+ local name="${data##*|}"
+ local dest="$DESKTOP_DIR/$name"
+
+ [ -L "$dest" ] && echo "Enabled" || echo "Disabled"
+}
+
+set_desktop_icon() {
+ local state="$1"
+ local key="$2"
+
+ local data="${DESKTOP_APPS[$key]}"
+ [ -z "$data" ] && return 1
+
+ local src="${data%%|*}"
+ local name="${data##*|}"
+ local dest="$DESKTOP_DIR/$name"
+
+ if [ "$state" = "on" ]; then
+ ln -snf "$src" "$dest"
+ else
+ rm -f "$dest"
+ fi
+}
+
+
+# Verify that the files exist
+if [ ! -f "$XINITRC" ]; then
+ kdialog --error "File $XINITRC not found!"
+ exit 1
+fi
+
+if [ ! -f "$MENU_FILE" ]; then
+ kdialog --error "File $MENU_FILE not found!"
+ exit 1
+fi
+
+is_active() {
+ local file="$1"
+ local pattern="$2"
+
+ if [[ -n "${DESKTOP_APPS[$pattern]}" ]]; then
+ desktop_icon_state "$pattern"
+ return
+ fi
+
+ if [[ "$file" == *.menu ]]; then
+ if grep -E "^[[:space:]]*$pattern" "$file" >/dev/null 2>&1; then
+ echo "Enabled"
+ else
+ echo "Disabled"
+ fi
+ else
+ local line=$(grep "$pattern" "$file" 2>/dev/null | head -1)
+ if [ -n "$line" ] && ! echo "$line" | grep -q "^[[:space:]]*#"; then
+ echo "Enabled"
+ else
+ echo "Disabled"
+ fi
+ fi
+}
+
+set_state_bash() {
+ local state="$1"
+ local pattern="$2"
+
+ if [[ -n "${DESKTOP_APPS[$pattern]}" ]]; then
+ set_desktop_icon "$state" "$pattern"
+ return
+ fi
+
+ if [ "$state" = "on" ]; then
+ sed -i "s|^\([[:space:]]*\)#\+\(.*$pattern.*\)|\1\2|g" "$XINITRC"
+ else
+ sed -i "/^[[:space:]]*#/! s|^\([[:space:]]*\)\(.*$pattern.*\)|\1#\2|g" "$XINITRC"
+ fi
+}
+
+set_state_xml() {
+ local state="$1"
+ local pattern="$2"
+
+ if [ "$state" = "on" ]; then
+ sed -i "s||\1|g" "$MENU_FILE"
+ else
+ sed -i "s|^\([[:space:]]*\)\($pattern\)|\1|g" "$MENU_FILE"
+ fi
+}
+
+get_all_states() {
+ # KStars
+ KS_DESK=$(is_active "$XINITRC" 'APPS\["/usr/share/applications/org.kde.kstars.desktop"\]')
+ KS_MENU=$(is_active "$MENU_FILE" "org.kde.kstars.desktop")
+ KS_START=$(is_active "$XINITRC" "kstars &")
+ KS_WATCH=$(is_active "$XINITRC" "pgrep -x kstars")
+
+ # PHD2
+ PH_DESK=$(is_active "$XINITRC" 'APPS\["/usr/share/applications/phd2.desktop"\]')
+ PH_MENU=$(is_active "$MENU_FILE" "phd2.desktop")
+ PH_START=$(is_active "$XINITRC" "phd2 &")
+ PH_WATCH=$(is_active "$XINITRC" 'pgrep -x "phd2.bin"')
+
+ # AstroDMx
+ AD_DESK=$(is_active "$XINITRC" 'APPS\["/usr/share/applications/astrodmx_capture.desktop"\]')
+ AD_MENU=$(is_active "$MENU_FILE" "astrodmx_capture.desktop")
+ AD_START=$(is_active "$XINITRC" "AstroDMx-Capture/bin/AstroDMx-Capture &")
+ AD_WATCH=$(is_active "$XINITRC" "pgrep -f AstroDMx-Capture")
+
+ # xgps
+ XG_DESK=$(is_active "$XINITRC" 'APPS\["/usr/share/applications/xgps.desktop"\]')
+ XG_MENU=$(is_active "$MENU_FILE" "xgps.desktop")
+ XG_START=$(is_active "$XINITRC" "xgps &")
+ XG_WATCH=$(is_active "$XINITRC" "pgrep -x xgps")
+}
+
+show_current_state() {
+ get_all_states
+
+ kdialog --title "Current configuration status" --msgbox "
+╔═══════════════════════════════════════════════════════╗
+║ CURRENT CONFIGURATION
+╠═══════════════════════════════════════════════════════╣
+║
+║ 📦 KStars
+║ • Desktop icon: $KS_DESK
+║ • Applications Menu: $KS_MENU
+║ • Auto launch: $KS_START
+║ • Watchdog: $KS_WATCH
+║═══════════════════════════════════════════════════════╣
+║ 📦 PHD2
+║ • Desktop icon $PH_DESK
+║ • Applications Menu: $PH_MENU
+║ • Auto launch $PH_START
+║ • Watchdog: $PH_WATCH
+║═══════════════════════════════════════════════════════╣
+║ 📦 AstroDMx Capture
+║ • Desktop icon: $AD_DESK
+║ • Applications Menu: $AD_MENU
+║ • Auto launch: $AD_START
+║ • Watchdog: $AD_WATCH
+║═══════════════════════════════════════════════════════╣
+║ 📦 xgps
+║ • Desktop icon: $XG_DESK
+║ • Applications Menu: $XG_MENU
+║ • Auto launch: $XG_START
+║ • Watchdog: $XG_WATCH
+║
+╚═══════════════════════════════════════════════════════╝
+"
+}
+
+configure_element() {
+ local app_name="$1"
+ local desk_pattern_bash="$2"
+ local menu_pattern_xml="$3"
+ local start_pattern_bash="$4"
+ local watch_pattern_bash="$5"
+
+ # Get the current status
+ local desk_state=$(is_active "$XINITRC" "$desk_pattern_bash")
+ local menu_state=$(is_active "$MENU_FILE" "$menu_pattern_xml")
+ local start_state=$(is_active "$XINITRC" "$start_pattern_bash")
+ local watch_state=$(is_active "$XINITRC" "$watch_pattern_bash")
+
+ # Create options for radiolist
+ local desk_current="off"; [ "$desk_state" = "Enabled" ] && desk_current="on"
+ local menu_current="off"; [ "$menu_state" = "Enabled" ] && menu_current="on"
+ local start_current="off"; [ "$start_state" = "Enabled" ] && start_current="on"
+ local watch_current="off"; [ "$watch_state" = "Enabled" ] && watch_current="on"
+
+ # Interface for configuration
+ RESULT=$(kdialog --title "Configuration of $app_name" \
+ --separate-output \
+ --checklist "Current status and configuration :" \
+ "desk" "Desktop icon (currently: $desk_state)" $desk_current \
+ "menu" "Applications menu (currently: $menu_state)" $menu_current \
+ "start" "Automatic launch (currently: $start_state)" $start_current \
+ "watch" "Watchdog - Auto restart (currently: $watch_state)" $watch_current)
+
+ if [ $? -ne 0 ]; then
+ return
+ fi
+
+ if echo "$RESULT" | grep -q "^desk$"; then
+ set_state_bash "on" "$desk_pattern_bash"
+ else
+ set_state_bash "off" "$desk_pattern_bash"
+ fi
+
+ if echo "$RESULT" | grep -q "^menu$"; then
+ set_state_xml "on" "$menu_pattern_xml"
+ else
+ set_state_xml "off" "$menu_pattern_xml"
+ fi
+
+ if echo "$RESULT" | grep -q "^start$"; then
+ set_state_bash "on" "$start_pattern_bash"
+ else
+ set_state_bash "off" "$start_pattern_bash"
+ fi
+
+ if echo "$RESULT" | grep -q "^watch$"; then
+ set_state_bash "on" "$watch_pattern_bash"
+ else
+ set_state_bash "off" "$watch_pattern_bash"
+ fi
+
+ kdialog --msgbox "$app_name configuration updated!"
+}
+
+while true; do
+ CHOICE=$(kdialog --title "AstroArch Kiosk Configuration" \
+ --menu "What do you want to do?" \
+ "state" "📊 Display the current configuration status" \
+ "kstars" "⭐ Configure KStars" \
+ "phd2" "🔭 Configure PHD2" \
+ "astrodmx" "📷 Configure AstroDMx Capture" \
+ "xgps" "🛰️ Configure xgps" \
+ "astromonitor" "🌠 Retrieve your kstars configuration" \
+ "backup" "💾 Create a manual backup" \
+ "rebuild" "🔄 Rebuild the menu cache" \
+ "quit" "❌ Exit")
+
+ if [ $? -ne 0 ] || [ "$CHOICE" = "quit" ]; then
+ break
+ fi
+
+ case "$CHOICE" in
+ state)
+ show_current_state
+ ;;
+ kstars)
+ configure_element "KStars" \
+ 'APPS\["/usr/share/applications/org.kde.kstars.desktop"\]' \
+ "org.kde.kstars.desktop" \
+ "kstars &" \
+ "pgrep -x kstars"
+ ;;
+ phd2)
+ configure_element "PHD2" \
+ 'APPS\["/usr/share/applications/phd2.desktop"\]' \
+ "phd2.desktop" \
+ "phd2 &" \
+ 'pgrep -x "phd2.bin"'
+ ;;
+ astrodmx)
+ configure_element "AstroDMx Capture" \
+ 'APPS\["/usr/share/applications/astrodmx_capture.desktop"\]' \
+ "astrodmx_capture.desktop" \
+ "AstroDMx-Capture/bin/AstroDMx-Capture &" \
+ "pgrep -f AstroDMx-Capture"
+ ;;
+ xgps)
+ configure_element "xgps" \
+ 'APPS\["/usr/share/applications/xgps.desktop"\]' \
+ "xgps.desktop" \
+ "xgps &" \
+ "pgrep -x xgps"
+ ;;
+ astromonitor)
+ key=$(kdialog --title "astromonitor key" --inputbox "Enter your astromonitor key:")
+ password=$(kdialog --title "astromonitor key" --password "Enter the password")
+ echo password || sudo -u astronaut-kiosk astromonitor --retrieve-backup
+ if [ $? = 0 ]; then
+ kdialog --msgbox "Kstars backup successful"
+ else
+ kdialog --error "Kstars backup failed"
+ fi
+ ;;
+ backup)
+ TIMESTAMP=$(date +%Y%m%d_%H%M%S)
+ cp "$XINITRC" "${XINITRC}.backup.${TIMESTAMP}"
+ cp "$MENU_FILE" "${MENU_FILE}.backup.${TIMESTAMP}"
+ kdialog --msgbox "Backup created successfully !\n\nTimestamp: $TIMESTAMP"
+ ;;
+ rebuild)
+ kbuildsycoca6 > /dev/null 2>&1
+ kdialog --msgbox "Menu cache rebuilt!\n\nRestart the session to see the changes"
+ ;;
+ esac
+done
+
+# Message de sortie
+kdialog --msgbox "Restart the session now to apply the changes"
+
diff --git a/scripts/astroarch-tweak-tool.zsh b/scripts/astroarch-tweak-tool.zsh
index e22c7c7..775bb9e 100755
--- a/scripts/astroarch-tweak-tool.zsh
+++ b/scripts/astroarch-tweak-tool.zsh
@@ -1,13 +1,13 @@
#!/bin/zsh
-result=$(kdialog --menu "Select action" 1 "Update-astroarch" 2 "Set GPS" 3 "Set Bluetooth" 4 "Set FTP" 5 "Rollback Kstars/Indi" 6 "Install Kstars/Indi stable/bleeding-edge" --title "AstroArch Tweak Tool")
+result=$(kdialog --menu "Select action" 1 "Update-astroarch" 2 "Set GPS" 3 "Set Bluetooth" 4 "Set FTP" 5 "Rollback Kstars/Indi" 6 "Install Kstars/Indi stable/bleeding-edge" 7 "Backup/Restore astroarch" --title "AstroArch Tweak Tool")
source ~/.zshrc
case $result in
1)
update-astroarch
if [ $? -eq 0 ] ; then
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Update AstroArch' 'Update completed'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Update AstroArch' 'Update completed'
else
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Update AstroArch' 'Update returns an error'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Update AstroArch' 'Update returns an error'
fi
;;
2)
@@ -49,25 +49,25 @@ case $result in
Full-Kstars-Indi)
astro-rollback-full
if [ $? -eq 0 ] ; then
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback full' 'Completed'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback full' 'Completed'
else
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback full' 'Returns an error'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback full' 'Returns an error'
fi
;;
Indi)
astro-rollback-indi
if [ $? -eq 0 ] ; then
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback indi' 'Completed'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback indi' 'Completed'
else
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback indi' 'Returns an error'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback indi' 'Returns an error'
fi
;;
Kstars)
astro-rollback-kstars
if [ $? -eq 0 ] ; then
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback kstars' 'Completed'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback kstars' 'Completed'
else
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback kstars' 'Returns an error'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Rollback kstars' 'Returns an error'
fi
;;
esac
@@ -75,20 +75,41 @@ case $result in
6)
install_kstars=$(kdialog --combobox " Select the Kstars installation version" "Bleeding-edge" "Stable" --title "AstroArch Install Kstars")
case $install_kstars in
- Bleeding-edg)
+ Bleeding-edge)
use-astro-bleeding-edge
if [ $? -eq 0 ] ; then
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Installation Kstars bleeding-edge' 'Completed'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Installation Kstars bleeding-edge' 'Completed'
else
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Installation Kstars bleeding-edge' 'Returns an error'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Installation Kstars bleeding-edge' 'Returns an error'
fi
;;
Stable)
use-astro-stable
if [ $? -eq 0 ] ; then
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Installation Kstars' 'Completed'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Installation Kstars' 'Completed'
else
- notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Installation Kstars' 'Returns an error'
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Installation Kstars' 'Returns an error'
+ fi
+ ;;
+ esac
+ ;;
+ 7)
+ backup_astroarch=$(kdialog --combobox " Select backup / restore" "Backup" "Restore" --title "AstroArch Backup / Restore")
+ case $backup_astroarch in
+ Backup)
+ backup-astroarch
+ if [ $? -eq 0 ] ; then
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Backup' 'Completed'
+ else
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Backup' 'Returns an error'
+ fi
+ ;;
+ Restore)
+ restore-astroarch
+ if [ $? -eq 0 ] ; then
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Restore' 'Completed'
+ else
+ notify-send --app-name 'AstroArch' --icon="/$HOME/.astroarch/assets/icons/novnc-icon.svg" -t 10000 'Restore' 'Returns an error'
fi
;;
esac
diff --git a/scripts/backup-astroarch.sh b/scripts/backup-astroarch.sh
new file mode 100755
index 0000000..359223e
--- /dev/null
+++ b/scripts/backup-astroarch.sh
@@ -0,0 +1,197 @@
+#!/bin/bash
+
+# --- 1. INITIALIZATION ---
+CONFIG_FILE="$HOME/.backup_dest"
+DEFAULT_DEST="$HOME/backup"
+
+# Detect GUI or SSH session
+is_gui() { [[ -n "$DISPLAY" && -z "$SSH_CLIENT" ]]; }
+
+# Update specific keys in the config file
+update_config() { sed -i "s|^$1=.*|$1=\"$2\"|" "$CONFIG_FILE"; }
+
+# --- NOUVELLE FONCTION DE NETTOYAGE ---
+cleanup_canceled_backup() {
+ local DEST="$1"
+ # Supprime le dossier corrompu (nécessite sudo car rsync préserve les permissions root)
+ if [ -d "$DEST" ]; then
+ sudo rm -rf "$DEST"
+ fi
+ # Supprime le fichier config pour forcer une réinitialisation propre au prochain lancement
+ rm -f "$CONFIG_FILE"
+
+ MSG="⚠️ Backup canceled. Destination folder and config removed to prevent corruption."
+ if is_gui; then
+ kdialog --title "Backup Aborted" --msgbox "$MSG"
+ else
+ echo -e "\e[31m$MSG\e[0m"
+ fi
+ exit 0
+}
+
+# ADAPTIVE CONFIRMATION FUNCTION
+ask_confirmation() {
+ local QUESTION="$1"
+ if is_gui; then
+ CHOICE=$(kdialog --combobox "$QUESTION" "Yes" "Yes, do not ask again" "No" "No, do not ask again" --default "Yes")
+ case "$CHOICE" in
+ "Yes, do not ask again") update_config "AUTO_CHOICE" "Yes"; AUTO_CHOICE="Yes" ;;
+ "No") exit 0 ;;
+ "No, do not ask again") update_config "AUTO_CHOICE" "Never"; exit 0 ;;
+ "Yes") ;; # Continue
+ *) exit 0 ;;
+ esac
+ else
+ read -p "$QUESTION (y/n) " r; [[ ! "$r" =~ ^[Yy]$ ]] && exit 0
+ fi
+}
+
+if [ ! -f "$CONFIG_FILE" ]; then
+ # FIRST TIME INSTALLATION
+ if is_gui; then
+ kdialog --title "Backup Assistant" --msgbox "
+
+ This is your first backup
+ Please select a folder. If the folder location does not have enough space, you will be asked to choose a different location.
+ Note: If the location is on the same drive, a minimum of 64 GB is required.
+
+ You can choose from several options:
+
+ - Perform a backup: (Yes)
+ - Set up automatic backups: (Yes, do not ask again)
+ - Do not perform: (No)
+ - Cancel permanently: (No, do not ask again)
+
+
+ To change default settings, edit: \$HOME/.backup_dest and set AUTO_CHOICE=\"ask\"
+ Please note: if you cancel the backup while it is in progress, the backup folder and the configuration file will be deleted
+ The backup will take some time...
+ " 600 500
+
+ DEST_PATH=$(kdialog --inputbox "First backup. Choose storage location:" "$DEFAULT_DEST")
+ else
+ read -p "First installation. Location [$DEFAULT_DEST]: " DEST_PATH
+ fi
+ [ -z "$DEST_PATH" ] && DEST_PATH="$DEFAULT_DEST"
+
+ mkdir -p "$DEST_PATH" 2>/dev/null
+ FIRST_BACKUP="yes"
+ AUTO_CHOICE="Ask"
+
+ cat << EOF > "$CONFIG_FILE"
+DEST_PATH="$DEST_PATH"
+FIRST_BACKUP="$FIRST_BACKUP"
+AUTO_CHOICE="$AUTO_CHOICE"
+EOF
+else
+ # EXISTING CONFIGURATION
+ source "$CONFIG_FILE"
+
+ # --- CASE: MISSING DIRECTORY ---
+ if [ ! -d "$DEST_PATH" ]; then
+ if is_gui; then
+ kdialog --title "Destination Missing" --warningcontinuecancel "The location \"$DEST_PATH\" was not found." --continue-label "Change location" --cancel-label "Quit" || exit 0
+ DEST_PATH=$(kdialog --inputbox "New location:" "$DEST_PATH")
+ [ -z "$DEST_PATH" ] && exit 0
+ ask_confirmation "Directory changed. Choose confirmation mode:"
+ else
+ echo "⚠️ The location \"$DEST_PATH\" was not found."
+ read -p "New path (or Enter to quit): " DEST_PATH
+ [ -z "$DEST_PATH" ] && exit 0
+ ask_confirmation "New confirmation mode:"
+ fi
+
+ mkdir -p "$DEST_PATH" 2>/dev/null
+ update_config "DEST_PATH" "$DEST_PATH"
+ update_config "AUTO_CHOICE" "$AUTO_CHOICE"
+ SKIP_FINAL_PROMPT="true"
+ fi
+fi
+
+# --- 2. AUTHENTICATION ---
+if ! sudo -n true 2>/dev/null; then
+ if is_gui; then
+ PASS=$(kdialog --title "Authentication" --password "Enter your user password:")
+ [ -z "$PASS" ] && exit 1
+ echo "$PASS" | sudo -S -v &>/dev/null
+ [ $? -ne 0 ] && kdialog --error "Incorrect password." && exit 1
+ unset PASS
+ else
+ sudo -v || exit 1
+ fi
+fi
+( while true; do sudo -n -v; sleep 60; kill -0 "$$" || exit; done 2>/dev/null ) &
+
+# --- 3. DISK SPACE VALIDATION LOOP ---
+VALID_SPACE=false
+while [ "$VALID_SPACE" = false ]; do
+ mkdir -p "$DEST_PATH" 2>/dev/null
+ ABS_DEST=$(realpath "$DEST_PATH")
+ EXCLUSIONS=(--exclude='/dev/*' --exclude='/proc/*' --exclude='/sys/*' --exclude='/tmp/*' --exclude='/run/*' --exclude='/mnt/*' --exclude='/media/*' --exclude='/lost+found/' --exclude='/boot/*' --exclude='*/thinclient_drives' --exclude='*/.gvfs' --exclude="$ABS_DEST")
+
+ echo "Analyzing space on $ABS_DEST..."
+ ROOT_SIZE=$(sudo -n rsync -aAXHvx --delete --dry-run --stats "${EXCLUSIONS[@]}" / "$ABS_DEST" | grep "Total transferred file size" | awk '{print $5}' | tr -d ',')
+ [ -z "$ROOT_SIZE" ] && ROOT_SIZE=0
+ AVAILABLE_SIZE=$(df -B1 "$ABS_DEST" | tail -1 | awk '{print $4}')
+
+ TRANS_HUMAN=$(numfmt --to=iec-i --suffix=B $ROOT_SIZE)
+ AVAIL_HUMAN=$(numfmt --to=iec-i --suffix=B $AVAILABLE_SIZE)
+
+ if [ "$AVAILABLE_SIZE" -lt "$ROOT_SIZE" ]; then
+ MSG_ERR="⚠️ Insufficient space on $ABS_DEST !\nRequired: $TRANS_HUMAN\nFree: $AVAIL_HUMAN"
+ if is_gui; then
+ kdialog --title "Insufficient Space" --warningcontinuecancel "$MSG_ERR" --continue-label "Change destination" --cancel-label "Abort" || exit 0
+ DEST_PATH=$(kdialog --inputbox "New location:" "$DEFAULT_DEST")
+ [ -z "$DEST_PATH" ] && exit 0
+ else
+ echo -e "$MSG_ERR"
+ read -p "New path (or Enter to quit): " DEST_PATH
+ [ -z "$DEST_PATH" ] && exit 0
+ fi
+ update_config "DEST_PATH" "$DEST_PATH"
+ else
+ VALID_SPACE=true
+ fi
+done
+
+# --- 4. FIRST BACKUP LOGIC AND CHOICE ---
+if [ "$(ls -A "$ABS_DEST" 2>/dev/null)" ]; then
+ [[ "$FIRST_BACKUP" == "yes" ]] && update_config "FIRST_BACKUP" "no" && FIRST_BACKUP="no"
+else
+ [[ "$FIRST_BACKUP" == "no" ]] && update_config "FIRST_BACKUP" "yes" && FIRST_BACKUP="yes"
+fi
+
+[[ "$AUTO_CHOICE" == "Never" ]] && exit 0
+if [[ "$AUTO_CHOICE" == "Ask" && "$SKIP_FINAL_PROMPT" != "true" ]]; then
+ ask_confirmation "Start backup?"
+fi
+
+if [[ "$FIRST_BACKUP" == "yes" ]]; then
+ MSG="Note: First full backup to $ABS_DEST ($TRANS_HUMAN)."
+ if is_gui; then kdialog --msgbox "$MSG"; else echo -e "$MSG"; fi
+fi
+
+# --- 5. EXECUTION ---
+if is_gui; then
+ dbus_ref=$(kdialog --progressbar "Initializing backup..." 100)
+ sudo -n rsync -aAXHxh --delete --no-inc-recursive --info=progress2 "${EXCLUSIONS[@]}" / "$ABS_DEST" 2>/dev/null | \
+ stdbuf -oL tr '\r' '\n' | grep --line-buffered -oP '[0-9]+(?=%)' | \
+ while read -r percent; do
+ ((count++))
+ if (( count % 5 == 0 )); then
+ # SI ANNULÉ PAR L'UTILISATEUR
+ if ! qdbus6 $dbus_ref >/dev/null 2>&1; then
+ sudo pkill -f "rsync.*$ABS_DEST"
+ cleanup_canceled_backup "$ABS_DEST"
+ fi
+ qdbus6 $dbus_ref setLabelText "Copying: $percent% of $TRANS_HUMAN"
+ qdbus6 $dbus_ref Set "" value "$percent"
+ fi
+ done
+ qdbus6 $dbus_ref close 2>/dev/null
+ notify-send --app-name 'AstroArch' --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" -t 10000 "✅ Backup completed."
+else
+ sudo -n rsync -aAXHxh --delete --no-inc-recursive --info=progress2 "${EXCLUSIONS[@]}" / "$ABS_DEST"
+fi
+
+update_config "FIRST_BACKUP" "no"
diff --git a/scripts/create_ap.sh b/scripts/create_ap.sh
index 3a8ecd1..d3356c6 100755
--- a/scripts/create_ap.sh
+++ b/scripts/create_ap.sh
@@ -1,11 +1,30 @@
#!/bin/bash
+RESET_BRCMFMAC="/home/astronaut/.astroarch/scripts/reset-brcmfmac.sh"
CONN_NAME=astroarch-hotspot
SSID=$(tr -dc A-Za-z0-9 /dev/null
+
+# Delete ALL hotspot connections
+for uuid in $(nmcli -g UUID,NAME connection show | grep "$CONN_NAME" | cut -d: -f1); do
+ nmcli connection delete uuid "$uuid"
+done
+
+rfkill unblock all
+modprobe -r brcmfmac_wcc 2>/dev/null
+modprobe -r brcmfmac 2>/dev/null
+sleep 2
+modprobe brcmfmac
+sleep 2
+
+# Restarting services
+systemctl start wpa_supplicant
+systemctl start NetworkManager
+systemctl start x0vncserver
+sleep 3
+
reboot
diff --git a/scripts/restore-astroarch.sh b/scripts/restore-astroarch.sh
new file mode 100755
index 0000000..d7cca3b
--- /dev/null
+++ b/scripts/restore-astroarch.sh
@@ -0,0 +1,125 @@
+#!/bin/bash
+
+# --- 1. CONFIGURATION AND TESTS ---
+CONFIG_FILE="$HOME/.backup_dest"
+
+is_gui() {
+ [[ -n "$DISPLAY" && -z "$SSH_CLIENT" && -z "$SSH_TTY" ]]
+}
+
+# Fix for xRDP/Sudo MIT-MAGIC-COOKIE
+if is_gui; then
+ xhost +local:root > /dev/null 2>&1
+ export XAUTHORITY=$HOME/.Xauthority
+fi
+
+# Function to ask for a new path
+ask_new_path() {
+ local REASON="$1"
+ if is_gui; then
+ DEST_PATH=$(kdialog --getexistingdirectory "$HOME" --title "$REASON - Choose backup folder:")
+ else
+ echo -e "\e[33m⚠️ $REASON\e[0m"
+ read -p "Enter backup folder path: " DEST_PATH
+ fi
+
+ if [ -n "$DEST_PATH" ]; then
+ echo "DEST_PATH=\"$DEST_PATH\"" > "$CONFIG_FILE"
+ echo "FIRST_BACKUP=\"no\"" >> "$CONFIG_FILE"
+ echo "AUTO_CHOICE=\"Ask\"" >> "$CONFIG_FILE"
+ else
+ exit 1
+ fi
+}
+
+# Check config and path
+if [ ! -f "$CONFIG_FILE" ]; then
+ ask_new_path "Configuration file missing"
+else
+ source "$CONFIG_FILE"
+ if [ ! -d "$DEST_PATH" ]; then
+ ask_new_path "Saved destination not found"
+ fi
+fi
+
+ABS_DEST=$(realpath "$DEST_PATH")
+
+# --- 2. CONFIRMATIONS ---
+if is_gui; then
+ kdialog --warningcontinuecancel "WARNING: System restore will overwrite EVERYTHING from: $ABS_DEST\n\nProceed?" --title "System Restore" || exit 0
+else
+ echo -e "\e[31m⚠️ WARNING: System restore from $ABS_DEST. This will overwrite EVERYTHING.\e[0m"
+ read -p "Continue? (y/N): " res; [[ ! "$res" =~ ^[yY]$ ]] && exit 0
+fi
+
+# --- 3. AUTHENTICATION ---
+if ! sudo -n true 2>/dev/null; then
+ if is_gui; then
+ PASS=$(kdialog --title "Authentication" --password "Enter password:")
+ [ -z "$PASS" ] && exit 1
+ echo "$PASS" | sudo -S -v &>/dev/null
+ [ $? -ne 0 ] && kdialog --error "Incorrect password." && exit 1
+ unset PASS
+ else
+ sudo -v || exit 1
+ fi
+fi
+( while true; do sudo -n -v; sleep 60; kill -0 "$$" || exit; done 2>/dev/null ) &
+
+# --- 4. EXECUTION ---
+EXCLUSIONS=(--exclude='/dev/*' --exclude='/proc/*' --exclude='/sys/*' --exclude='/tmp/*' --exclude='/run/*' --exclude='/mnt/*' --exclude='/media/*' --exclude='/lost+found/' --exclude='/boot/*' --exclude='*/thinclient_drives' --exclude='*/.gvfs' --exclude="$ABS_DEST")
+
+if is_gui; then
+ # --- MÉTHODE DBUS POUR KDE ---
+ # On envoie la notification via gdbus pour récupérer son ID numérique unique
+ NOTIFY_ID=$(gdbus call --session --dest org.freedesktop.Notifications \
+ --object-path /org/freedesktop/Notifications \
+ --method org.freedesktop.Notifications.Notify \
+ "AstroArch" 0 "/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" \
+ "System Restore" "Restoration in progress... DO NOT interrupt." \
+ [] '{"urgency": }' 0 | sed 's/(uint32 \([0-9]*\),)/\1/')
+
+ # Execute rsync (bloquant)
+ sudo rsync -aAXxh -x --delete "${EXCLUSIONS[@]}" "$ABS_DEST/" /
+ RSYNC_RESULT=$?
+
+ # FERMETURE FORCÉE via l'ID récupéré
+ if [ -n "$NOTIFY_ID" ]; then
+ gdbus call --session --dest org.freedesktop.Notifications \
+ --object-path /org/freedesktop/Notifications \
+ --method org.freedesktop.Notifications.CloseNotification "$NOTIFY_ID" >/dev/null
+ fi
+
+ if [ $RSYNC_RESULT -eq 0 ]; then
+ # SUCCESS
+ for i in {10..1}; do
+ notify-send "Restore Complete" "✅ Finished. Rebooting in $i seconds..." \
+ --icon="/home/astronaut/.astroarch/assets/icons/novnc-icon.svg" \
+ -t 1000 --hint=int:transient:1
+ sleep 1
+ done
+ #sudo reboot
+ else
+ # ERROR
+ notify-send "Restore FAILED" "❌ Error code: $RSYNC_RESULT." --icon="dialog-error" --urgency=critical -t 0
+ kdialog --error "Restoration failed."
+ exit 1
+ fi
+else
+ # CONSOLE MODE
+ echo -e "\e[32m🚀 Restoration in progress...\e[0m"
+ sudo rsync -aAXxh -x --delete --info=progress2 "${EXCLUSIONS[@]}" "$ABS_DEST/" /
+ RSYNC_RESULT=$?
+
+ if [ $RSYNC_RESULT -eq 0 ]; then
+ echo -e "\n\e[32m✅ Restore complete.\e[0m"
+ for i in {10..1}; do
+ echo -ne "Rebooting in $i seconds... \r"
+ sleep 1
+ done
+ #sudo reboot
+ else
+ echo -e "\n\e[31m❌ ERROR: Restoration failed.\e[0m"
+ exit 1
+ fi
+fi
diff --git a/systemd/create_ap.service b/systemd/create_ap.service
index 30b3670..732b758 100644
--- a/systemd/create_ap.service
+++ b/systemd/create_ap.service
@@ -1,12 +1,14 @@
[Unit]
Description=Create an AP with a semi random name
-After=NetworkManager-wait-online.service
-Wants=NetworkManager-wait-online.service
+After=systemd-networkd-wait-online.service
+Wants=systemd-networkd-wait-online.service
+Requires=NetworkManager-wait-online.service
[Service]
ExecStart=/bin/bash /home/astronaut/.astroarch/scripts/create_ap.sh
ExecStop=/bin/systemctl disable create_ap.service
Type=oneshot
+RemainAfterExit=yes
[Install]
-WantedBy=multi-user.target
\ No newline at end of file
+WantedBy=multi-user.target