diff --git a/distros/debian8/zoneminder.config b/distros/debian8/zoneminder.config index e13632872..399411059 100644 --- a/distros/debian8/zoneminder.config +++ b/distros/debian8/zoneminder.config @@ -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 + else + DB_OK=true + # Set the database server to localhost + dbc_dbserver="localhost" 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 + # 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 diff --git a/distros/debian8/zoneminder.postinst b/distros/debian8/zoneminder.postinst index 882810a83..429ad779a 100644 --- a/distros/debian8/zoneminder.postinst +++ b/distros/debian8/zoneminder.postinst @@ -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 $? - # Run the ZoneMinder update tool - zmupdate.pl + # 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#