Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@efournie there is only a small gotcha, these commands are listed here cause they are found within zshrc so users can invoke them directly in the terminal. We may need to alias that command in zshrc to invoke your bash script

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am currently trying to port it to python, will probably be much more flexible and make further development easier:
https://github.com/efournie/kstars-watchdog
It's not working 100% yet but should be soon

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The python version seems to work now, use or adapt whichever one you prefer!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you comfortable packaging python stuff? Ideally if you drop a setup.py I can package this directly for archlinux

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, sounds good! I will try to package it, never done it before but it should not be too complicated, especially with a single dependency.
I will first try to let it run one or two nights in order to check for unforeseen problems, just have to wait for a clear now!


# Connecting via browser (noVNC)
By default `AstroArch` will start a hostpot called `AstroArch`, to connect to that WiFi network use the password `astronomy`
Expand Down
2 changes: 2 additions & 0 deletions astroarch_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,15 @@ 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"
su astronaut -c "cp /usr/share/astroarch_onboarding/desktop/AstroArch-onboarding-xrdp.desktop /home/astronaut/.config/autostart/AstroArch-onboarding-xrdp.desktop"

# 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

Expand Down
4 changes: 4 additions & 0 deletions build-astroarch/clear-install-astroarch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions desktop/kstars-watchdog.desktop
Original file line number Diff line number Diff line change
@@ -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=
83 changes: 83 additions & 0 deletions scripts/kstars-watchdog.sh
Original file line number Diff line number Diff line change
@@ -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