Add files for debconf support

This commit is contained in:
Emmanuel Papin 2014-11-30 17:55:26 +01:00
parent e0f8136b68
commit df8b625228
4 changed files with 107 additions and 1 deletions

View File

@ -2,7 +2,7 @@ Source: zoneminder
Section: net Section: net
Priority: optional Priority: optional
Maintainer: Isaac Connor <iconnor@connortechnology.com> Maintainer: Isaac Connor <iconnor@connortechnology.com>
Build-Depends: debhelper (>= 9), dh-systemd (>= 1.5), autoconf, automake, quilt, libphp-serialization-perl, libgnutls28-dev, libmysqlclient-dev | libmariadbclient-dev, libdbd-mysql-perl, libdate-manip-perl, libwww-perl, libjpeg8-dev|libjpeg9-dev|libjpeg62-turbo-dev, libpcre3-dev, libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libv4l-dev (>= 0.8.3), libbz2-dev, libtool, libsys-mmap-perl, ffmpeg | libav-tools, libnetpbm10-dev, libavdevice-dev, libdevice-serialport-perl, libarchive-zip-perl, libmime-lite-perl, dh-autoreconf, libvlccore-dev, libvlc-dev, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libgcrypt11-dev|libgcrypt20-dev, libpolkit-gobject-1-dev Build-Depends: debhelper (>= 9), po-debconf, dh-systemd (>= 1.5), autoconf, automake, quilt, libphp-serialization-perl, libgnutls28-dev, libmysqlclient-dev | libmariadbclient-dev, libdbd-mysql-perl, libdate-manip-perl, libwww-perl, libjpeg8-dev|libjpeg9-dev|libjpeg62-turbo-dev, libpcre3-dev, libavcodec-dev, libavformat-dev (>= 3:0.svn20090204), libswscale-dev (>= 3:0.svn20090204), libavutil-dev, libv4l-dev (>= 0.8.3), libbz2-dev, libtool, libsys-mmap-perl, ffmpeg | libav-tools, libnetpbm10-dev, libavdevice-dev, libdevice-serialport-perl, libarchive-zip-perl, libmime-lite-perl, dh-autoreconf, libvlccore-dev, libvlc-dev, libcurl4-gnutls-dev | libcurl4-nss-dev | libcurl4-openssl-dev, libgcrypt11-dev|libgcrypt20-dev, libpolkit-gobject-1-dev
Standards-Version: 3.9.6 Standards-Version: 3.9.6
Package: zoneminder Package: zoneminder

View File

@ -0,0 +1,64 @@
#!/bin/sh
# This file is the debconf config script used to configure ZoneMinder
# This script asks questions and retains the answers for the postinst script
set -e
# Source the debconf module
. /usr/share/debconf/confmodule
# Set our version (maybe used to compare versions in the futur)
dbc_first_version="1.28.0-0.3"
# Source the db-config-common module to manage the database
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
# Currently we only support mysql
dbc_dbtypes="mysql"
dbc_authmethod_user="password"
. /usr/share/dbconfig-common/dpkg/config
#DEBHELPER#
dbc_go zoneminder $@
fi
# Use upgrade mode if the package is already configured
if [ -z "$old_version" ]; then
db_input high zoneminder/debconf_upgrade || true
fi
# Ask the user if debconf shall be used to configure the package
db_input high zoneminder/debconf_install || true
db_go || true
db_get zoneminder/debconf_install
# Exit if the user don't want to use debconf
if [ "$RET" = false ]; then
DEBCONF_SKIPPED=true
exit 0
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
# Don't overwrite configuration if the package is already configured
if [ -z "$old_version" ]; then
# Get the administrator login and set a default value if empty
db_get zoneminder/admin_login
ADMIN_LOGIN=${RET:-admin}
# Get the admimistrator password and set a default value if empty
db_get zoneminder/admin_password
ADMIN_PASSWORD=${RET:-admin}
# Get the list of webservers to configure
db_input high zoneminder/webserver || true
db_go || true
db_get zoneminder/webserver
WEBSERVERS="$RET"
fi
exit 0

View File

@ -2,6 +2,11 @@
set -e set -e
old_version=$2
# Sourcing this file here ensure that debconf config script is runned
. /usr/share/debconf/confmodule
apache_install() { apache_install() {
mkdir -p /etc/apache2/conf-available mkdir -p /etc/apache2/conf-available
ln -sf ../../zm/apache.conf /etc/apache2/conf-available/zoneminder.conf ln -sf ../../zm/apache.conf /etc/apache2/conf-available/zoneminder.conf
@ -16,6 +21,19 @@ apache_install() {
fi fi
} }
database_default_config() {
. /usr/share/dbconfig-common/internal/$dbc_dbtype
command_prefix='dbc_'
exec_command=${command_prefix}${dbc_dbtype}_exec_command
# Remove hard-coded default admin account
$exec_command "DELETE FROM Users WHERE Username = 'admin';" || true
# Install custom admin account
md5_password="`echo -n $ADMIN_PASSWORD | md5sum | sed -e 's/ *-$//'`"
$exec_command "INSERT INTO Users (id, username, password, mail_address) VALUES (1, '$ADMIN_LOGIN', '$md5_password');" || true
}
if [ "$1" = "configure" ]; then if [ "$1" = "configure" ]; then
if [ -e "/etc/init.d/mysql" ]; then if [ -e "/etc/init.d/mysql" ]; then
# #

View File

@ -0,0 +1,24 @@
Template: zoneminder/webserver
Type: multiselect
Choices: apache2
Description: Web server to reconfigure automatically:
Please choose the web server that should be automatically configured
to run ZoneMinder.
Template: zoneminder/admin_login
Type: string
Default: admin
Description: Administrative user's login:
Please enter the login of the administrative user.
Template: zoneminder/admin_password
Type: password
Default: admin
Description: Administrative user's password:
Please enter the password of the administrative user.
Template: zoneminder/debconf_install
Type: boolean
Default: true
Description: Configure ZoneMinder automatically?
The configuration program for the package can configure automatically ZoneMinder.