My video surveillance works great, but there’s a problem. I don’t want it on when I’m home, it tends to fill up my hard drive. I thought to myself “what’s the easiest way to do this?”. I came up with starting and stopping the motion service (the service doing the surveillance) via php-pages on a web server. Not very high tech, but it’s easy to implement.
To start with I installed Apache, PHP, etc. Just apt-get install in Debian.
The next step is to make the Apache user able to start and stop motion, I did this with some sudo tricks and added the following to /etc/sudoers after installing sudo.
Cmnd_Alias MOTION = /etc/init.d/motion User_Alias MOTIONUSERS = www-data MOTIONUSERS ALL = NOPASSWD : MOTION
This gives the www-data-user rights to use sudo and restart motion without a password.
Now, the last step is to create two simple php pages. I have one called start.php and one called stop.php.
<html>
<head>
<link rel="apple-touch-icon" href="Safe.png"/>
<link rel="apple-touch-icon" sizes="114x114" href="safe_114.png"/>
<title>Start Motion</title>
</head>
<body>
<?
system('sudo /etc/init.d/motion start');
print $list_line;
?>
<br>
<h1>Started!</h1>
</body>
</html><html>
<head>
<link rel="apple-touch-icon" href="Safe.png"/>
<link rel="apple-touch-icon" sizes="114x114" href="safe_114.png"/>
<title>Stop Motion</title>
</head>
<body>
<?
system('sudo /etc/init.d/motion stop');
?>
<br>
<h1>Stopped!</h1>
</body>
</html>Each file contains a line to start/stop motion plus apple touch icons. The icons are used when I add the start and stop pages on my home screen on my iPhone.
I can now start motion when I leave home and stop it just before i open the front door and thus avoid any extra pictures or alarms.




