Building the control script

Now that we have designed our system the way we want it to work, we can start writing our Bash control script. As before, we'll locate our scripts in the folder, /etc/pi-alarm, which, you'll remember from Chapter 7, Building a Web-Based Control Panel, is also where our Web-based control panel writes its configuration status file, alarm.cfg to. We'll be referring to that file in our scripts too.

In this script, we are going to use the bc tool (the Bash command-line calculator) to convert hex values to binary. It's not installed by default, so you'll need to get the package:

$ sudo apt-get update
$ sudo apt-get install bc

Tip

Our script file is quite long so, as before, you might want to sit on the sofa and write it on ...

Get Building a Home Security System with Raspberry Pi now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.