Skip to content
This repository has been archived by the owner on Oct 27, 2018. It is now read-only.
Calin Crisan edited this page Aug 10, 2015 · 11 revisions

Partition Layout

motionPie uses three partitions:

  • a boot partition, FAT32, about 16M, mounted read-only at /boot
  • a root partition, EXT4, about 120M, mounted read-only at /
  • a data partition, EXT4, fills up the entire remaining card space, mounted read-write at /data

The boot and root partitions are both overwritten when performing an update (except for the /boot/config.txt file which is preserved). Whenever you need to change something on either root or boot partitions, run the following commands to make them writable:

mount -o remount,rw /
mount -o remount,rw /boot

The data partition contains all the configuration files as well as media files (recorded movies and pictures taken). It is created and formatted at first boot. Wiping out the data partition is equivalent to a factory reset.

Manually Editing Network Configuration

There's no /etc/network/interfaces file. Networking is configured by /etc/init.d/S35wifi and /etc/init.d/S40network.

The wifi script looks for /data/etc/wpa_supplicant.conf; if found, it's used to establish the wifi connection. If this file is absent, it looks for /etc/wpa_supplicant.conf (normally created by writeimage.sh) and it copies it over to /data/etc/, using it thereafter. If none of the files are present, wifi connection is skipped.

The network script looks for /data/etc/static_ip.conf; if found, it's used for configuring the IP of the first connected interface (wlan0, eth0 in this order). If this file is absent, it looks for /etc/static_ip.conf (normally created by writeimage.sh) and it copies it over to /data/etc, using it thereafter. If none of the files are present, all the connected interfaces are configured using DHCP.

Here's an example of a static_ip.conf file:

static_ip="192.168.0.3/24"
static_gw="192.168.0.1"
static_dns="8.8.8.8"

Tweaking motionEye

motionEye is installed at /programs/motioneye, on the root partition. After remounting the root partition read-write, you can edit /programs/motioneye/settings.py and its startup script, /etc/init.d/S95motioneye. If you want to override a setting and make it persistent across updates, add it to /data/etc/motioneye.conf (following the file format and syntax).

Tweaking motion

The main motion daemon is (re)started automatically by motionEye when required; it is not started at boot by any init script. The configuration files used by motions can be found at /data/etc/motion.conf and /data/etc/thread-x.conf, where x is the camera number (starting at 1).

You can make changes to these files as you please, but keep in mind that various options corresponding to the settings found in the UI settings panel will be overwritten when applying settings in the UI. However configuration variables that are not covered by the UI are left untouched when settings are applied.

Adding Custom Startup Commands

If you want motionPie run some custom commands at boot, you can create the file /data/etc/userinit.sh and fill it up with your commands.

Make sure it does not block (terminate any blocking command with a & to run it in the background). Any output can be safely redirected to /var/log/your_file; the file will be persisted on the data partition, in the log directory. echo-ing will print to the console (and thus the line will appear in /var/log/boot.log).

There's no need to add a shebang (i.e. #!/bin/sh) at the beginning of the file and there is no need to make it executable. It will be run with the /bin/bash interpreter anyway.

Running Commands At Regular Intervals (Cron Support)

If you need to run a certain command at regular intervals, you can use the builtin cron support. To configure cron, log in using SSH and run the following command:

EDITOR=nano crontab -e

The crontab file is initially empty. After adding your crontab lines, hit Ctrl-O, Enter, Ctrl-X to save and exit the editor. If you're not familiar with the crontab file format, see cron configuration file on Wikipedia.

For example, the following line updates the IP address on freedns.afraid.org dynamic DNS service, every 5 minutes:

3,8,13,18,23,28,33,38,43,48,53,58 * * * * sleep 20 ; wget -O - http://freedns.afraid.org/dynamic/update.php?Rry68SBhp93GbgzL7T57FEb6kK9djtvjXGTDEADBEEF= >> /var/log/dyndns.log 2>&1 &

Loading Custom Modules At Startup

If you wish for a certain module to be loaded at startup (because for some reason it doesn't get loaded automatically, or because you need to supply extra arguments when loading it), you can simply create the file /data/etc/modules and add the module name, along with any optional arguments to it.