Merge pull request #3 from dolfs/prepfix

Prepfix
This commit is contained in:
Scott Lamb 2016-04-30 07:31:57 -07:00
commit 33b24197c3

25
prep.sh
View File

@ -45,43 +45,43 @@
# User and group # User and group
# Default: or whatever is in $NVR_USER (default "moonfire-nvr") # Default: or whatever is in $NVR_USER (default "moonfire-nvr")
# #
NVR_USER= #NVR_USER=
NVR_GROUP= #NVR_GROUP=
# Port for web server # Port for web server
# Default: 8080 # Default: 8080
# #
NVR_PORT= #NVR_PORT=
# This should, ideally, be a location on flash storage under which the # This should, ideally, be a location on flash storage under which the
# moonfire user's home directory will be created. # moonfire user's home directory will be created.
# Default: "/var/lib" # Default: "/var/lib"
# #
NVR_HOME_BASE= #NVR_HOME_BASE=
# Set to mountpoint of media directory, empty to stay in home directory # Set to mountpoint of media directory, empty to stay in home directory
# Default: empty # Default: empty
SAMPLES_DIR= #SAMPLES_DIR=
# Set to path for media directory relative to mountpoint # Set to path for media directory relative to mountpoint
# Default: "samples" # Default: "samples"
# #
SAMPLES_DIR_NAME= #SAMPLES_DIR_NAME=
# Binary location # Binary location
# Default: "/usr/local/bin/moonfire-nvr" # Default: "/usr/local/bin/moonfire-nvr"
# #
SERVICE_BIN= #SERVICE_BIN=
# Service name # Service name
# Default: "moonfire-nvr" # Default: "moonfire-nvr"
# #
SERVICE_NAME= #SERVICE_NAME=
# Service Description # Service Description
# Default: "Moonfire NVR" # Default: "Moonfire NVR"
# #
SERVICE_DESC= #SERVICE_DESC=
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# Derived variables: Do not modify! # Derived variables: Do not modify!
@ -150,6 +150,7 @@ if [ "${SKIP_APT:-0}" != 1 ]; then
libgoogle-perftools-dev \ libgoogle-perftools-dev \
libjsoncpp-dev \ libjsoncpp-dev \
libre2-dev \ libre2-dev \
libssl-dev \
sqlite3 \ sqlite3 \
libsqlite3-dev \ libsqlite3-dev \
pkgconf \ pkgconf \
@ -183,7 +184,7 @@ fi
# #
echo 'Create user/group and directories we need...'; echo echo 'Create user/group and directories we need...'; echo
sudo addgroup --quiet --system ${NVR_GROUP} sudo addgroup --quiet --system ${NVR_GROUP}
sudo adduser --quiet --system ${NVR_USER} --home "${NVR_HOME}" sudo adduser --quiet --system ${NVR_USER} --group "${NVR_GROUP}" --home "${NVR_HOME}"
if [ ! -d "${NVR_HOME}" ]; then if [ ! -d "${NVR_HOME}" ]; then
sudo mkdir "${NVR_HOME}" sudo mkdir "${NVR_HOME}"
fi fi
@ -195,6 +196,8 @@ if [ -z "${SAMPLES_DIR}" ]; then
SAMPLES_PATH="${NVR_HOME}/${SAMPLES_DIR_NAME}" SAMPLES_PATH="${NVR_HOME}/${SAMPLES_DIR_NAME}"
if [ ! -d "${SAMPLES_PATH}" ]; then if [ ! -d "${SAMPLES_PATH}" ]; then
sudo -u ${NVR_USER} -H mkdir "${SAMPLES_PATH}" sudo -u ${NVR_USER} -H mkdir "${SAMPLES_PATH}"
else
chown -R ${NVR_USER}.${NVR_USER} "${SAMPLES_PATH}"
fi fi
else else
SAMPLES_PATH="${SAMPLES_DIR}" SAMPLES_PATH="${SAMPLES_DIR}"
@ -202,6 +205,7 @@ else
sudo mkdir "${SAMPLES_PATH}" sudo mkdir "${SAMPLES_PATH}"
echo ">>> Do not forget to edit /etc/fstab to mount samples media"; echo echo ">>> Do not forget to edit /etc/fstab to mount samples media"; echo
fi fi
chown -R ${NVR_USER}.${NVR_USER} "${SAMPLES_PATH}"
fi fi
@ -249,6 +253,7 @@ NVR_EOF
if [ -f "${SERVICE_PATH}" ]; then if [ -f "${SERVICE_PATH}" ]; then
echo 'Configuring system daemon...'; echo echo 'Configuring system daemon...'; echo
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl enable ${SERVICE_NAME}
sudo systemctl restart ${SERVICE_NAME} sudo systemctl restart ${SERVICE_NAME}
echo 'Getting system daemon status...'; echo echo 'Getting system daemon status...'; echo
sudo systemctl status ${SERVICE_NAME} sudo systemctl status ${SERVICE_NAME}