#!/bin/bash set -e CONFIG=/etc/default/solaar . /usr/share/debconf/confmodule db_version 2.0 db_capb backup consolekit_running() { test -e /var/run/ConsoleKit/database } systemd_running() { test -d /run/systemd/system } plugdev_group_exists() { getent group plugdev >/dev/null } # Load the current value, if any USE_PLUGDEV_GROUP=false if db_get solaar/use_plugdev_group; then USE_PLUGDEV_GROUP="$RET" fi if [ -r "$CONFIG" ]; then while IFS="=" read -r VAR VALUE _; do if [ "$VAR" = "USE_PLUGDEV_GROUP" ]; then USE_PLUGDEV_GROUP="${VALUE//\"/}" fi done < "$CONFIG" fi # During normal installation/upgrade, try to avoid bothering the user # if the current settings are sane. if test -z "$DEBCONF_RECONFIGURE"; then consolekit_running && exit 0 systemd_running && exit 0 if [ "$USE_PLUGDEV_GROUP" = true ] && plugdev_group_exists; then exit 0; fi if ! db_get solaar/use_plugdev_group; then # If the group already exists, just use it. plugdev_group_exists && db_set solaar/use_plugdev_group true && exit 0 fi fi # If the package hasn't been configured yet, and no seat daemon is running, # change the default. if ! db_get solaar/use_plugdev_group; then if ! consolekit_running && ! systemd_running; then plugdev_group_exists && db_set solaar/use_plugdev_group true fi fi # update the question template if consolekit_running; then db_subst solaar/use_plugdev_group SEAT_DAEMON_STATUS "the ConsoleKit" elif systemd_running; then db_subst solaar/use_plugdev_group SEAT_DAEMON_STATUS "the systemd" else db_subst solaar/use_plugdev_group SEAT_DAEMON_STATUS "NEITHER" fi # ask the question db_input high solaar/use_plugdev_group || true db_go || true # If the answer has changed, force a rewrite of the configuration file in postinst db_get solaar/use_plugdev_group if [ "$USE_PLUGDEV_GROUP" != "$RET" ]; then rm -f /etc/default/solaar fi exit 0