Thanks to the work by other community members in Uploading IQ files to S3 I was able to create a script that uploads IQ files to Dropbox using rclone.
Rclone supports a lot of cloud storage providers (Dropbox, AWS S3, Google Drive, Azure blob storage, Microsoft OneDrive, NextCloud, etc) as well as generic upload methods such as SFTP, FTP, HTTP). This is great, since the same script can be used for all supported targets. See https://rclone.org/ for a full list.
rclone install
rclone can be installed by running apt-get install rclone
if you are using the SATNOGS Raspberry Pi image (or any other Ubuntu-baed system).
rclone setup
rclone needs to be configured. Note that the configuration needs to be run as the satnogs user. This is what I did:
edit /etc/passed; change
satnogs:x:999:995::/var/lib/satnogs:/bin/false
to
satnogs:x:999:995::/var/lib/satnogs:/bin/bash
Run sudo su - satnogs
to get a shell as the satnogs user. Click on the icon that looks like a book next to your storage provider on https://rclone.org/ and follow the instructions. Instructions for Dropbox: Dropbox
After configuring you can change /etc/passwd back to /bin/false for the satnogs user.
post observation script
This is the script I use:
#!/bin/bash
RC_REMOTE=mfdropbox # This needs to be the same name you specified when configuring rclone
if [ -n "$IQ_DUMP_FILENAME" ] && [ -f "$IQ_DUMP_FILENAME" ]
then
IQ_DIR=$(dirname "${IQ_DUMP_FILENAME}")
IQ_NAME="$1".wav.xz
IQ_FILE="$IQ_DIR"/"$IQ_NAME"
xz -c -7 -T2 "$IQ_DUMP_FILENAME" > "$IQ_FILE"
rclone move "$IQ_FILE" $RC_REMOTE:
fi
I placed it in /usr/local/bin/satnogs-post
and made it executable by the satnogs user:
chgrp satnogs /usr/local/bin/satnogs-post
chmod g+x /usr/local/bin/satnogs-post
satnogs-setup
To enable IQ file saving and activate the post observation script, run sudo satnogs-setup
and set the following settings:
Advanced -> SATNOGS_POST_OBSERVATION_SCRIPT /usr/local/bin/satnogs-post {{ID}}
Advanced -> ENABLE_IQ_DUMP YES
Advanced -> IQ_DUMP_FILENAME /tmp/.satnogs/iq.raw
Let satnogs-setup apply the configuration.
Contents of the configuration file (/etc/default/satnogs-client):
SATNOGS_POST_OBSERVATION_SCRIPT="/usr/local/bin/satnogs-post {{ID}}"
ENABLE_IQ_DUMP="True"
IQ_DUMP_FILENAME="/tmp/.satnogs/iq.raw"
Compressing the IQ files save about 50% based on my tests. I chose xz because it often performs better than gz and bzip2, but xz uses more cpu and more ram, so using a different compressor might be useful.
After each observation, the iq file will be uploaded to my dropbox account:
Things I’d like to add at some point in the future:
- Only upload IQ files for selected observations (observations I’ve scheduled myself for example, or from a whitelist, or based on tags set in Feature RQ: Add custom observation options/tags (#563) · Issues · librespacefoundation / SatNOGS / satnogs-network · GitLab )
- Maybe add the satellite name, frequency and some other metadata to the file name. The following parameters are available:
{{ID}} {{FREQ}} {{TLE}} {{TIMESTAMP}} {{BAUD}} {{SCRIPT_NAME}}"
example data:
1582787 437250000 {"tle2": "2 39161 97.9744 109.0828 0009620 355.2085 4.9027 14.72273109360518", "tle1": "1 39161U 13021C 20023.16198395 .00000100 00000-0 23673-4 0 9992", "tle0": "ESTCUBE 1"} 2020-01-23T10-54-56 None satnogs_cw_decoder.py
1574047 437424000 {"tle2": "2 41460 98.0961 127.5580 0155052 334.7290 24.6413 15.08103934205599", "tle1": "1 41460U 16025E 20023.19743888 .00001022 00000-0 54631-4 0 9992", "tle0": "AAUSAT 4"} 2020-01-23T11-32-39 2400.0 satnogs_msk_ax25.py