63 lines
1.5 KiB
Bash
Executable File
63 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
. /usr/share/debconf/confmodule
|
|
db_version 2.0
|
|
db_capb backup
|
|
|
|
consolekit_running() {
|
|
test -e /var/run/ConsoleKit/database
|
|
}
|
|
|
|
systemd_running() {
|
|
test -e /sys/fs/cgroup/systemd
|
|
}
|
|
|
|
plugdev_group_exists() {
|
|
getent group plugdev >/dev/null
|
|
}
|
|
|
|
|
|
# if not reconfiguring, and the right daemons are running,
|
|
# no reason to do anything
|
|
if test -z "$DEBCONF_RECONFIGURE"; then
|
|
consolekit_running && exit 0
|
|
systemd_running && exit 0
|
|
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
|
|
# if not reconfiguring, we have the right group and the right setting
|
|
# no need to ask anything
|
|
test -z "$DEBCONF_RECONFIGURE" && exit 0
|
|
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
|
|
db_go
|
|
|
|
db_get solaar/use_plugdev_group
|
|
if test "$RET" = true; then
|
|
# make sure the group exists
|
|
if ! plugdev_group_exists; then
|
|
groupadd --system plugdev || addgroup --system plugdev
|
|
fi
|
|
# reminder about plugdev membership
|
|
db_input high solaar/plugdev_membership
|
|
db_go
|
|
fi
|
|
|
|
exit 0
|