Install and remove package without error even if no database

This commit is contained in:
Emmanuel Papin 2014-12-07 15:18:08 +01:00
parent f2168f50d1
commit 91719ff7f4
2 changed files with 30 additions and 23 deletions

View File

@ -17,61 +17,62 @@ if [ "$1" = "configure" ]; then
# Exit if the user does not want to use debconf
db_get zoneminder/debconf_install
if [ "$RET" = "false" ]; then
exit 0
fi
[ "$RET" = "false" ] && exit 0
dbc_install="$RET"
fi
# Source the config file if exists
if [ -e $CONFIGFILE ]; then
. $CONFIGFILE || true
else
# Exit with error if no config file
# Display a message 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
# Display a message if wrong database type
db_input high zoneminder/debconf_dbtypeerror || true
db_go || true
exit 1
fi
DB_OK=false
# 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
# Display a message 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
else
DB_OK=true
# Set the database server to localhost
dbc_dbserver="localhost"
fi
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
# Display a message 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
# 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
else
DB_OK=true
fi
fi
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
if [ "$DB_OK" = "true" ] && [ -f /usr/share/dbconfig-common/dpkg/config ]; then
# Set the first version in which dbconfig-common was introduced in the
# package

View File

@ -50,11 +50,10 @@ mysql_update() {
# Exit if user didn't want to use debconf
db_get zoneminder/debconf_install
if [ "$RET" = "false" ]; then
exit 0;
fi
[ "$RET" = "false" ] && exit 0
# Source the config file if exists
[ ! -e $CONFIGFILE ] && exit 0
. $CONFIGFILE
if [ -f /usr/share/dbconfig-common/dpkg/postinst ]; then
@ -152,8 +151,15 @@ if [ "$1" = "configure" ]; then
# Ensure zoneminder is stopped
deb-systemd-invoke stop zoneminder.service || exit $?
# If mysql server exists and is running
if [ -e "/usr/sbin/mysqld" ] && deb-systemd-invoke start mysql.service; then
# Run the ZoneMinder update tool
zmupdate.pl
else
# Otherwise exit without error (mysql server may not be available on
# this machine)
exit 0;
fi
fi
#DEBHELPER#