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 # Exit if the user does not want to use debconf
db_get zoneminder/debconf_install db_get zoneminder/debconf_install
if [ "$RET" = "false" ]; then [ "$RET" = "false" ] && exit 0
exit 0 dbc_install="$RET"
fi
fi fi
# Source the config file if exists # Source the config file if exists
if [ -e $CONFIGFILE ]; then if [ -e $CONFIGFILE ]; then
. $CONFIGFILE || true . $CONFIGFILE || true
else else
# Exit with error if no config file # Display a message if no config file
db_input high zoneminder/debconf_confmissingerror || true db_input high zoneminder/debconf_confmissingerror || true
db_go || true db_go || true
exit 1
fi fi
if [ ! "$ZM_DB_TYPE" = "mysql" ]; then 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_input high zoneminder/debconf_dbtypeerror || true
db_go || true db_go || true
exit 1
fi fi
DB_OK=false
# Ask the user if the database shall be installed locally or remotely # Ask the user if the database shall be installed locally or remotely
db_input high zoneminder/debconf_dblocation || true db_input high zoneminder/debconf_dblocation || true
db_go || true db_go || true
db_get zoneminder/debconf_dblocation db_get zoneminder/debconf_dblocation
if [ "$RET" = "local" ]; then if [ "$RET" = "local" ]; then
if [ ! -e "/usr/sbin/mysqld" ]; then if [ ! -e "/usr/sbin/mysqld" ]; then
# Display a message and exit if the user want a local database but no # Display a message if the user want a local database but no database
# database server is available # server is available
db_input high zoneminder/debconf_dblocalmissingerror || true db_input high zoneminder/debconf_dblocalmissingerror || true
db_go || true db_go || true
exit 1 else
fi DB_OK=true
# Set the database server to localhost # Set the database server to localhost
dbc_dbserver="localhost" dbc_dbserver="localhost"
fi
else else
# Source the dbconfig main configuration file # Source the dbconfig main configuration file
if [ -f /etc/dbconfig-common/config ]; then if [ -f /etc/dbconfig-common/config ]; then
. /etc/dbconfig-common/config . /etc/dbconfig-common/config
fi fi
if [ "$dbc_remote_questions_default" = "false" ]; then 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 # installation of databases on remote servers from this assistant
# Note: It would be nice to override the default configuration by setting # Note: It would be nice to override the default configuration by
# dbc_remote_questions_default to true here but unfortunately this does # setting dbc_remote_questions_default to true here but unfortunately
# not work # this does not work
# https://bugs.launchpad.net/ubuntu/+source/dbconfig-common/+bug/1065331 # https://bugs.launchpad.net/ubuntu/+source/dbconfig-common/+bug/1065331
db_input high zoneminder/debconf_dbconfigerror || true db_input high zoneminder/debconf_dbconfigerror || true
db_go || true db_go || true
exit 1 else
DB_OK=true
fi fi
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 # Set the first version in which dbconfig-common was introduced in the
# package # package

View File

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