|
Motioneye is an opensource software project which turns your SBC (Small Board Computer) into a video security system with support for both IPv4 Cameras, as well as directly attached USB cameras.
It even includes a all-in-one prepackaged distribution called MotioneyeOS. Just burn to an SD card, insert into your SBC, and you are off and running. The downside is that it does not support IPv6.
Thanks to a bug raised in 2018, the author of Motioneye enabled IPv6 in the kernel distributed and burned to an SD card. That was the first step. But in order to manage the SBC via IPv6 requires a bit more work.
One can follow the instructions in the bug 779, but in order to make the required change to settings.py
one must first get the source. MotioneyeOS does not include the *py
files, only the byte-compiled pyc
files.
uncompyle6
the Python decompilerFortunately, there is another open source project which does an excellent job of decompiling pyc
to py
files. uncompyle6
I installed it on one of my Alpine Linux containers with pip. I'll call this system remote_host
in this article.
apk add python2 py2-pip
pip install uncompyle6
The Distro is convenient to use, but a downside of the MotioneyeOS distro is that there aren't any package management tools on the SD card. So one can't install uncompyle6
directly on the SBC.
In order to change files on the root file system, one needs to remount it in rw
mode
mount -o remount,rw /
Fortunately, the distro does include openssh, and it is possible to scp
files off and back onto the SBC. First one needs to enable IPv6 for ssh. Edit /etc/ssh/sshd_config
and add the line:
ListenAddress ::
and restart sshd
/etc/init.d/S60sshd restart
Now you should be able to ssh
in on the IPv6 address of MotioneyeOS. How did you get the address. The easiest way is to make a note of it while you were in editing the sshd config file with the ip addr
command.
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether b8:27:eb:6c:02:88 brd ff:ff:ff:ff:ff:ff
inet 192.168.215.140/24 brd 192.168.215.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 2001:db8:8011:fd44:ba27:ebff:fe6c:288/64 scope global dynamic
valid_lft forever preferred_lft forever
inet6 fe80::ba27:ebff:fe6c:388/64 scope link
valid_lft forever preferred_lft forever
Since I run a DNS server for the machines in my house, I just added a AAAA record with the IPv6 GUA (Global Unique) address.
Now that we have enabled IPv6 for ssh
we can copy the settings.pyc
file onto a system (for me a linux container) which has uncompyle6
installed.
While you are ssh-d into the MotioneyeOS system, just scp the file off to the remote_host.
cd /usr/lib/python2.7/site-packages/motioneye/
scp settings.pyc remote_host:
In another terminal window, ssh into the remote_host
with uncompyle6
installed and cd into the directory you scp
'd the settings.pyc
file into.
Running uncompyle6 is easy. Like all good programs it has help.
$ uncompyle6 --help
Usage:
uncompyle6 [OPTIONS]... [ FILE | DIR]...
uncompyle6 [--help | -h | --V | --version]
Examples:
uncompyle6 foo.pyc bar.pyc # decompile foo.pyc, bar.pyc to stdout
uncompyle6 -o . foo.pyc bar.pyc # decompile to ./foo.pyc_dis and ./bar.pyc_dis
uncompyle6 -o /tmp /usr/lib/python1.5 # decompile whole library
To decompile settings.pyc
to settings.py
just run:
uncompyle6 -o . settings.pyc
Now there should be a settings.py
file in that directory.
settings.py
While logged into the remote_host
with uncompyle6
installed, might as well edit the settings.py
file to enable IPv6. Look for the line:
LISTEN = '0.0.0.0'
and change it to:
LISTEN = ''
Save, and now we'll put the file back on to the MotioneyeOS SBC.
ssh
back into the MotioneyeOS SBC and cd into the directory where the settings.pyc
file lives. I moved the settings.pyc
file to a back up to ensure that the python compiler would create a new pyc
file from the modified settings.py
file.
cd /usr/lib/python2.7/site-packages/motioneye/
scp remote_host:settings.py .
mv settings.pyc settings.pyc.bak
Lastly, comment out the LISTEN line on the /data/etc/motioneye.conf
file, as it will over-ride the settings.py
file.
It is possible to just restart the web management service, but at this point it probably easiest to just reboot the SBC.
reboot
Now point your browser at the MotioneyeOS SBC (you did create an AAAA record in your DNS, right?) and you are now managing MotioneyeOS via IPv6!
11 December 2020
updated 21 March 2021