Skip to content

Instantly share code, notes, and snippets.

@rickbassham
Last active June 20, 2024 06:42
Show Gist options
  • Save rickbassham/61d3b02ce959d7ea07664b05656a7125 to your computer and use it in GitHub Desktop.
Save rickbassham/61d3b02ce959d7ea07664b05656a7125 to your computer and use it in GitHub Desktop.
Step by Step Instructions to create an Open Source Astro-Imaging Computer

Instructions (works on amd64 and arm64)

A copy/paste guide to getting a full working astro-imaging computer running on Ubuntu 20.04 LTS. Installs latest stable versions of gpsd, KStars, INDI, OACapture, SkyChart, ASTAP, and Astrometry.net.

It uses the lightweight XFCE4 desktop, and allows you to VNC in, running everything locally on the astro-imaging pc.

Install Ubuntu Server 20.04.1

PC (amd64)

https://releases.ubuntu.com/20.04/

Raspberry Pi (arm64)

https://ubuntu.com/download/raspberry-pi

All commands below are to be run on the astro pc unless otherwise noted.

Set Hostname

Set Hostname (only needed on Raspberry Pi)

The raspberry pi ubuntu distro ships with a default hostname of ubuntu. You will probably want to change it. You will probably want to change astrobuntupi-dev to something more meaningful for you.

sudo hostnamectl set-hostname astrobuntupi-dev
sudo reboot

If you want to change the default ubuntu user name, now is the time.

Enable ssh with no password

Not required, but nice to have. Uses your public key to authenticate so you do not need to type your password when you ssh. Replace astrobuntupi-dev with the hostname you set above.

# from remote pc, not the astro-imaging pc
cat ~/.ssh/id_rsa.pub | ssh ubuntu@astrobuntupi-dev 'mkdir -p .ssh && cat >> .ssh/authorized_keys'

Install screen

screen will keep your ssh session running even if you get disconnected.

sudo apt install screen
# auto start screen when you ssh
echo 'if $(screen -ls | grep -q pts); then  screen -x; else screen -R; fi' >> ~/.bash_profile
exit

Configure WiFi

https://linuxconfig.org/ubuntu-20-04-connect-to-wifi-from-command-line

Set Your Timezone

sudo dpkg-reconfigure tzdata

Disable Automatic Upgrades

Ubuntu by default will automatically run apt upgrade periodically for new stable updates. To keep a good working configuration and prevent updates in the middle of imaging, run:

sudo dpkg-reconfigure unattended-upgrades

Install xfce4 and tightvncserver

sudo apt install xubuntu-core^
sudo apt install tightvncserver

Setup tightvncserver

vncserver
vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
cat << EOF > ~/.vnc/xstartup
#!/bin/bash
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

xhost +
xrdb $HOME/.Xresources
startxfce4 &
EOF

chmod +x ~/.vnc/xstartup
vncserver
vncserver -kill :1

Auto-start tightvncserver on boot

You can change geometry below to whatever resolution you'd like your VNC server to use, but depth must be 24 or greater for SkyChart to run.

cat << EOF | sudo tee /etc/systemd/system/[email protected]
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=forking
User=${USER}
Group=${USER}
WorkingDirectory=${HOME}

PIDFile=${HOME}/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1920x1080 :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable [email protected]
sudo systemctl start vncserver@1
sudo systemctl status vncserver@1
# press q to quit the status viewer

Disable Screensaver

You must disable the screen saver and screen blanking or the vnc server will freeze after a few minutes.

  1. Go to Applications -> Settings -> Screen Saver and disable
  2. Go to Applications -> Settings -> Power Manager -> Display and disable.

xfwm4 bug

In Ubuntu 20.04 Focal, xfwm4 4.14.1 currently has an issue with tightvncserver, so use 4.14.2 from groovy. This bug manifests as all window decorations being missing.

Add groovy to apt

Raspberry Pi

echo 'deb http://ports.ubuntu.com/ubuntu-ports groovy main restricted universe multiverse' | sudo tee -a /etc/apt/sources.list

AMD64

echo 'deb http://us.archive.ubuntu.com/ubuntu groovy main restricted universe multiverse' | sudo tee -a /etc/apt/sources.list

Only use groovy for xfwm4

echo 'APT::Default-Release "focal";' | sudo tee -a /etc/apt/apt.conf.d/01-vendor-ubuntu
cat << EOF | sudo tee /etc/apt/preferences.d/xfwm4
Package: xfwm4
Pin: release n=focal
Pin-Priority: -10

Package: xfwm4
Pin: release n=groovy
Pin-Priority: 900
EOF

sudo apt update
sudo apt upgrade
sudo reboot

Astro software

# INDI, KStars, Astrometry.net, web browser, etc.

# if you want to live on the edge, you can use the nightly builds here
# sudo add-apt-repository ppa:mutlaqja/indinightly

# stable releases
sudo add-apt-repository -y ppa:mutlaqja/ppa
sudo apt install -y ekos-debugger gsc indi-full kstars-bleeding astrometry.net ser-player gpredict gpsd-clients breeze-icon-theme oxygen-icon-theme

# PHD2
sudo add-apt-repository -y ppa:pch/phd2
sudo apt install -y phd2 phdlogview

# Note that oacapture doesn't have an arm64 distro for 20.04 yet, so if you want it, you'll need to compile it. See http://www.openastroproject.org to get the source and installation instructions.
sudo apt install -y libhidapi-libusb0
wget http://www.openastroproject.org/wp-content/uploads/2020/12/ubuntu-20.04-amd64/oacapture_1.8.0-1_amd64.deb
sudo dpkg -i oacapture_1.8.0-1_amd64.deb

# ASTAP and supporting database
wget https://iweb.dl.sourceforge.net/project/astap-program/linux_installer/astap_$(dpkg --print-architecture).deb
wget https://cfhcable.dl.sourceforge.net/project/astap-program/star_databases/h17_star_database_mag17_astap.deb

sudo dpkg -i astap*.deb h17*.deb

# SkyChart and a stand-alone INDI client
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8B8B57C1AA716FC2
sudo sh -c "echo deb http://www.ap-i.net/apt stable main > /etc/apt/sources.list.d/skychart.list"
sudo apt update
sudo apt install -y skychart indistarter

# Stellarium
sudo add-apt-repository -y ppa:stellarium/stellarium-releases
sudo apt install -y stellarium

Astrometry.net Data

Download the info you need from http://data.astrometry.net/debian/

GPSD

sudo apt install gpsd

I keep my GPS plugged into the same USB port, and use udev to assign a symlink name so it is always consistent. I find this easier to deal with than using vendor, product and serial ids, since many of the devices I use all use cheap USB serial chips that all have the same values, so the only difference between them is what USB port they are plugged into, especially since I just leave everything plugged in all the time.

First, unplug your GPS receiver. Then plug it in to the USB port you will use. Now find the port number using dmesg.

dmesg

Example Output:

[42198.265988] usb 1-2: new full-speed USB device number 10 using xhci_hcd
[42198.415307] usb 1-2: New USB device found, idVendor=1546, idProduct=01a7, bcdDevice= 1.00
[42198.415310] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[42198.415312] usb 1-2: Product: u-blox 7 - GPS/GNSS Receiver
[42198.415314] usb 1-2: Manufacturer: u-blox AG - www.u-blox.com
[42198.417465] cdc_acm 1-2:1.0: ttyACM1: USB ACM device

This shows my GPS is using a device kernels path of 1-2:1.0, so we can write a udev rule to assign it a static name:

cat << EOF | sudo tee -a /etc/udev/rules.d/99-serial.rules
ACTION=="add", SUBSYSTEM=="tty", KERNELS=="1-2:1.0", SYMLINK+="gps0"
EOF

Now we can edit our gpsd config to specify this device.

cat << EOF | sudo tee /etc/default/gpsd
# should match the symlink you defined in the udev rules
DEVICES="/dev/gps0"

# do not wait for a client to connect to initialize the gps
GPSD_OPTIONS="-n"
EOF

sudo systemctl enable gpsd
sudo systemctl restart gpsd

You can check that your gps is working correctly using cgps.

Extras

GPS Data in Screen Status Line

sudo apt install python3-pip
pip3 install gpsd-py3

# screen_gps.py
cat << EOF > ~/screen_gps.py
#!/usr/bin/python3

import gpsd
import time

# Connect to the local gpsd
try:
    gpsd.connect()
except:
    print("gpsd not running")

pkt = gpsd.get_current()

if pkt.mode < 2:
    print("no fix")
elif pkt.mode == 2:
    print(f"{pkt.lat:.2f} {pkt.lon:.2f}")
else:
    print(f"{pkt.lat:.2f} {pkt.lon:.2f} {pkt.alt:.1f}m")
EOF

chmod +x screen_gps.py

# screenrc
cat << 'EOF' > ~/.screenrc
backtick 2 30 30 python3 ${HOME}/screen_gps.py

hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%Y-%m-%d %{W}%c:%s%{g}][%{B}%2`%{g}]'

defscrollback 5000

startup_message off
EOF

Now when I ssh into my astro-imaging pc, I see the following:

rick@astrobuntu-dev:~$



[astrobuntu-dev][              0*bash              ][2020-08-08  9:13:30][34.70 -80.54 155.1m]

GPS GUI

sudo apt install foxtrotgps

Astro Live Stacker

https://github.com/gehelem/als

Install

sudo apt update && sudo apt install -y git gcc python3-dev python3-venv libraw-dev
git clone https://github.com/gehelem/als.git
cd als

If you are running on a raspberry pi, run this:

patch < ci/rpi4_requirements.patch
./utils/venv_setup.sh
source ./venv/bin/activate
python3 setup.py develop

Run

cd als
source ./venv/bin/activate
als

Update

cd als
git pull

Remote GPSD

For my setup, I have a couple of mounts running, so I built a dedicated Raspberry Pi Zero W GPSD server. Since the indi-gpsd driver will only connect to localhost, this is a decent workaround that forwards any tcp connections for localhost:2947 to another machine.

cat << EOF | sudo tee /etc/default/remote-gpsd
# hostname that actually runs gpsd
REMOTE_HOST=pi-gps-ntp
EOF

cat << 'EOF' | sudo tee /etc/systemd/system/remote-gpsd.service
[Unit]
Description=Remote GPSD Service
After=network.target remote-gpsd.socket
Requires=remote-gpsd.socket

[Service]
EnvironmentFile=-/etc/default/remote-gpsd
ExecStart=/usr/lib/systemd/systemd-socket-proxyd ${REMOTE_HOST}:2947
PrivateTmp=yes

[Install]
WantedBy=default.target
EOF

cat << EOF | sudo tee /etc/systemd/system/remote-gpsd.socket
[Unit]
Description=Remote GPSD Socket
PartOf=remote-gpsd.service

[Socket]
ListenStream=127.0.0.1:2947

[Install]
WantedBy=sockets.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now remote-gpsd.socket

Conclusion

You should now have a fully functional, open source astro-imaging pc, running a modern 64-bit OS, with a lightweight desktop environment.

@deufrai
Copy link

deufrai commented Jun 20, 2024

Hi

Thanks for mentioning ALS in here.
Project is back on track and I'd like to mention we provide ready-to-use archives for both amd64 and arm64 systems.
arm64 is not yet officially released on our GitHub 'releases' section but it should be in a couple days. We just need a few more feedbacks from testers.

Have a look at our v0.7-beta release page : https://github.com/gehelem/als/releases/tag/v0.7-beta2
v0.7-beta2 arm64 build is here : https://als-app.org/assets/custom_builds/als-v0.7-beta2_arm64.tgz

Clear skies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment