Automate shutdown during thunderstorm warning script

Forum rules
Before you post please read how to get help
Level 13
Level 13
Posts: 4869
Joined: Sun Nov 21, 2010 8:31 pm

Automate shutdown during thunderstorm warning script

Postby Habitual » Mon Aug 01, 2011 1:20 pm

Inspired by 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

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

Step 2: Register at
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

Step 3: Edit the sudoers file (add your username to the "allow" list for the halt command)

Code: Select all

sudo visudo

I inserted the command just like this in the file here:

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

substitute jj for your actual username
save and exit the visudo comand.

Step 4: Create this script:

Code: Select all

# Author: Habitual
# Date: Mon 01 Aug 2011 01:11:15 PM EDT
# Requirements: conkyForecast

forecast=`echo $(/usr/share/conkyforecast/ --location=USWI0244 --d CT)`
if [ "$forecast" = "Severe Thunderstorm*" ] ; then
sudo halt
exit 0

Save and exit. > Terminal >

Code: Select all

chmod 700 /path/to/

NOTE: Your "USWI0244" code will be different depending on your Registration details at

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/

Your "USWI0244" code will be different depending on your Registration details at
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/" to "*/1 * * * * /path/to/ >/dev/null 2>&1"
in your crontab (crontab -e)

I might have missed something, but this will get you most of the way there.

rkhunter 1.4.3 Tutorial
“The single biggest problem in communication is the illusion that it has taken place.”

Return to “Scripts & Bash”

Who is online

Users browsing this forum: No registered users and 1 guest