Spypi

From Hack Manhattan Wiki
This is the layout the screen should hopefully be. The top-left terminal is running the Motion command, the next one down the find-loop bash script, the file manager is open to the /home/hm/Videos/motion/output/ directory, and VLC is running a network stream from the localhost on port 8081. Ideally, we should keep a similar layout at all times.

The spypi is the hall(s)-cam of Hack Manhattan, it runs a video stream of the hall outside our door to a little monitor mounted alongside the doorpi. It is not attatched to the network in any capacity, and not meant for keeping track of who comes and goes. It is only up for legal purposes and as a (slightly)better peephole.

Re-Set-up Instructions

A recording-on-motion buffer is implemented via motion and a bash script that runs find every 6 hours with the following commands run from the /home/hm/Videos/motion/output/ directory. The file manager is open to this directory to make deleting or viewing logged recordings simple and transparent. VLC is also open with a stream from localhost on the port 8081.

Motion Run Command:
sudo libcamerify motion -l ../motion.log -c ../motion.conf

The notable components of this command are libcamerify, which uses the new(ish) libcamera backend, and -l and -c, which specify the log and config files(both of which are elevated for transparency) for the motion command.

Bash Script Run Command:
./../find-loop.sh

This script simply looks in the current directory, in this case /home/hm/Videos/motion/output/, and deletes all files older than 3 days, every 12 hours. Please remember to cd into the correct directory or this command may mess up system files and will certainly not function as intended!

Bash Script Contents:
while true; 
do find * -mtime +3 -delete;
sleep 43200; 
done

This command runs every 43200 seconds, or 12 hours.

Why Are You Doing This

The reason this process is so hacked-together and exposed to the user is entirely for transparency. The goal is to have a system anyone can trust, and the more "user-friendly" versions of this setup are much more obscured behind layers of UX. There are no systemd services, no config files buried in /etc/, and no networking in any capacity, and that's the way we like it dangnabbit! It also means a trade-off in how it responds to a power-cycle, in that it will lose all the volatile setup, hence the thorough documentation.

Backup Info

File Tree

└── Videos
    └── motion
        ├── find-loop.sh
        ├── motion.conf
        ├── motion.log
        └── output
            └── recording.mkv

find-loop.sh

while true;
do find * -mtime +3 -delete;
sleep 43200;
done;

motion.conf

daemon off
setup_mode off
; pid_file value
log_file /home/hm/Videos/motion/motion.log
log_level 6
target_dir /home/hm/Videos/motion/output/
videodevice /dev/video0
; vid_control_params value
; netcam_url value
; mmalcam_name value
; mmalcam_control_params value
width 1020
height 1080
framerate 15
text_left CAMERA1
text_right %Y-%m-%d\n%T-%q
emulate_motion off
threshold 1500
; noise_level 32
despeckle_filter EedDl
minimum_motion_frames 1
event_gap 60
pre_capture 5
post_capture 5
; on_event_start value
; on_event_end value
; on_movie_end value
picture_output off
picture_filename %Y%m%d%H%M%S-%q
movie_output on
movie_max_time 30
movie_quality 45
movie_codec mkv
movie_filename %t-%v-%Y%m%d%H%M%S
webcontrol_port 8080
webcontrol_localhost off
webcontrol_parms 0
stream_port 8081
stream_localhost on
; camera /usr/etc/motion/camera1.conf
; camera /usr/etc/motion/camera2.conf
; camera /usr/etc/motion/camera3.conf
; camera /usr/etc/motion/camera4.conf
; camera_dir /usr/etc/motion/conf.d