2014-12-01 00:55:26 +08:00
|
|
|
#!/bin/sh
|
2014-12-02 07:58:18 +08:00
|
|
|
# config maintainer script for zoneminder
|
2014-12-01 00:55:26 +08:00
|
|
|
|
2014-12-10 23:11:56 +08:00
|
|
|
set -ex
|
2014-12-01 00:55:26 +08:00
|
|
|
|
2014-12-02 07:58:18 +08:00
|
|
|
# Source the debconf stuff
|
2014-12-01 00:55:26 +08:00
|
|
|
. /usr/share/debconf/confmodule
|
|
|
|
|
2014-12-10 23:11:56 +08:00
|
|
|
# Set the first version in which dbconfig-common was introduced in the package
|
|
|
|
dbc_first_version="1.28.0"
|
2014-12-01 00:55:26 +08:00
|
|
|
|
2014-12-10 23:11:56 +08:00
|
|
|
CONFIGFILE=/etc/zm/zm.conf
|
2014-12-01 00:55:26 +08:00
|
|
|
|
2014-12-02 07:58:18 +08:00
|
|
|
# Source the config file if exists
|
|
|
|
if [ -e $CONFIGFILE ]; then
|
|
|
|
. $CONFIGFILE || true
|
|
|
|
else
|
2014-12-08 23:57:37 +08:00
|
|
|
# Display a message and exit with error if no config file
|
2014-12-07 00:50:13 +08:00
|
|
|
db_input high zoneminder/debconf_confmissingerror || true
|
|
|
|
db_go || true
|
2014-12-08 23:57:37 +08:00
|
|
|
exit 1
|
2014-12-02 07:58:18 +08:00
|
|
|
fi
|
2014-12-01 00:55:26 +08:00
|
|
|
|
2014-12-07 00:50:13 +08:00
|
|
|
if [ ! "$ZM_DB_TYPE" = "mysql" ]; then
|
2014-12-08 23:57:37 +08:00
|
|
|
# Display a message and exit with error if wrong database type
|
2014-12-07 00:50:13 +08:00
|
|
|
db_input high zoneminder/debconf_dbtypeerror || true
|
|
|
|
db_go || true
|
2014-12-08 23:57:37 +08:00
|
|
|
exit 1
|
2014-12-07 00:50:13 +08:00
|
|
|
fi
|
|
|
|
|
2014-12-10 23:11:56 +08:00
|
|
|
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
|
|
|
|
|
|
|
|
# Currently we only support mysql database
|
|
|
|
dbc_dbtypes="mysql"
|
|
|
|
|
|
|
|
# Set authentication method to password
|
|
|
|
dbc_authmethod_user="password"
|
|
|
|
|
|
|
|
# Re-use data from ZM config file
|
|
|
|
dbc_dbserver="$ZM_DB_HOST"
|
|
|
|
dbc_dbname="$ZM_DB_NAME"
|
|
|
|
dbc_dbuser="$ZM_DB_USER"
|
|
|
|
|
|
|
|
# Source the dbconfig-common stuff
|
|
|
|
. /usr/share/dbconfig-common/dpkg/config
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "configure" ]; then
|
|
|
|
|
|
|
|
# Ask the user if debconf shall be used to configure the package
|
|
|
|
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
|
|
|
|
[ "$RET" = "false" ] && exit 0
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then
|
|
|
|
|
2014-12-07 22:18:08 +08:00
|
|
|
DB_OK=false
|
|
|
|
|
2014-12-07 00:50:13 +08:00
|
|
|
# Ask the user if the database shall be installed locally or remotely
|
2014-12-07 07:04:26 +08:00
|
|
|
db_input high zoneminder/debconf_dblocation || true
|
2014-12-07 00:50:13 +08:00
|
|
|
db_go || true
|
|
|
|
db_get zoneminder/debconf_dblocation
|
|
|
|
if [ "$RET" = "local" ]; then
|
2014-12-02 07:58:18 +08:00
|
|
|
if [ ! -e "/usr/sbin/mysqld" ]; then
|
2014-12-07 22:18:08 +08:00
|
|
|
# Display a message if the user want a local database but no database
|
|
|
|
# server is available
|
2014-12-07 07:04:26 +08:00
|
|
|
db_input high zoneminder/debconf_dblocalmissingerror || true
|
2014-12-02 07:58:18 +08:00
|
|
|
db_go || true
|
2014-12-07 22:18:08 +08:00
|
|
|
else
|
|
|
|
DB_OK=true
|
|
|
|
# Set the database server to localhost
|
|
|
|
dbc_dbserver="localhost"
|
2014-12-02 07:58:18 +08:00
|
|
|
fi
|
2014-12-04 01:22:19 +08:00
|
|
|
else
|
2014-12-07 00:50:13 +08:00
|
|
|
# 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
|
2014-12-07 22:18:08 +08:00
|
|
|
# Display a message if the dbconfig configuration does not allow
|
2014-12-07 00:50:13 +08:00
|
|
|
# installation of databases on remote servers from this assistant
|
2014-12-07 22:18:08 +08:00
|
|
|
# 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
|
2014-12-07 00:50:13 +08:00
|
|
|
# https://bugs.launchpad.net/ubuntu/+source/dbconfig-common/+bug/1065331
|
2014-12-07 07:04:26 +08:00
|
|
|
db_input high zoneminder/debconf_dbconfigerror || true
|
2014-12-07 00:50:13 +08:00
|
|
|
db_go || true
|
2014-12-07 22:18:08 +08:00
|
|
|
else
|
|
|
|
DB_OK=true
|
2014-12-07 00:50:13 +08:00
|
|
|
fi
|
2014-12-02 07:58:18 +08:00
|
|
|
fi
|
2014-12-01 00:55:26 +08:00
|
|
|
|
2014-12-10 23:11:56 +08:00
|
|
|
#if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then
|
2014-12-07 00:50:13 +08:00
|
|
|
|
2014-12-10 23:11:56 +08:00
|
|
|
# If db config is ok, ask the user for all other settings about the database
|
|
|
|
[ "$DB_OK" = "true" ] && dbc_go zoneminder $@
|
2014-12-02 07:58:18 +08:00
|
|
|
|
2014-12-08 23:57:37 +08:00
|
|
|
# Ask the user for the web server(s) to configure
|
|
|
|
db_input high zoneminder/webserver || true
|
|
|
|
db_go || true
|
|
|
|
|
|
|
|
# Ask the user for the password of the database administrator if the user
|
|
|
|
# has not yet answered this question. This may happen if the user skipped
|
|
|
|
# the database creation step when reconfiguring the package.
|
|
|
|
RET=""
|
|
|
|
db_get zoneminder/mysql/admin-pass
|
|
|
|
if [ -z "$RET" ]; then
|
|
|
|
db_input high zoneminder/mysql/admin-pass || true
|
|
|
|
db_go || true
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ask for the password of 'admin' user
|
|
|
|
while :; do
|
|
|
|
RET=""
|
|
|
|
db_input high zoneminder/admin_password || true
|
|
|
|
db_go || true
|
|
|
|
db_get zoneminder/admin_password
|
|
|
|
# If password isn't empty we ask for password verification
|
|
|
|
if [ -z "$RET" ]; then
|
|
|
|
db_fset zoneminder/admin_password seen false
|
|
|
|
db_fset zoneminder/admin_password_again seen false
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
ROOT_PW="$RET"
|
|
|
|
db_input high zoneminder/admin_password_again || true
|
|
|
|
db_go || true
|
|
|
|
db_get zoneminder/admin_password_again
|
|
|
|
if [ "$RET" = "$ROOT_PW" ]; then
|
|
|
|
ROOT_PW=""
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
db_fset zoneminder/password_mismatch seen false
|
|
|
|
db_input critical zoneminder/password_mismatch || true
|
|
|
|
db_set zoneminder/admin_password ""
|
|
|
|
db_set zoneminder/admin_password_again ""
|
|
|
|
db_go || true
|
|
|
|
done
|
|
|
|
|
|
|
|
fi
|
2014-12-02 07:58:18 +08:00
|
|
|
|
2014-12-03 21:12:26 +08:00
|
|
|
#DEBHELPER#
|
|
|
|
|
2014-12-01 00:55:26 +08:00
|
|
|
exit 0
|