Skip to content

Commit

Permalink
Add EddyFlux Get Files Module
Browse files Browse the repository at this point in the history
  • Loading branch information
vahid-dan committed Feb 22, 2024
1 parent 4203ddb commit 183da5e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gateways/base/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ export lora_radio_ingress_policing_burst=$(yq e '.lora_radio.ingress_policing_bu
export nebula_overlay_network_is_enabled=$(yq e '.nebula_overlay_network.is_enabled' $config_file)
export nebula_overlay_network_log_file=$(yq e '.nebula_overlay_network.log_file' $config_file)

# EddyFlux Get Files
export eddyflux_get_files_is_enabled=$(yq e '.eddyflux_get_files.is_enabled' $config_file)
export eddyflux_get_files_log_file=$(yq e '.eddyflux_get_files.log_file' $config_file)
export eddyflux_get_files_ssh_user=$(yq e '.eddyflux_get_files.ssh_user' $config_file)
export eddyflux_get_files_ssh_host=$(yq e '.eddyflux_get_files.ssh_host' $config_file)
export eddyflux_get_files_source_path=$(yq e '.eddyflux_get_files.source_path' $config_file)
export eddyflux_get_files_destination_path=$(yq e '.eddyflux_get_files.destination_path' $config_file)

########## DEFINE FUNCTIONS ##########

# Check if module is is_enabled
Expand Down
10 changes: 10 additions & 0 deletions gateways/config-files/henrietta/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ git_push:
directories:
- /data/fcre-catwalk-data
- /data/henrietta-logs
- /data/fcre-eddyflux-data

git_garbage_collector:
is_enabled: true
log_file: git-garbage-collector.log
directories:
- /data/fcre-catwalk-data
- /data/henrietta-logs
- /data/fcre-eddyflux-data

health_checks_io:
is_enabled: true
Expand Down Expand Up @@ -104,3 +106,11 @@ lora_radio:
nebula_overlay_network:
is_enabled: true
log_file: nebula-overlay-network.log

eddyflux_get_files:
is_enabled: true
log_file: eddyflux-get-files.log
ssh_user: licor
ssh_host: 10.10.1.4
source_path: ~/data/summaries/*
destination_path: /data/fcre-eddyflux-data/
3 changes: 3 additions & 0 deletions gateways/cron-jobs/non-root
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
# Runs LoRa Radio
@reboot sleep 60 && /home/ubuntu/miscellaneous/gateways/remote-access/lora-radio.sh
00 * * * * /home/ubuntu/miscellaneous/gateways/remote-access/lora-radio.sh

# Gets EddyFlux Files
45 23 * * * /home/ubuntu/miscellaneous/gateways/eddyflux/eddyflux-get-files.sh
39 changes: 39 additions & 0 deletions gateways/eddyflux/eddyflux-get-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# EddyFlux Get Files Module
# This module downloads EddyFlux files to the gateway.
# Usage: Run periodically, every day, for instance.

# SSH Access Sample Command:
# ssh -o PubkeyAcceptedAlgorithms=+ssh-rsa -oHostKeyAlgorithms=+ssh-rsa,ssh-dss [email protected]

# SCP File Transfer Sample Command:
# scp -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostKeyAlgorithms=+ssh-rsa,ssh-dss -r [email protected]:data/summaries/* /data/fcre-eddyflux-data/

########## HEADER ##########

module_name=eddyflux_get_files

# Load utility functions and configurations for gateways
source /home/ubuntu/miscellaneous/gateways/base/utils.sh

# Check if the module is enabled
check_if_enabled "$module_name"

# Redirect all output of this module to log_to_file function
exec > >(while IFS= read -r line; do log_to_file "$module_name" "$line"; echo "$line"; done) 2>&1

echo "########## START ##########"

########## BODY ##########

scp -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostKeyAlgorithms=+ssh-rsa,ssh-dss -r ${eddyflux_get_files_ssh_user}@${eddyflux_get_files_ssh_host}:${eddyflux_get_files_source_path} ${eddyflux_get_files_destination_path}

########## FOOTER ##########

echo "########## END ##########"

# Close stdout and stderr
exec >&- 2>&-
# Wait for all background processes to complete
wait

0 comments on commit 183da5e

Please sign in to comment.