2021-04-01 15:10:43 -04:00
|
|
|
|
# Installing Moonfire NVR <!-- omit in toc -->
|
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
|
* [Downloading, installing, and configuring Moonfire NVR](#downloading-installing-and-configuring-moonfire-nvr)
|
2021-04-01 15:10:43 -04:00
|
|
|
|
* [Dedicated hard drive setup](#dedicated-hard-drive-setup)
|
|
|
|
|
* [Completing configuration through the UI](#completing-configuration-through-the-ui)
|
|
|
|
|
* [Starting it up](#starting-it-up)
|
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
|
## Downloading, installing, and configuring Moonfire NVR
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2018-08-24 23:45:46 -04:00
|
|
|
|
This document describes how to download, install, and configure Moonfire NVR
|
2023-10-14 18:52:06 -04:00
|
|
|
|
via the prebuilt Linux binaries available for x86-64, arm64, and arm. If you
|
2021-01-21 19:00:38 -05:00
|
|
|
|
instead want to build Moonfire NVR yourself, see the [Build
|
|
|
|
|
instructions](build.md).
|
2018-08-24 23:45:46 -04:00
|
|
|
|
|
2023-12-05 11:44:34 -05:00
|
|
|
|
<table><tr><td><details>
|
|
|
|
|
<summary>Go to the instructions for your exact Moonfire version</summary>
|
|
|
|
|
|
|
|
|
|
Make sure you are viewing instructions that match the release you intend
|
2022-03-11 18:37:09 -05:00
|
|
|
|
to install. When viewing this page on Github, look for a pull-down in the upper
|
2023-07-08 18:25:05 -04:00
|
|
|
|
left, and pick the [latest tagged version](https://github.com/scottlamb/moonfire-nvr/releases/latest):
|
2022-03-11 18:37:09 -05:00
|
|
|
|
|
2023-12-05 11:44:34 -05:00
|
|
|
|
<img src="install-version.png" height=367 alt="Selecting a version of install instructions">
|
|
|
|
|
|
|
|
|
|
</details></td></tr></table>
|
|
|
|
|
|
2022-03-11 18:37:09 -05:00
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
|
Download the binary for your platform from the matching GitHub release.
|
|
|
|
|
Install it as `/usr/local/bin/moonfire-nvr` and ensure it is executable, e.g.
|
2023-12-29 18:37:58 -05:00
|
|
|
|
for version `v0.7.11`:
|
2021-08-23 15:40:14 -04:00
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
|
```console
|
2023-12-29 18:37:58 -05:00
|
|
|
|
$ VERSION=v0.7.11
|
2023-11-27 20:48:02 -05:00
|
|
|
|
$ ARCH=$(uname -m)
|
2023-10-14 18:52:06 -04:00
|
|
|
|
$ curl -OL "https://github.com/scottlamb/moonfire-nvr/releases/download/$VERSION/moonfire-nvr-$VERSION-$ARCH"
|
|
|
|
|
$ sudo install -m 755 "moonfire-nvr-$VERSION-$ARCH" /usr/local/bin/moonfire-nvr
|
|
|
|
|
```
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2023-12-05 11:44:34 -05:00
|
|
|
|
<table><tr><td><details>
|
2023-11-27 20:48:02 -05:00
|
|
|
|
<summary>Docker</summary>
|
|
|
|
|
|
2024-01-31 20:23:35 -05:00
|
|
|
|
The procedure above, in which Moonfire runs directly on the host, is strongly
|
|
|
|
|
recommended.
|
|
|
|
|
|
|
|
|
|
* The single binary installed in `/usr/local/bin` has zero dependencies.
|
|
|
|
|
It is statically linked and bundles the UI. It just works. There's no
|
|
|
|
|
complex distribution-specific install procedures or danger of conflicting
|
|
|
|
|
version requirements between Moonfire and other software. These are the same
|
|
|
|
|
problems most people use Docker to solve.
|
|
|
|
|
* Moonfire's recommended install method used to involve Docker. In our
|
|
|
|
|
experience, complexity around Docker commands, filesystem/process namespace
|
|
|
|
|
mappings, broken seccomp defaults that do not allow standard system calls
|
|
|
|
|
like `clock_gettime`, etc. has been a major frustration for folks installing
|
|
|
|
|
Moonfire. Now that we have the zero-dependencies binary, we recommend
|
|
|
|
|
sidestepping all of this and have rewritten the docs accordingly.
|
|
|
|
|
|
|
|
|
|
…but, you may still prefer Docker for familiarity or other reasons. If so, you
|
|
|
|
|
can install the [`ghcr.io/scottlamb/moonfire-nvr`](https://github.com/scottlamb/moonfire-nvr/pkgs/container/moonfire-nvr) Docker images instead. We'll
|
|
|
|
|
assume you know your way around your preferred tools and can adapt the
|
|
|
|
|
instructions to the workflow you use with Docker. You may find the following
|
|
|
|
|
Docker compose snippet useful:
|
2023-11-27 20:48:02 -05:00
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
version: 3
|
|
|
|
|
services:
|
|
|
|
|
moonfire-nvr:
|
2024-01-31 20:23:35 -05:00
|
|
|
|
# The `vX.Y.Z` images will work on any architecture (x86-64, arm, or
|
|
|
|
|
# aarch64); just pick the correct version.
|
2023-12-29 18:37:58 -05:00
|
|
|
|
image: ghcr.io/scottlamb/moonfire-nvr:v0.7.11
|
2023-11-27 20:48:02 -05:00
|
|
|
|
command: run
|
|
|
|
|
|
|
|
|
|
volumes:
|
2023-12-05 11:44:34 -05:00
|
|
|
|
# Pass through `/var/lib/moonfire-nvr` from the host.
|
2023-11-27 20:48:02 -05:00
|
|
|
|
- "/var/lib/moonfire-nvr:/var/lib/moonfire-nvr"
|
|
|
|
|
|
|
|
|
|
# Pass through `/etc/moonfire-nvr.toml` from the host.
|
2023-12-05 11:44:34 -05:00
|
|
|
|
# Be sure to create `/etc/moonfire-nvr.toml` first (see below).
|
|
|
|
|
# Docker will "helpfully" create a directory by this name otherwise.
|
2023-11-27 20:48:02 -05:00
|
|
|
|
- "/etc/moonfire-nvr.toml:/etc/moonfire-nvr.toml:ro"
|
|
|
|
|
|
2023-12-29 19:23:38 -05:00
|
|
|
|
# Pass through `/var/tmp` from the host.
|
|
|
|
|
# SQLite expects to be able to create temporary files in this dir, which
|
|
|
|
|
# is not created in Moonfire's minimal Docker image.
|
|
|
|
|
# See: <https://www.sqlite.org/tempfiles.html>
|
|
|
|
|
- "/var/tmp:/var/tmp"
|
|
|
|
|
|
2023-11-27 20:48:02 -05:00
|
|
|
|
# Add additional mount lines here for each sample file directory
|
|
|
|
|
# outside of /var/lib/moonfire-nvr, e.g.:
|
|
|
|
|
# - "/media/nvr:/media/nvr"
|
|
|
|
|
|
|
|
|
|
# The Docker image doesn't include the time zone database; you must mount
|
|
|
|
|
# it from the host for Moonfire to support local time.
|
|
|
|
|
- "/usr/share/zoneinfo:/usr/share/zoneinfo:ro"
|
|
|
|
|
|
2023-12-05 11:44:34 -05:00
|
|
|
|
# Edit this to match your `moonfire-nvr` user.
|
2024-01-31 20:23:35 -05:00
|
|
|
|
# Note that Docker will not honor names from the host here, even if
|
|
|
|
|
# `/etc/passwd` is passed through.
|
2023-12-05 11:44:34 -05:00
|
|
|
|
# - Be sure to run the `useradd` command below first.
|
2023-12-05 12:11:41 -05:00
|
|
|
|
# - Then run `echo $(id -u moonfire-nvr):$(id -g moonfire-nvr)` to see
|
2023-12-05 11:44:34 -05:00
|
|
|
|
# what should be filled in here.
|
2023-11-27 20:48:02 -05:00
|
|
|
|
user: UID:GID
|
|
|
|
|
|
|
|
|
|
# Uncomment this if Moonfire fails with `clock_gettime failed` (likely on
|
|
|
|
|
# older 32-bit hosts). <https://github.com/moby/moby/issues/40734>
|
|
|
|
|
# security_opt:
|
|
|
|
|
# - seccomp:unconfined
|
|
|
|
|
|
|
|
|
|
environment:
|
|
|
|
|
# Edit zone below to taste. The `:` is functional.
|
|
|
|
|
TZ: ":America/Los_Angeles"
|
|
|
|
|
RUST_BACKTRACE: 1
|
|
|
|
|
|
|
|
|
|
# docker's default log driver won't rotate logs properly, and will throw
|
|
|
|
|
# away logs when you destroy and recreate the container. Using journald
|
|
|
|
|
# solves these problems.
|
|
|
|
|
# <https://docs.docker.com/config/containers/logging/configure/>
|
|
|
|
|
logging:
|
|
|
|
|
driver: journald
|
|
|
|
|
options:
|
|
|
|
|
tag: moonfire-nvr
|
|
|
|
|
|
|
|
|
|
restart: unless-stopped
|
|
|
|
|
|
|
|
|
|
ports:
|
|
|
|
|
- "8080:8080/tcp"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Command reference:
|
|
|
|
|
|
2023-12-05 12:00:41 -05:00
|
|
|
|
<table>
|
|
|
|
|
|
|
|
|
|
<tr><th colspan="2">Initialize the database</th></tr>
|
|
|
|
|
<tr><th>Non-Docker</th><td><code>sudo -u moonfire-nvr moonfire-nvr init</code></td></tr>
|
|
|
|
|
<tr><th>Docker</th><td><code>sudo docker compose run --rm moonfire-nvr init</code></td></tr>
|
|
|
|
|
|
|
|
|
|
<tr><th colspan="2">Run interactive configuration</th></tr>
|
|
|
|
|
<tr><th>Non-Docker</th><td><code>sudo -u moonfire-nvr moonfire-nvr config 2>debug-log</code></td></tr>
|
|
|
|
|
<tr><th>Docker</th><td><code>sudo docker compose run --rm moonfire-nvr config 2>debug-log</code></td></tr>
|
|
|
|
|
|
|
|
|
|
<tr><th colspan="2">Enable and start the server</th></tr>
|
|
|
|
|
<tr><th>Non-Docker<td><code>sudo systemctl enable --now moonfire-nvr</code></td></tr>
|
|
|
|
|
<tr><th>Docker</th><td><code>sudo docker compose up --detach moonfire-nvr</code></td></tr>
|
|
|
|
|
|
|
|
|
|
</table>
|
2023-11-27 20:48:02 -05:00
|
|
|
|
|
2023-12-05 11:44:34 -05:00
|
|
|
|
</details></td></tr></table>
|
2023-11-27 20:48:02 -05:00
|
|
|
|
|
2021-04-09 01:15:31 -04:00
|
|
|
|
Next, you'll need to set up your filesystem and the Moonfire NVR user.
|
2021-01-21 19:00:38 -05:00
|
|
|
|
|
|
|
|
|
Moonfire NVR keeps two kinds of state:
|
|
|
|
|
|
|
|
|
|
* a SQLite database, typically <1 GiB. It should be stored on flash if
|
|
|
|
|
available. In most cases your root filesystem is on flash, so the
|
|
|
|
|
default location of `/var/lib/moonfire-nvr/db` will be fine.
|
|
|
|
|
* the "sample file directories", which hold the actual samples/frames of
|
|
|
|
|
H.264 video. These should be quite large and are typically stored on hard
|
|
|
|
|
drives. More below.
|
|
|
|
|
|
|
|
|
|
(See [schema.md](schema.md) for more information.)
|
|
|
|
|
|
|
|
|
|
On most Linux systems, you can create the user as follows:
|
|
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
|
```console
|
2021-01-21 19:00:38 -05:00
|
|
|
|
$ sudo useradd --user-group --create-home --home /var/lib/moonfire-nvr moonfire-nvr
|
2019-07-10 02:48:06 -04:00
|
|
|
|
```
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
|
Use your favorite editor to create `/etc/moonfire-nvr.toml`,
|
|
|
|
|
starting from the configurations below:
|
2021-08-23 15:40:14 -04:00
|
|
|
|
|
|
|
|
|
```console
|
2022-03-16 15:28:08 -04:00
|
|
|
|
$ sudo nano /etc/moonfire-nvr.toml
|
2022-03-11 18:02:29 -05:00
|
|
|
|
(see below for contents)
|
2021-01-21 19:00:38 -05:00
|
|
|
|
```
|
2021-08-23 15:40:14 -04:00
|
|
|
|
|
2023-01-06 12:40:41 -05:00
|
|
|
|
`/etc/moonfire-nvr.toml` (see [ref/config.md](../ref/config.md) for more explanation):
|
2022-03-16 15:28:08 -04:00
|
|
|
|
```toml
|
|
|
|
|
[[binds]]
|
|
|
|
|
ipv4 = "0.0.0.0:8080"
|
2022-12-31 12:08:26 -05:00
|
|
|
|
allowUnauthenticatedPermissions = { viewVideo = true }
|
2022-03-16 15:28:08 -04:00
|
|
|
|
|
|
|
|
|
[[binds]]
|
|
|
|
|
unix = "/var/lib/moonfire-nvr/sock"
|
2022-12-31 12:08:26 -05:00
|
|
|
|
ownUidIsPrivileged = true
|
2022-03-11 18:02:29 -05:00
|
|
|
|
```
|
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
|
Then initialize the database:
|
2021-01-21 19:00:38 -05:00
|
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
|
```console
|
2023-10-14 18:52:06 -04:00
|
|
|
|
$ sudo -u moonfire-nvr moonfire-nvr init
|
2021-01-21 19:00:38 -05:00
|
|
|
|
```
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2021-01-21 19:00:38 -05:00
|
|
|
|
This will create a directory `/var/lib/moonfire-nvr/db` with a SQLite3 database
|
|
|
|
|
within it.
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2021-04-01 15:10:43 -04:00
|
|
|
|
### Dedicated hard drive setup
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2021-07-13 19:08:50 -04:00
|
|
|
|
If a dedicated hard drive is available, set it up now.
|
|
|
|
|
|
|
|
|
|
If you haven't yet created the filesystem, consider using
|
|
|
|
|
`mkfs.ext4 -T largefile -m 1`, as described in more detail [on the
|
|
|
|
|
wiki](https://github.com/scottlamb/moonfire-nvr/wiki/System-setup). If you're
|
|
|
|
|
using a USB SATA bridge, this is also a good time to ensure you're not
|
|
|
|
|
using UAS, as described there. UAS has been linked to filesystem corruption.
|
|
|
|
|
|
2021-08-26 12:47:59 -04:00
|
|
|
|
Set up the mount point and sample file directory:
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
|
```console
|
2022-03-11 18:02:29 -05:00
|
|
|
|
$ sudo blkid
|
|
|
|
|
(note the UUID of your new device)
|
|
|
|
|
$ sudo nano /etc/fstab
|
|
|
|
|
(see below for line to add)
|
|
|
|
|
$ sudo mkdir -p /media/nvr
|
2019-07-10 02:48:06 -04:00
|
|
|
|
$ sudo mount /media/nvr
|
|
|
|
|
$ sudo install -d -o moonfire-nvr -g moonfire-nvr -m 700 /media/nvr/sample
|
|
|
|
|
```
|
2018-08-24 23:45:46 -04:00
|
|
|
|
|
2019-07-10 02:48:06 -04:00
|
|
|
|
In `/etc/fstab`, add a line similar to this:
|
2018-08-24 23:45:46 -04:00
|
|
|
|
|
2019-07-10 02:48:06 -04:00
|
|
|
|
```
|
2021-04-12 00:15:45 -04:00
|
|
|
|
UUID=23d550bc-0e38-4825-acac-1cac8a7e091f /media/nvr ext4 nofail,noatime,lazytime,data=writeback,journal_async_commit 0 2
|
2019-07-10 02:48:06 -04:00
|
|
|
|
```
|
2018-08-24 23:45:46 -04:00
|
|
|
|
|
|
|
|
|
If you use the `nofail` attribute in `/etc/fstab` as described above, your
|
|
|
|
|
system will boot successfully even when the hard drive is unavailable (such as
|
2021-01-21 19:00:38 -05:00
|
|
|
|
when your external USB storage is unmounted). This can be helpful when
|
|
|
|
|
recovering from problems.
|
2018-08-24 23:45:46 -04:00
|
|
|
|
|
2021-04-01 15:10:43 -04:00
|
|
|
|
### Completing configuration through the UI
|
2018-08-24 23:45:46 -04:00
|
|
|
|
|
2021-01-21 19:00:38 -05:00
|
|
|
|
Once your system is set up, it's time to initialize an empty database
|
|
|
|
|
and add the cameras and sample directories. You can do this
|
2020-07-18 04:26:58 -04:00
|
|
|
|
by using the `moonfire-nvr` binary's text-based configuration tool.
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
|
```console
|
2023-10-14 18:52:06 -04:00
|
|
|
|
$ sudo -u moonfire-nvr moonfire-nvr config 2>debug-log
|
2019-07-10 02:48:06 -04:00
|
|
|
|
```
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2023-12-05 11:44:34 -05:00
|
|
|
|
<table><tr><td><details>
|
|
|
|
|
<summary>Did it return without doing anything?</summary>
|
2021-08-23 15:40:14 -04:00
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
|
If `moonfire-nvr config` returns you to the console prompt right away, look in
|
|
|
|
|
the `debug-log` file for why. One common reason is that you have Moonfire NVR
|
|
|
|
|
running; you'll need to shut it down first. If you are running a systemd
|
|
|
|
|
service as described below, try `sudo systemctl stop moonfire-nvr` before
|
|
|
|
|
editing the config and `sudo systemctl start moonfire-nvr` after.
|
2023-12-05 11:44:34 -05:00
|
|
|
|
</details></td></tr></table>
|
2021-08-23 15:40:14 -04:00
|
|
|
|
|
2018-02-12 01:45:51 -05:00
|
|
|
|
In the user interface,
|
|
|
|
|
|
2021-04-01 12:39:14 -04:00
|
|
|
|
1. add your sample file dir(s) under "Directories and retention".
|
2021-08-26 12:47:59 -04:00
|
|
|
|
(Many streams can share a directory. It's recommended to have just one
|
|
|
|
|
directory per hard drive.)
|
|
|
|
|
|
2019-07-10 02:48:06 -04:00
|
|
|
|
If you used a dedicated hard drive, use the directory you precreated
|
2021-01-21 19:00:38 -05:00
|
|
|
|
(eg `/media/nvr/sample`). Otherwise, try
|
2019-07-10 02:48:06 -04:00
|
|
|
|
`/var/lib/moonfire-nvr/sample`. Moonfire NVR will create the directory as
|
|
|
|
|
long as it has the required permissions on the parent directory.
|
|
|
|
|
|
2021-04-01 12:39:14 -04:00
|
|
|
|
2. add cameras under "Cameras and streams".
|
2018-08-24 23:45:46 -04:00
|
|
|
|
|
2021-04-01 15:10:43 -04:00
|
|
|
|
* See the [wiki](https://github.com/scottlamb/moonfire-nvr/wiki) for notes
|
2021-04-27 13:59:55 -04:00
|
|
|
|
about specific camera models. The [Configuring cameras](https://github.com/scottlamb/moonfire-nvr/wiki/Configuring-cameras)
|
|
|
|
|
page mentions a couple tools that can autodetect RTSP URLs.
|
2021-04-01 15:10:43 -04:00
|
|
|
|
|
|
|
|
|
* There's a "Test" button to verify your settings directly from the add/edit
|
|
|
|
|
camera dialog.
|
|
|
|
|
|
|
|
|
|
* Be sure to assign each stream you want to capture to a sample file
|
|
|
|
|
directory and check the "record" box.
|
|
|
|
|
|
|
|
|
|
* `flush_if_sec` should typically be 120 seconds. This causes the database to
|
|
|
|
|
be flushed when the first instant of one of this stream's completed
|
|
|
|
|
recordings is 2 minutes old. A "recording" is a segment of a video
|
|
|
|
|
stream that is 60–120 seconds when first establishing the stream,
|
|
|
|
|
about 60 seconds midstream, and shorter when an error or server
|
|
|
|
|
shutdown terminates the stream. Thus, a value just below 60 will
|
|
|
|
|
cause the database to be flushed once per minute per stream in the
|
|
|
|
|
steady state. A value around 180 will cause the database to be once
|
|
|
|
|
every 3 minutes per stream, or less frequently if other streams cause
|
|
|
|
|
flushes first. Lower values cause less video to be lost on power
|
|
|
|
|
loss. Higher values reduce wear on the SSD holding the SQLite
|
|
|
|
|
database, particularly when you have many cameras and when you record
|
|
|
|
|
both the "main" and "sub" streams of each camera.
|
2018-12-27 17:00:15 -05:00
|
|
|
|
|
2021-04-01 12:39:14 -04:00
|
|
|
|
3. Assign disk space to your cameras back in "Directories and retention".
|
|
|
|
|
Leave a little slack between the total limit and the filesystem capacity,
|
2021-08-26 12:47:59 -04:00
|
|
|
|
even if you store nothing else on the disk. 1 GiB of slack per camera should
|
|
|
|
|
be plenty. This is needed for a few reasons:
|
2021-04-01 12:39:14 -04:00
|
|
|
|
|
|
|
|
|
* Up to `max(120, flush_if_sec)` seconds of video can be written before
|
|
|
|
|
being counted toward the usage because the recording doesn't count until
|
|
|
|
|
it's fully written, and old recordings can't be deleted until the
|
|
|
|
|
next database flush. So a 8 Mbps video stream with `flush_if_sec=300`
|
|
|
|
|
will take up to (8 Mbps * 300 sec / 8 bits/byte) = 300 MB ~= 286 MiB
|
|
|
|
|
of extra disk space.
|
|
|
|
|
* If a file is open when it is deleted (such as if a HTTP client is
|
|
|
|
|
downloading it), it stays around until the file is closed. Moonfire NVR
|
|
|
|
|
currently doesn't account for this.
|
|
|
|
|
* Smaller factors: deletion isn't instantaneous, and directories
|
|
|
|
|
themselves take up some disk space.
|
|
|
|
|
|
|
|
|
|
4. Add a user for yourself (and optionally others) under "Users". You'll need
|
2018-12-27 17:00:15 -05:00
|
|
|
|
this to access the web UI once you enable authentication.
|
|
|
|
|
|
2021-04-01 15:10:43 -04:00
|
|
|
|
### Starting it up
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2022-03-11 14:51:28 -05:00
|
|
|
|
With this config, Moonfire NVR's web interface is **insecure**: it doesn't use
|
|
|
|
|
`https` and doesn't require you to authenticate to it. You might be comfortable
|
|
|
|
|
starting it in this configuration to try it out, particularly if the machine
|
|
|
|
|
it's running on is behind a home router's firewall. You might not; in that case
|
|
|
|
|
read through [secure the system](secure.md) first.
|
2018-12-27 17:00:15 -05:00
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
|
Assuming you want to proceed, you can launch Moonfire NVR through `systemd`.
|
|
|
|
|
Create `/etc/systemd/system/moonfire-nvr.service`:
|
|
|
|
|
|
|
|
|
|
```ini
|
|
|
|
|
[Unit]
|
|
|
|
|
Description=Moonfire NVR
|
|
|
|
|
After=network-online.target
|
|
|
|
|
|
|
|
|
|
# If you use an external hard drive, uncomment this with a reference to the
|
|
|
|
|
# mount point as written in `/etc/fstab`.
|
|
|
|
|
# RequiresMountsFor=/media/nvr
|
|
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
ExecStart=/usr/local/bin/moonfire-nvr run
|
|
|
|
|
Environment=TZ=:/etc/localtime
|
|
|
|
|
Environment=MOONFIRE_FORMAT=systemd
|
|
|
|
|
Environment=MOONFIRE_LOG=info
|
|
|
|
|
Environment=RUST_BACKTRACE=1
|
2023-10-20 00:34:28 -04:00
|
|
|
|
Type=notify
|
2023-10-23 23:00:52 -04:00
|
|
|
|
# large installations take a while to scan the sample file dirs
|
|
|
|
|
TimeoutStartSec=300
|
2023-10-14 18:52:06 -04:00
|
|
|
|
User=moonfire-nvr
|
|
|
|
|
Restart=on-failure
|
|
|
|
|
CPUAccounting=true
|
|
|
|
|
MemoryAccounting=true
|
|
|
|
|
BlockIOAccounting=true
|
|
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Then start it up as follows:
|
|
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
$ sudo systemctl daemon-reload # read in the new config file
|
|
|
|
|
$ sudo systemctl enable --now moonfire-nvr # start the service now and on boot
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Some handy commands:
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
|
```console
|
2023-10-14 18:52:06 -04:00
|
|
|
|
$ sudo systemctl daemon-reload # reload configuration files
|
|
|
|
|
$ sudo systemctl start moonfire-nvr # start the service now without enabling on boot
|
|
|
|
|
$ sudo systemctl stop moonfire-nvr # stop the service now (but don't wait for it finish stopping)
|
|
|
|
|
$ sudo systemctl status moonfire-nvr # show if the service is running and the last few log lines
|
|
|
|
|
$ sudo systemctl enable moonfire-nvr # start the service on boot
|
|
|
|
|
$ sudo systemctl disable moonfire-nvr # don't start the service on boot
|
|
|
|
|
$ sudo journalctl --unit=moonfire-nvr --since='-5 min' --follow # look at recent logs and await more
|
2019-07-10 02:48:06 -04:00
|
|
|
|
```
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
|
See the [systemd](http://www.freedesktop.org/wiki/Software/systemd/)
|
|
|
|
|
documentation for more information. The [manual
|
|
|
|
|
pages](http://www.freedesktop.org/software/systemd/man/) for `systemd.service`
|
|
|
|
|
and `systemctl` may be of particular interest.
|
2021-01-21 19:00:38 -05:00
|
|
|
|
|
2018-12-27 17:00:15 -05:00
|
|
|
|
The HTTP interface is accessible on port 8080; if your web browser is running
|
|
|
|
|
on the same machine, you can access it at
|
|
|
|
|
[http://localhost:8080/](http://localhost:8080/).
|
2017-10-02 01:02:39 -04:00
|
|
|
|
|
2018-08-24 23:45:46 -04:00
|
|
|
|
If the system isn't working, see the [Troubleshooting
|
|
|
|
|
guide](troubleshooting.md).
|
2018-12-27 17:00:15 -05:00
|
|
|
|
|
2021-07-13 19:08:50 -04:00
|
|
|
|
See also the [system setup guide](https://github.com/scottlamb/moonfire-nvr/wiki/System-setup)
|
|
|
|
|
on the wiki, which has additional advice on configuring a Linux system which
|
|
|
|
|
runs Moonfire NVR.
|
|
|
|
|
|
2018-12-27 17:00:15 -05:00
|
|
|
|
Once the web interface seems to be working, read through [securing Moonfire
|
|
|
|
|
NVR](secure.md).
|