diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09172aa --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +predict/ diff --git a/METEOR.md b/METEOR.md index 701ef42..a318ece 100644 --- a/METEOR.md +++ b/METEOR.md @@ -10,4 +10,3 @@ Currently, the satellite is using 137.1Mhz as the center frequency, Wide-FM @ 12 3. Use artlav's [medet_arm](https://github.com/artlav/meteor_decoder) to generate a decoded dump and then a false color image 4. Use dbdexter's [meteor_rectify](https://github.com/dbdexter-dev/meteor_rectify) to correct the visible deformation on Meteor images (wrong aspect ratio) 1. I made [some changes](rectify.py) to rectify to export to compressed JPG and remove some prints - diff --git a/README.md b/README.md index 4787000..d3c9e19 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ Most of the code and setup stolen from: [Instructables](https://www.instructable - [Wiki](https://github.com/reynico/raspberry-noaa/wiki) is updated! - Audio files are stored on a RAMFS partition. Happen to had some glitches on image reception -### Manual work - - See [Wiki's install and config page](https://github.com/reynico/raspberry-noaa/wiki/Initial-installation-and-configuration) for information +### Install +There's an [install.sh](install.sh) script that does everything at once. If in doubt, see the [Wiki's install and config page](https://github.com/reynico/raspberry-noaa/wiki/Initial-installation-and-configuration). ### Important notes - I tried to run this on a Raspberry PI Zero Wifi, no luck. Seems like it's too much load for the CPU. Running on a Raspberry PI 2+ is ok. See [Wiki's hardware notes page](https://github.com/reynico/raspberry-noaa/wiki/Hardware-notes). diff --git a/common.sh b/common.sh index ed44bba..dd1501e 100755 --- a/common.sh +++ b/common.sh @@ -4,6 +4,7 @@ # set -x . ~/.noaa.conf +. "${NOAA_HOME}"/common.sh declare -A levels=([DEBUG]=0 [INFO]=1 [WARN]=2 [ERROR]=3) log_level=${LOG_LEVEL} diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..50e50da --- /dev/null +++ b/install.sh @@ -0,0 +1,168 @@ +#!/bin/bash +set -e + +RED=$(tput setaf 1) +GREEN=$(tput setaf 2) +YELLOW=$(tput setaf 3) +BLUE=$(tput setaf 4) +BOLD=$(tput bold) +RESET=$(tput sgr0) + +die() { + >&2 echo "${RED}error: $1${RESET}" && exit 1 +} + +log() { + echo "$*" +} + +log_done() { + echo " ${GREEN}✓${RESET} $1" +} + +log_running() { + echo " ${YELLOW}*${RESET} $1" +} + +success() { + echo "${GREEN}$1${RESET}" +} + +### Verify cloned repo +if [ ! -e "$HOME/raspberry-noaa" ]; then + die "Is https://github.com/reynico/raspberry-noaa cloned in your home directory?" +fi + +### Install required packages +log_running "Installing required packages..." +sudo apt update -yq +sudo apt install -yq predict \ + python-setuptools \ + ntp \ + cmake \ + libusb-1.0 \ + sox \ + at \ + nginx \ + libncurses5-dev \ + libncursesw5-dev \ + python3-pip +sudo pip3 install numpy +log_done "Packages installed" + +### Blacklist DVB modules +if [ -e /etc/modprobe.d/rtlsdr.conf ]; then + log_done "DVB modules were already blacklisted" +else + sudo cp modprobe.d/rtlsdr.conf /etc/modprobe.d/rtlsdr.conf + log_done "DVB modules are blacklisted now" +fi + +### Install RTL-SDR +if [ -e /usr/local/bin/rtl_fm ]; then + log_done "rtl-sdr was already installed" +else + log_running "Installing rtl-sdr from osmocom..." + ( + cd /tmp/ + git clone https://github.com/osmocom/rtl-sdr.git + cd rtl-sdr/ + mkdir build + cd build + cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON + make + sudo make install + sudo ldconfig + cd /tmp/ + sudo cp ./rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/ + ) + log_done "rtl-sdr install done" +fi + +### Install WxToIMG +if [ -e /usr/local/bin/xwxtoimg ]; then + log_done "WxToIMG was already installed" +else + log_running "Installing WxToIMG..." + sudo dpkg -i wxtoimg-armhf-2.11.2-beta.deb + log_done "WxToIMG installed" +fi + +### Install default config file +if [ -e "$HOME/.noaa.conf" ]; then + log_done "$HOME/.noaa.conf already exists" +else + cp ".noaa.conf" "$HOME/.noaa.conf" + log_done "$HOME/.noaa.conf installed" +fi + +if [ -e "$HOME/.predict/predict.qth" ]; then + log_done "$HOME/.predict/predict.qth already exists" +else + cp "predict.qth" "$HOME/.predict/predict.qth" + log_done "$HOME/.predict/predict.qth installed" +fi + +### Install meteor_demod +if [ -e /usr/bin/meteor_demod ]; then + log_done "meteor_demod was already installed" +else + log_running "Installing meteor_demod..." + ( + cd /tmp + git clone https://github.com/dbdexter-dev/meteor_demod.git + cd meteor_demod + make + sudo make install + ) + log_done "meteor_demod installed" +fi + +### Install medet_arm +if [ -e /usr/bin/medet_arm ]; then + log_done "medet_arm was already installed" +else + log_running "Installing medet_arm..." + sudo cp medet_arm /usr/bin/medet_arm + sudo chmod +x /usr/bin/medet_arm + log_done "medet_arm installed" +fi + +### Cron the scheduler +crontab -l | grep -q "raspberry-noaa" +if [ $? -eq 0 ]; then + log_done "Crontab for schedule.sh already exists" +else + cat <(crontab -l) <(echo "1 0 * * * /home/pi/raspberry-noaa/schedule.sh") | crontab - + log_done "Crontab installed" +fi + +### Setup Nginx +sudo cp nginx.cfg /etc/nginx/sites-enabled/default +( + sudo mkdir -p /var/www/wx + sudo chown -R www-data:www-data /var/www/wx + sudo usermod -a -G www-data pi + sudo chmod 775 /var/www/wx +) +sudo systemctl restart nginx + +### Setup ramFS +cat /etc/fstab | grep -q "ramfs" +if [ $? -eq 0 ]; then + log_done "ramfs already setup" +else + sudo mkdir -p /var/ramfs + cat fstab | sudo tee -a /etc/fstab > /dev/null + log_done "Ramfs installed" +fi +set +e +sudo mount -a +set -e +sudo chmod 777 /var/ramfs + +success "Install (almost) done! Let's do some configuration" +echo " + 1. Edit $HOME/.noaa.conf + 2. Edit $HOME/.predict/predict.qth and set lat/lon data + " diff --git a/medet_arm b/medet_arm new file mode 100755 index 0000000..7ec3a9f Binary files /dev/null and b/medet_arm differ diff --git a/modprobe.d/rtlsdr.conf b/modprobe.d/rtlsdr.conf new file mode 100644 index 0000000..1dd3641 --- /dev/null +++ b/modprobe.d/rtlsdr.conf @@ -0,0 +1,3 @@ +blacklist dvb_usb_rtl28xxu +blacklist rtl2832 +blacklist rtl2830 diff --git a/predict.qth b/predict.qth new file mode 100644 index 0000000..ed25a79 --- /dev/null +++ b/predict.qth @@ -0,0 +1,4 @@ +raspberry + << your latitude>> + << your longitude >> + <> diff --git a/schedule.sh b/schedule.sh old mode 100644 new mode 100755 index 38df850..d27a988 --- a/schedule.sh +++ b/schedule.sh @@ -1,7 +1,8 @@ #!/bin/bash ## import common lib -. ~/common.sh +. ~/.noaa.conf +. "${NOAA_HOME}"/common.sh wget -qr http://www.celestrak.com/NORAD/elements/weather.txt -O "${NOAA_HOME}"/predict/weather.txt wget -qr http://www.celestrak.com/NORAD/elements/amateur.txt -O "${NOAA_HOME}"/predict/amateur.txt diff --git a/schedule_iss.sh b/schedule_iss.sh index e0bd145..67e4b16 100644 --- a/schedule_iss.sh +++ b/schedule_iss.sh @@ -4,6 +4,7 @@ # set -x . ~/.noaa.conf +. "${NOAA_HOME}"/common.sh SAT_MIN_ELEV=10 PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/amateur.tle -p "${1}" | head -1) diff --git a/schedule_meteor.sh b/schedule_meteor.sh index dc59142..d63bc9c 100755 --- a/schedule_meteor.sh +++ b/schedule_meteor.sh @@ -1,7 +1,8 @@ #!/bin/bash ## import common lib -. ~/common.sh +. ~/.noaa.conf +. "${NOAA_HOME}"/common.sh PREDICTION_START=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" | head -1) PREDICTION_END=$(/usr/bin/predict -t "${NOAA_HOME}"/predict/weather.tle -p "${1}" | tail -1) diff --git a/schedule_sat.sh b/schedule_sat.sh old mode 100644 new mode 100755 index edf246b..8ea049f --- a/schedule_sat.sh +++ b/schedule_sat.sh @@ -1,7 +1,8 @@ #!/bin/bash ## import common lib -. ~/common.sh +. ~/.noaa.conf +. "${NOAA_HOME}"/common.sh # $1 = Satellite Name # $2 = Frequency diff --git a/wxtoimg-armhf-2.11.2-beta.deb b/wxtoimg-armhf-2.11.2-beta.deb new file mode 100644 index 0000000..0f45f09 Binary files /dev/null and b/wxtoimg-armhf-2.11.2-beta.deb differ