| 1 |
#!/bin/sh |
| 2 |
# postinst script for bumblebee |
| 3 |
# |
| 4 |
# see: dh_installdeb(1) |
| 5 |
|
| 6 |
set -e |
| 7 |
|
| 8 |
xconffile=/etc/bumblebee/xorg.conf.nouveau |
| 9 |
|
| 10 |
# group that allows users to use Bumblebee |
| 11 |
BB_GROUP=bumblebee |
| 12 |
|
| 13 |
# add members of these groups automatically to group "bumblebee" for new |
| 14 |
# installations |
| 15 |
USE_GROUPS='adm sudo admin' |
| 16 |
|
| 17 |
case "$1" in |
| 18 |
configure) |
| 19 |
# only add a group and members if the configured group does match the |
| 20 |
# default group and if the group is missing |
| 21 |
if grep -qx ServerGroup=$BB_GROUP /etc/bumblebee/bumblebee.conf && |
| 22 |
! getent group $BB_GROUP > /dev/null; then |
| 23 |
groupadd --system $BB_GROUP |
| 24 |
users=$(getent -s files group $USE_GROUPS | cut -d: -f4 | tr , '\n' | sort -u) |
| 25 |
echo "Adding members from group(s) '$USE_GROUPS' to '$BB_GROUP':" |
| 26 |
echo $users |
| 27 |
for user in $users; do |
| 28 |
gpasswd -a $user $BB_GROUP |
| 29 |
done |
| 30 |
fi |
| 31 |
|
| 32 |
|
| 33 |
# Raring specific issue |
| 34 |
# Also, do not rely solely on dpkg-vendor (see LP: #1061769) |
| 35 |
if (which dpkg-vendor >/dev/null && dpkg-vendor --derives-from Ubuntu) || \ |
| 36 |
[ -e /etc/dpkg/origins/ubuntu ]; then |
| 37 |
# assume first device to be discrete in nvidia/nvidia |
| 38 |
busid=$(lspci -d10de: -nn | grep '\[030[02]\]' | cut -d' ' -f1 | tr . : | head -1) |
| 39 |
if [ -z "$busid" ]; then |
| 40 |
echo "No Nvidia card found. If you really have an Optimus system," |
| 41 |
echo "try selecting the Optimus setup in BIOS and run:" |
| 42 |
echo "sudo dpkg-reconfigure bumblebee" |
| 43 |
else |
| 44 |
echo "Selecting $busid as discrete nvidia card. If this is incorrect," |
| 45 |
echo "edit the BusID line in $xconffile ." |
| 46 |
sed -i $xconffile -r -e "s/^([\t ]*)#([\t ]*BusID[\t ]*)\"[^\"]*\"$/\\1 \\2\"PCI\:$busid\"/" |
| 47 |
fi |
| 48 |
|
| 49 |
# Only for 3.2.1, remove busid.conf if still present. |
| 50 |
if [ -e /etc/bumblebee/xorg.conf.d/busid.conf ]; then |
| 51 |
echo "Deleting old /etc/bumblebee/xorg.conf.d/busid.conf" |
| 52 |
rm /etc/bumblebee/xorg.conf.d/busid.conf |
| 53 |
fi |
| 54 |
fi |
| 55 |
|
| 56 |
# Do not treat /etc/modprobe.d/bumblebee-nvidia.conf as a conffile |
| 57 |
# LP: #1242785, https://github.com/Bumblebee-Project/Bumblebee/issues/525 |
| 58 |
cp -f /usr/share/bumblebee/modprobe.d/bumblebee.conf /etc/modprobe.d/bumblebee.conf |
| 59 |
|
| 60 |
;; |
| 61 |
triggered) |
| 62 |
case "$2" in |
| 63 |
restart-bumblebeed) |
| 64 |
# Trigger a restart of the bumblebee service, only if it's already running |
| 65 |
|
| 66 |
if [ -d /run/systemd/system ]; then |
| 67 |
if deb-systemd-invoke is-active bumblebeed.service > /dev/null 2>&1; then |
| 68 |
deb-systemd-invoke restart bumblebeed.service || exit $? |
| 69 |
fi |
| 70 |
elif [ -x "/etc/init.d/bumblebeed" ]; then |
| 71 |
if invoke-rc.d bumblebeed status > /dev/null 2>&1; then |
| 72 |
invoke-rc.d bumblebeed restart || exit $? |
| 73 |
fi |
| 74 |
fi |
| 75 |
;; |
| 76 |
esac |
| 77 |
esac |
| 78 |
|
| 79 |
#DEBHELPER# |