118 lines
3.4 KiB
Bash
118 lines
3.4 KiB
Bash
#!/bin/sh
|
|
# config maintainer script for zoneminder
|
|
|
|
set -e
|
|
|
|
# Source the debconf stuff
|
|
. /usr/share/debconf/confmodule
|
|
|
|
CONFIGFILE=/etc/zm/zm.conf
|
|
|
|
if [ "$1" = "configure" ]; then
|
|
|
|
# Ask the user if debconf shall be used to configure the package
|
|
db_set zoneminder/debconf_install true
|
|
db_input high zoneminder/debconf_install || true
|
|
db_go || true
|
|
|
|
# Exit if the user does not want to use debconf
|
|
db_get zoneminder/debconf_install
|
|
if [ "$RET" = "false" ]; then
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# Source the config file if exists
|
|
if [ -e $CONFIGFILE ]; then
|
|
. $CONFIGFILE || true
|
|
else
|
|
# Exit with error if no config file
|
|
db_input high zoneminder/debconf_confmissingerror || true
|
|
db_go || true
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! "$ZM_DB_TYPE" = "mysql" ]; then
|
|
# Exit with error, currently we only support mysql
|
|
db_input high zoneminder/debconf_dbtypeerror || true
|
|
db_go || true
|
|
exit 1
|
|
fi
|
|
|
|
# Ask the user if the database shall be installed locally or remotely
|
|
db_input high zoneminder/debconf_dblocation || true
|
|
db_go || true
|
|
db_get zoneminder/debconf_dblocation
|
|
if [ "$RET" = "local" ]; then
|
|
if [ ! -e "/usr/sbin/mysqld" ]; then
|
|
# Display a message and exit if the user want a local database but no
|
|
# database server is available
|
|
db_input high zoneminder/debconf_dblocalmissingerror || true
|
|
db_go || true
|
|
exit 1
|
|
fi
|
|
# Set the database server to localhost
|
|
dbc_dbserver="localhost"
|
|
else
|
|
# Source the dbconfig main configuration file
|
|
if [ -f /etc/dbconfig-common/config ]; then
|
|
. /etc/dbconfig-common/config
|
|
fi
|
|
if [ "$dbc_remote_questions_default" = "false" ]; then
|
|
# Display a message and exit if the dbconfig configuration does not allow
|
|
# installation of databases on remote servers from this assistant
|
|
# Note: It would be nice to override the default configuration by setting
|
|
# dbc_remote_questions_default to true here but unfortunately this does
|
|
# not work
|
|
# https://bugs.launchpad.net/ubuntu/+source/dbconfig-common/+bug/1065331
|
|
db_input high zoneminder/debconf_dbconfigerror || true
|
|
db_go || true
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
|
|
|
|
# Set the first version in which dbconfig-common was introduced in the
|
|
# package
|
|
dbc_first_version="1.28.0"
|
|
|
|
# Currently we only support mysql database
|
|
dbc_dbtypes="mysql"
|
|
|
|
# Set authentication method to password
|
|
dbc_authmethod_user="password"
|
|
|
|
if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then
|
|
# Force the use of the database name and application user name set in
|
|
# the zoneminder configuration file
|
|
dbc_dbname="$ZM_DB_NAME"
|
|
dbc_dbuser="$ZM_DB_USER"
|
|
fi
|
|
|
|
# Reuse custom hostname and password when reconfiguring
|
|
if [ "$1" = "reconfigure" ]; then
|
|
dbc_dbserver="$ZM_DB_HOST"
|
|
dbc_dbpass="$ZM_DB_PASS"
|
|
fi
|
|
|
|
# Source the dbconfig-common stuff
|
|
. /usr/share/dbconfig-common/dpkg/config
|
|
|
|
# Ask the user for all other settings about the database
|
|
dbc_go zoneminder $@
|
|
fi
|
|
|
|
# Ask the user for the administrator login and password
|
|
db_input high zoneminder/admin_login || true
|
|
db_input high zoneminder/admin_password || true
|
|
db_go || true
|
|
|
|
# Ask the user for the web server(s) to configure
|
|
db_input high zoneminder/webserver || true
|
|
db_go || true
|
|
|
|
#DEBHELPER#
|
|
|
|
exit 0
|