Skip to content

Commit

Permalink
Refactor Configs
Browse files Browse the repository at this point in the history
Instead of having things spread all over the place (home directory kept
in sync with ansible prompts and other configs), simplify and
consolidate down to a single settings.yml file that can be used and kept
up to date for driving all configurations.
  • Loading branch information
jekhokie committed Feb 2, 2021
1 parent 20f6a02 commit f8aee65
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 116 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
# vim swap files
*.swp
*.swo

# environment-specific config file
config/settings.yml
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@ reach out by submitting an issue:
# update os localisation settings
sudo raspi-config

# clone and install, following prompts
# install git
sudo apt-get -y install git

# clone repository
cd $HOME
git clone https://github.com/jekhokie/raspberry-noaa-v2.git
cd raspberry-noaa-v2/

# copy sample settings and update for your install
cp config/settings.yml.sample config/settings.yml
vi config/settings.yml

# perform install
./install_and_upgrade.sh
```

Expand Down Expand Up @@ -81,13 +89,23 @@ patching, and even then it would still be questionable), updating your Pi user p

## Install

To install the product and get going, simply clone the project to the `pi` user's home directory, run a script, and provide the
inputs asked for:
To install the product and get going, simply clone the project to the `pi` user's home directory, set up your settings, and run the
install script:

```bash
# install git
sudo apt-get -y install git

# clone repository
cd $HOME
git clone https://github.com/jekhokie/raspberry-noaa-v2.git
cd raspberry-noaa-v2/

# copy sample settings and update for your install
cp config/settings.yml.sample config/settings.yml
vi config/settings.yml

# perform install
./install_and_upgrade.sh
```

Expand All @@ -98,10 +116,19 @@ been using raspberry-noaa on this device) or, if this is a brand new setup, just

Want to get the latest and greatest content from the GitHub master branch? Easy - use the same script from the Install process
and all of your content will automatically upgrade (obviously you'll want to do this when there isn't a scheduled capture occurring
or about to occur). Note that the upgrade process will *only* ask you for parameters if they are new to the software being updated -
your original configurations will remain intact and used without you needing to get involved!
or about to occur). Note that once you pull the latest code down using git, you'll likely want to compare your `config/settings.yml`
file with the new code `config/settings.yml.sample` and include/incorporate any new or renamed configuration parameters.

```bash
# pull down new code
cd $HOME/raspberry-noaa-v2/
git pull

# compare settings file:
# config/settings.yml.sample with config/settings.yml
# and incorporate any changes/updates

# perform upgrade
./install_and_update.sh
```

Expand All @@ -114,9 +141,8 @@ to enable/configure with links to the respective instructions:

## Changing Configurations After Install

Want to make changes to either the base station functionality or webpanel settings? You can view and edit the available settings in
/home/pi/.base_station.yml` and `/home/pi/.webserver.yml` respectively. Once modifying a setting in those files, simply re-run
the installer/upgrader script: `./install_and_update.sh`.
Want to make changes to either the base station functionality or webpanel settings? Simply update the `config/settings.yml` file
and re-run `./install_and_update.sh` - the script will take care of the rest of the configurations!

## Troubleshooting

Expand Down
53 changes: 0 additions & 53 deletions ansible/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,12 @@
hosts: core
connection: local
gather_facts: no
vars_prompt:
- name: latitude
prompt: What is your base station latitude (South values are negative)?
private: no
- name: longitude
prompt: What is your base station longitude (West values are negative)?
private: no
- name: timezone_offset
prompt: What is your time zone offset (e.g. -5 for US Eastern)?
private: no
- name: enable_bias_tee
prompt: Enable bias tee (True/False)?
private: no
default: False
- name: schedule_iss
prompt: Schedule ISS captures (True/False)?
private: no
default: False
- name: delete_audio
prompt: Delete audio files after image create (True/False)?
private: no
default: True
- name: sat_min_elevation
prompt: NOAA satellite minimum elevation (degrees) to schedule capture?
private: no
default: 30
- name: meteor_min_elevation
prompt: Meteor satellite minimum elevation (degrees) to schedule capture?
private: no
default: 30
- name: sun_min_elevation
prompt: Sun minimum elevation (degrees) to attempt additional imagery enhancements?
private: no
default: 10
pre_tasks:
- name: get os release
shell: lsb_release -c --short
register: raspbian_version
check_mode: no
changed_when: no
- name: validate bias tee setting
assert:
that: enable_bias_tee|string == 'True' or enable_bias_tee|string == 'False'
fail_msg: "'Enable bias tee?' must be either 'True' or 'False' - please re-run and try again."
- name: validate schedule_iss setting
assert:
that: schedule_iss|string == 'True' or schedule_iss|string == 'False'
fail_msg: "'Schedule ISS captures?' must be either 'True' or 'False' - please re-run and try again."
- name: validate delete_audio setting
assert:
that: delete_audio|string == 'True' or delete_audio|string == 'False'
fail_msg: "'Delete audio files after image create?' must be either 'True' or 'False' - please re-run and try again."
- name: store settings for future runs
template:
src: ../templates/base_station.yml.j2
dest: ~pi/.base_station.yml
owner: pi
group: pi
mode: 0644
roles:
- role: common
...
20 changes: 16 additions & 4 deletions ansible/roles/common/templates/noaa-v2.conf.j2
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
# framework configs
NOAA_HOME={{ noaa_home }}
DB_FILE={{ db_file }}
WEB_HOME={{ web_home }}
IMAGE_OUTPUT={{ images_output }}
NOAA_AUDIO_OUTPUT={{ audio_output }}/noaa
METEOR_AUDIO_OUTPUT={{ audio_output }}/meteor
RAMFS_AUDIO={{ ramfs_path }}
SAT_MIN_ELEV={{ sat_min_elevation }}
METEOR_MIN_ELEV={{ meteor_min_elevation }}
SUN_MIN_ELEV={{ sun_min_elevation }}

# base station configs
LAT={{ latitude }}
LON={{ longitude }}

# whether to schedule specific objects
SCHEDULE_ISS="{% if schedule_iss|string == 'True' %}true{% else %}false{% endif %}"
SCHEDULE_NOAA="{% if schedule_noaa|string == 'True' %}true{% else %}false{% endif %}"
SCHEDULE_METEOR="{% if schedule_meteor|string == 'True' %}true{% else %}false{% endif %}"

# thresholds for captures
SAT_MIN_ELEV={{ sat_min_elevation }}
SUN_MIN_ELEV={{ sun_min_elevation }}

# system configs, processing configs, and sdr tuning
DELETE_AUDIO="{% if delete_audio|string == 'True' %}true{% else %}false{% endif %}"
BIAS_TEE="{% if enable_bias_tee|string == 'True' %}-T{% endif %}"
FLIP_METEOR_IMG="true"
GAIN=50
SCHEDULE_ISS="{% if schedule_iss|string == 'True' %}true{% else %}false{% endif %}"

# language and debugging
TZ_OFFSET={{ timezone_offset }}
LOG_LEVEL=DEBUG
9 changes: 0 additions & 9 deletions ansible/templates/base_station.yml.j2

This file was deleted.

3 changes: 0 additions & 3 deletions ansible/templates/webserver.yml.j2

This file was deleted.

24 changes: 0 additions & 24 deletions ansible/webserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,6 @@
hosts: webserver
connection: local
gather_facts: no
vars_prompt:
- name: timezone
prompt: What is your timezone (e.g. America/New_York - see https://www.php.net/manual/en/timezones.php)?
private: no
- name: lang_setting
prompt: What is your preferred language setting (ar, de, en, es, sr)?
private: no
default: en
- name: web_port
prompt: Port to run the web interface on?
private: no
default: 80
pre_tasks:
- name: validate language setting
assert:
that: lang_setting in available_langs
fail_msg: "Your specified locale {{ lang_setting }} is not one of the available - please re-run and try again."
- name: store settings for future runs
template:
src: ../templates/webserver.yml.j2
dest: ~pi/.webserver.yml
owner: pi
group: pi
mode: 0644
roles:
- role: webserver
post_tasks:
Expand Down
37 changes: 37 additions & 0 deletions config/settings.yml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# base station configurations
# latitude: south values are negative
# longitude: west values are negative
latitude: 40.712776
longitude: -74.005974

# time zone offset from UTC (for example, '-5' for US Eastern)
timezone_offset: -5

# whether to enable bias tee (power LNA or upstream devices from SDR)
enable_bias_tee: True

# whether to schedule specific orbiting objects for capture
schedule_iss: False
schedule_noaa: True
schedule_meteor: True

# whether audio files should be deleted after images are created
delete_audio: False

# thresholds for scheduling captures - enables avoiding an attempt
# to capture imagery if objects are lower than these degree elevation thresholds
sat_min_elevation: 30
meteor_min_elevation: 30
sun_min_elevation: 10

# locale settings for timezone and language
# timezone: see https://www.php.net/manual/en/timezones.php
# lang_setting: see the 'webpanel/App/Lang' folder for available
# languages (2-letter filename - e.g. ar, de, en, es, sr)
timezone: America/New_York
lang_setting: en

# port to run the webpanel on
web_port: 80
...
17 changes: 6 additions & 11 deletions install_and_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,15 @@ if [ $? -ne 0 ]; then
fi
fi

# append pre-set variables if available
log_running "Getting any pre-configured variables..."
ansible_extra_args=""
if [ -f $HOME/.base_station.yml ]; then
ansible_extra_args="--extra-vars \"@~/.base_station.yml\""
fi
if [ -f $HOME/.webserver.yml ]; then
ansible_extra_args="$ansible_extra_args --extra-vars \"@~/.webserver.yml\""
log_running "Checking for configuration settings..."
if [ -f config/settings.yml ]; then
log_done " Settings file ready!"
else
die " No settings file detected - please copy config/settings.yml.sample to config/settings.yml and edit for your environment"
fi
ansible_cmd="ansible-playbook -i ansible/hosts $ansible_extra_args ansible/site.yml"
log_running " Done getting pre-configured variables!"

log_running "Running Ansible to install and/or update your raspberry-noaa-v2..."
eval "${ansible_cmd}"
ansible-playbook -i ansible/hosts --extra-vars "@config/settings.yml" ansible/site.yml
if [ $? -eq 0 ]; then
log_done " Ansible apply complete!"
else
Expand Down
14 changes: 10 additions & 4 deletions scripts/schedule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ log "Scheduling new capture jobs..." "INFO"
if [ "$SCHEDULE_ISS" == "true" ]; then
$NOAA_HOME/scripts/schedule_captures.sh "ISS (ZARYA)" 145.8000 "receive_iss.sh" $TLE_OUTPUT
fi
$NOAA_HOME/scripts/schedule_captures.sh "NOAA 15" 137.6200 "receive_noaa.sh" $TLE_OUTPUT
$NOAA_HOME/scripts/schedule_captures.sh "NOAA 18" 137.9125 "receive_noaa.sh" $TLE_OUTPUT
$NOAA_HOME/scripts/schedule_captures.sh "NOAA 19" 137.1000 "receive_noaa.sh" $TLE_OUTPUT
$NOAA_HOME/scripts/schedule_captures.sh "METEOR-M 2" 137.1000 "receive_meteor.sh" $TLE_OUTPUT

if [ "$SCHEDULE_NOAA" == "true" ]; then
$NOAA_HOME/scripts/schedule_captures.sh "NOAA 15" 137.6200 "receive_noaa.sh" $TLE_OUTPUT
$NOAA_HOME/scripts/schedule_captures.sh "NOAA 18" 137.9125 "receive_noaa.sh" $TLE_OUTPUT
$NOAA_HOME/scripts/schedule_captures.sh "NOAA 19" 137.1000 "receive_noaa.sh" $TLE_OUTPUT
fi

if [ "$SCHEDULE_METEOR" == "true" ]; then
$NOAA_HOME/scripts/schedule_captures.sh "METEOR-M 2" 137.1000 "receive_meteor.sh" $TLE_OUTPUT
fi

0 comments on commit f8aee65

Please sign in to comment.