Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

Commit

Permalink
1.2 release (#9)
Browse files Browse the repository at this point in the history
* Added function to generate the configuration file

* Added comments to functions definitions. Related to #6.

* Header updated in README. Updated Windows steps as shell script does not work on Windows. Updated setup steps. Added URL to bitsecondtech.com in More Information section. Updated missing output to generate configuration file. Updated if condition in script main.

* Updated the directory for rules. Updated README to include how to import rules.

* Resolve #2 and #6. Added blank lines to generated config file for readability.
  • Loading branch information
almostengr authored Jul 27, 2017
1 parent b1db7a8 commit 1489b2d
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 15 deletions.
40 changes: 28 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# farmosnws
# FarmOS NWS
Automated importing of National Weather Service (NWS) data into FarmOS.

## Purpose
Expand All @@ -22,7 +22,7 @@ investment.
## Setup

### Clone the Repository
Clone this repository by running the command below
To get the latest release, clone this repository by running the command below
```shell
git clone https://github.com/bitsecondal/farmosnws.git
```
Expand All @@ -31,6 +31,10 @@ git clone https://github.com/bitsecondal/farmosnws.git
Make a copy of the get_weather_config_ex.sh file. Update the variables located in the configuration
script file.

```shell
get_weather.sh genconfig
```

The *feedsdir* location will need to be updated to the file system location that
Drupal is checking to see if data files are available.

Expand All @@ -56,38 +60,50 @@ file respectively. If you want to log the output of the script, also update the
```shell
24 * * * * (/path/to/drupal/sites/all/modules/farmosnws/get_weather.sh /path/to/drupal/sites/all/modules/farmosnws/config.sh) >> /var/log/get_weather.log 2>&1
```
If you don't want to log the output of the command, then use the command below.
```shell
24 * * * * (/path/to/drupal/sites/all/modules/farmosnws/get_weather.sh /path/to/drupal/sites/all/modules/farmosnws/config.sh) >> /dev/null 2>&1
```

#### Windows with Task Scheduler
You will need to install software that is capable of downloading files in Windows. Powershell
script should be capable of peforming this task.
Open the Task Scheduler, located in the Control Panel. Create a new scheduled task. When prompted
for the command to run, enter the path to the script in your Drupal directory and the configuration
file as an argument in the script.
This script is not designed to work on Windows.

## Rules
Rules for automating some tasks, such as cutting grass based on frequency are included in this module.
To import the rules, do the following:
1) Install the Rules and Rules UI modules.
2) Copy and paste the text of the rule that you wish to import. The text for each of the rules are located in the rules_import directory of this module.
3) Go to Adminstration > Configuration > Workflow > Rules > Import Rule.
4) Paste the text of the rule that you copied into the box and then click Import.

## Code Updates
To get the latest version of this code, pull the latest release from the
[FarmOS NWS GitHub Page](https://github.com/bitsecondal/farmosnws).

Alternatively you can get the latest code by going to the directory that contains the code and running the command below:
Alternatively you can get the latest code by going to the directory that contains the code and running the commands below:
```shell
git checkout master
git pull origin master
```

## Author
Kenny Robinson, Bit Second Tech (www.bitsecondtech.com)
Kenny Robinson, [Bit Second Tech](www.bitsecondtech.com)

## Bug Reports and Feature Enhancements
Bugs and enhancements will be tracked using the Issue tracker
on the [project repo](https://github.com/bitsecondal/farmosnws/issues).

If you need to report a bug, please open a new issue on this repo. Include
as much detail as possible so that the issue can be replicated.
as much detail as possible including error messages or screenshots so that the issue can be replicated.

## License
Project is available under the MIT License. See LICENSE for more information.

## Additional Information
For more information about Bit Second Tech, please visit the [Bit Second Tech](http://www.bitsecondtech.com) website.

For more information about FarmOS, please visit the [FarmOS](http://www.farmos.org) website.

For more information about the National Weather Service (NWS), please visit the
[NWS](http://www.weather.gov) website.
For more information about the National Weather Service (NWS), please visit the [NWS](http://www.weather.gov) website.


40 changes: 37 additions & 3 deletions get_weather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function log_message() {

function show_help() {
# Show the help documentation
# accepts no arguments

log_message ""
log_message "Usage:"
log_message "get_weather.sh <param>"
Expand All @@ -28,19 +30,48 @@ function show_help() {
log_message ""
log_message "For more information, visit https://github.com/bitsecondal/farmosnws"
}

function generate_config_file() {
# generates the configuration file by answering questions. Resolves Issue #6.
# accepts no arguments

echo "Please answer the questions below to have a configuration file generated."
echo -n "Full path to save configuration file:"
read CONFIGFILENAME
echo -n "Path of the feeds directory:"
read FEEDSPATH
echo -n "Location Code: "
read LOCATIONCODE

log_message "Generating configuration file."

touch ${CONFIGFILENAME}

echo "feedsdir=${FEEDSPATH}" >> ${CONFIGFILENAME}
echo "location=${LOCATIONCODE}" >> ${CONFIGFILENAME}
echo "export feedsdir" >> ${CONFIGFILENAME}
echo "export location" >> ${CONFIGFILENAME}
echo "" >> ${CONFIGFILENAME}
echo "# Config file generated on $(date)" >> ${CONFIGFILENAME}
echo "" >> ${CONFIGFILENAME}

log_message "Done generating configuration file."
}

## SCRIPT MAIN ## SCRIPT MAIN ## SCRIPT MAIN ##
## SCRIPT MAIN ## SCRIPT MAIN ## SCRIPT MAIN ##

FILENAME="${1}"
# check the argument passed
if [[ "${1}" == "genconfig" ]]; then
generate_config_file

# verify that the configuration file exists
if [[ -f ${FILENAME} ]]; then
elif [[ -f ${1} ]]; then

log_message "Loading the configuration"

# load the configuration file
source $1
source ${1}

log_message "Done loading the configuration"

Expand All @@ -50,8 +81,11 @@ if [[ -f ${FILENAME} ]]; then
/usr/bin/wget -O ${feedsdir}/${location}_$(/bin/date +%Y%m%d%H%M%S).xml http://w1.weather.gov/xml/current_obs/${location}.xml

log_message "Done getting the weather data"

# no value or invalid value passed, then show help
else
log_message "Configuration file does not exist."
show_help
fi


File renamed without changes.
File renamed without changes.

0 comments on commit 1489b2d

Please sign in to comment.