Automate shutdown during thunderstorm warning script
Posted: Mon Aug 01, 2011 1:20 pm
Inspired by http://forums.linuxmint.com/viewtopic.php?f=90&t=78069 I set out to help another member come up with a "Severe Thunderstorm shutdown script".
Rather than re-invent the wheel, I decided that conkyForecast can help us achieve the desired result.
Here are the instructions:
Install and configure conkyForecast.I have Version: 2.20 installed and this works just fine.
Although you can install a later version. You do NOT need to install conky.
Step 1: Install conkyForecast
Step 2: Register at http://www.weather.com/services/xmloap.html
Register and get your XOAP* codes. They will be emailed to you.
You will need these to use the conkyForecast script and the values you receive from this registration will need to be entered into your ~/.conkyForecast.config file.
The fields are
XOAP_LICENCE_KEY= and
XOAP_PARTNER_ID=
Step 3: Edit the sudoers file (add your username to the "allow" list for the halt command)
I inserted the command just like this in the file here:
substitute jj for your actual username
save and exit the visudo comand.
Step 4: Create this script:
Save and exit. > Terminal >
NOTE: Your "USWI0244" code will be different depending on your Registration details at http://www.weather.com/services/xmloap.html
Step 5: Create a cron AS YOU (to execute the script you created in Step 4)
This cron will run every minute of every day
terminal >
crontab -e
*/1 * * * * /path/to/script.sh
NOTES:
Your "USWI0244" code will be different depending on your Registration details at http://www.weather.com/services/xmloap.html
You do NOT need to install conky.
The conkyForecast script instructions
Sudoers - Ubuntu Documentation
Later, if cron gets "too noisy" about blah blah blah,
just change "*/1 * * * * /path/to/script.sh" to "*/1 * * * * /path/to/script.sh >/dev/null 2>&1"
in your crontab (crontab -e)
I might have missed something, but this will get you most of the way there.
Enjoy.
Rather than re-invent the wheel, I decided that conkyForecast can help us achieve the desired result.
Here are the instructions:
Install and configure conkyForecast.I have Version: 2.20 installed and this works just fine.
Although you can install a later version. You do NOT need to install conky.
Step 1: Install conkyForecast
Code: Select all
sudo add-apt-repository ppa:conky-companions/ppa
sudo apt-get update
sudo apt-get install -y conkyforecast
cp /usr/share/conkyforecast/conkyForecast.config ~/.conkyForecast.config
Register and get your XOAP* codes. They will be emailed to you.
You will need these to use the conkyForecast script and the values you receive from this registration will need to be entered into your ~/.conkyForecast.config file.
The fields are
XOAP_LICENCE_KEY= and
XOAP_PARTNER_ID=
Step 3: Edit the sudoers file (add your username to the "allow" list for the halt command)
Code: Select all
sudo visudo
Code: Select all
# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
jj ALL=NOPASSWD: /sbin/halt
save and exit the visudo comand.
Step 4: Create this script:
Code: Select all
#!/bin/bash
# Author: Habitual
# Date: Mon 01 Aug 2011 01:11:15 PM EDT
# Requirements: conkyForecast
forecast=`echo $(/usr/share/conkyforecast/conkyForecast.py --location=USWI0244 --d CT)`
if [ "$forecast" = "Severe Thunderstorm*" ] ; then
sudo halt
else
exit 0
fi
Code: Select all
chmod 700 /path/to/script.sh
Step 5: Create a cron AS YOU (to execute the script you created in Step 4)
This cron will run every minute of every day
terminal >
crontab -e
*/1 * * * * /path/to/script.sh
NOTES:
Your "USWI0244" code will be different depending on your Registration details at http://www.weather.com/services/xmloap.html
You do NOT need to install conky.
The conkyForecast script instructions
Sudoers - Ubuntu Documentation
Later, if cron gets "too noisy" about blah blah blah,
just change "*/1 * * * * /path/to/script.sh" to "*/1 * * * * /path/to/script.sh >/dev/null 2>&1"
in your crontab (crontab -e)
I might have missed something, but this will get you most of the way there.
Enjoy.