diff --git a/README.md b/README.md index cb0afa1..264f19a 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,7 @@ The following are some useful commands that you can run from the terminal so you - `astro-rollback-full` => rollback automatically indi and kstars to the previous version - `use-astro-bleeding-edge` => install bleeding edge packages for Kstars and INDI - `use-astro-stable` => install stable packages for Kstars and INDI + - `kstars-watchdog` => starts Kstars and Ekos with the default profile. If the program is closed or crashes, it will restart automatically. If an ekos job file named default.esl is present in the home dir, it will automatically be started. # Connecting via browser (noVNC) By default `AstroArch` will start a hostpot called `AstroArch`, to connect to that WiFi network use the password `astronomy` diff --git a/astroarch_build.sh b/astroarch_build.sh index 8e0caea..7d148d5 100644 --- a/astroarch_build.sh +++ b/astroarch_build.sh @@ -207,6 +207,7 @@ su astronaut -c "ln -snf /usr/share/applications/org.kde.kstars.desktop /home/as su astronaut -c "ln -snf /usr/share/applications/astrodmx_capture.desktop /home/astronaut/Desktop/AstroDMx_capture" su astronaut -c "ln -snf /usr/share/applications/phd2.desktop /home/astronaut/Desktop/PHD2" su astronaut -c "ln -snf /home/astronaut/.astroarch/desktop/update-astroarch.desktop /home/astronaut/Desktop/update-astroarch" +su astronaut -c "ln -snf /home/astronaut/.astroarch/desktop/kstars-watchdog.desktop /home/astronaut/Desktop/kstars-watchdog" su astronaut -c "ln -snf /home/astronaut/.astroarch/desktop/astroarch-tweak-tool.desktop /home/astronaut/Desktop/AstroArch-Tweak-Tool" su astronaut -c "ln -snf /usr/share/astroarch_onboarding/desktop/AstroArch-onboarding.desktop /home/astronaut/Desktop/AstroArch-onboarding" su astronaut -c "cp /usr/share/astroarch_onboarding/desktop/AstroArch-onboarding-x11.desktop /home/astronaut/.config/autostart/AstroArch-onboarding-x11.desktop" @@ -214,6 +215,7 @@ su astronaut -c "cp /usr/share/astroarch_onboarding/desktop/AstroArch-onboarding # Make the icons executable so there will be no ! on the first boot chmod +x /home/astronaut/Desktop/update-astroarch +chmod +x /home/astronaut/Desktop/kstars-watchdog chmod +x /home/astronaut/Desktop/AstroArch-onboarding chmod +x /home/astronaut/Desktop/AstroArch-Tweak-Tool diff --git a/build-astroarch/clear-install-astroarch.sh b/build-astroarch/clear-install-astroarch.sh index 828f45f..80d15b8 100755 --- a/build-astroarch/clear-install-astroarch.sh +++ b/build-astroarch/clear-install-astroarch.sh @@ -6,12 +6,16 @@ rm /astroarch_build_chroot.sh rm /clear-install-astroarch.sh rm /plasmasystemsettings.sh rm /update-astroarch.sh +rm /kstars-watchdog.sh rm /plasmasystemsettings.sh.desktop rm /update-astroarch.sh.desktop +rm /kstars-watchdog.desktop rm /home/astronaut/.cache/update-astroarch.sh +rm /home/astronaut/.cache/kstars-watchdog.sh rm /home/astronaut/.cache/plasmasystemsettings.sh rm /home/astronaut/.config/autostart/plasmasystemsettings.sh.desktop rm /home/astronaut/.config/autostart/update-astroarch.sh.desktop +rm /home/astronaut/.config/autostart/kstars-watchdog.desktop systemctl disable clear-install-astroarch.timer systemctl disable astroarch-onboarding.timer diff --git a/desktop/kstars-watchdog.desktop b/desktop/kstars-watchdog.desktop new file mode 100755 index 0000000..11d03bf --- /dev/null +++ b/desktop/kstars-watchdog.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Comment= +Comment= +Exec=/home/astronaut/.astroarch/scripts/kstars-watchdog.sh +GenericName= +GenericName= +Icon=application-x-shellscript +MimeType= +Name=kstars-watchdog.sh +Path= +StartupNotify=true +Terminal=false +TerminalOptions= +Type=Application +X-KDE-AutostartScript=true +X-KDE-SubstituteUID=false +X-KDE-Username= diff --git a/scripts/kstars-watchdog.sh b/scripts/kstars-watchdog.sh new file mode 100755 index 0000000..e37047e --- /dev/null +++ b/scripts/kstars-watchdog.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# This script starts Kstars then Ekos with the default profile. +# If Kstars is already running, the script will monitor it. +# If an Ekos scheduler job file named default.esl exists in the +# home directory, the telescope is unparked and the scheduler +# job file will be loaded and started. +# If Kstars is closed or crashes, the script will restart it +# automatically. + +SCHEDFILE=/home/astronaut/default.esl # Can be a link to a .esl file located elsewhere or a real file +LOGFILE=/dev/null +# LOGFILE=/home/astronaut/kstars.log +echo $'\n\n\n\n\n' >> $LOGFILE +date >> $LOGFILE + +# Setup X + +export DISPLAY=:0 +XAUTHORITY=`ls /tmp/xauth_* -tr | tail -n1` +xhost +local: >> $LOGFILE 2>&1 + +# Main loop + +while true +do + while true + do + if qdbus org.kde.kstars >> /dev/null 2>&1 + then + break + else + /usr/bin/kstars >> $LOGFILE 2>&1 & + fi + echo ">>> Waiting for Kstars to start..." | tee -a $LOGFILE + sleep 1 + done + + echo ">>> Kstars started successfully." | tee -a $LOGFILE + + CNT=1 + while true + do + qdbus org.kde.kstars /KStars/Ekos org.kde.kstars.Ekos.start >> $LOGFILE 2>&1 && break + sleep 1 + echo ">>> Waiting for ekos availability : attempt "$CNT" of 10..." | tee -a $LOGFILE + CNT=$((CNT+1)) + if (( CNT > 10 )) + then + echo ">>> Too many attempts to start ekos, aborting..." | tee -a $LOGFILE + break + fi + done + sleep 1 + + # Show main Ekos window + qdbus org.kde.kstars /kstars/MainWindow_1/actions/show_ekos trigger + + # At this point, INDI devices are up and running + + # Check if the default scheduler script exists + if [ -f $SCHEDFILE ] + then + echo ">>> $SCHEDFILE found, unparking telescope and starting scheduler job." | tee -a $LOGFILE + # Unpark telescope + qdbus org.kde.kstars /kstars/MainWindow_1/actions/telescope_unpark org.qtproject.Qt.QAction.trigger + + # (Re-)start scheduler jobs + # => load and start scheduler file + qdbus org.kde.kstars /KStars/Ekos/Scheduler loadScheduler $SCHEDFILE >> $LOGFILE 2>&1 + qdbus org.kde.kstars /KStars/Ekos/Scheduler start >> $LOGFILE 2>&1 + fi + + # Watchdog loop, restart everything if Kstars crashes or is closed + echo ">>> Starting watchdog loop..." | tee -a $LOGFILE + while true + do + qdbus org.kde.kstars /KStars/Ekos > /dev/null 2>&1 || break + sleep 1 + done + echo ">>> Kstars has been closed or crashed, restarting in 5 seconds..." | tee -a $LOGFILE + sleep 5 +done