#!/bin/sh # postinst script for bumblebee # # see: dh_installdeb(1) set -e xconffile=/etc/bumblebee/xorg.conf.nouveau # group that allows users to use Bumblebee BB_GROUP=bumblebee # add members of these groups automatically to group "bumblebee" for new # installations USE_GROUPS='adm sudo admin' case "$1" in configure) # only add a group and members if the configured group does match the # default group and if the group is missing if grep -qx ServerGroup=$BB_GROUP /etc/bumblebee/bumblebee.conf && ! getent group $BB_GROUP > /dev/null; then groupadd --system $BB_GROUP users=$(getent group $USE_GROUPS | cut -d: -f4 | tr , '\n' | sort -u) echo "Adding members from group(s) '$USE_GROUPS' to '$BB_GROUP':" echo $users for user in $users; do gpasswd -a $user $BB_GROUP done fi # Raring specific issue # Also, do not rely solely on dpkg-vendor (see LP: #1061769) if (which dpkg-vendor >/dev/null && dpkg-vendor --derives-from Ubuntu) || \ [ -e /etc/dpkg/origins/ubuntu ]; then # assume first device to be discrete in nvidia/nvidia busid=$(lspci -d10de: -nn | grep '\[030[02]\]' | cut -d' ' -f1 | tr . : | head -1) if [ -z "$busid" ]; then echo "No Nvidia card found. If you really have an Optimus system," echo "try selecting the Optimus setup in BIOS and run:" echo "sudo dpkg-reconfigure bumblebee" else echo "Selecting $busid as discrete nvidia card. If this is incorrect," echo "edit the BusID line in $xconffile ." sed -i $xconffile -r -e "s/^([\t ]*)#([\t ]*BusID[\t ]*)\"[^\"]*\"$/\\1 \\2\"PCI\:$busid\"/" fi # Only for 3.2.1, remove busid.conf if still present. if [ -e /etc/bumblebee/xorg.conf.d/busid.conf ]; then echo "Deleting old /etc/bumblebee/xorg.conf.d/busid.conf" rm /etc/bumblebee/xorg.conf.d/busid.conf fi fi # Do not treat /etc/modprobe.d/bumblebee-nvidia.conf as a conffile # LP: #1242785, https://github.com/Bumblebee-Project/Bumblebee/issues/525 cp -f /usr/share/bumblebee/modprobe.d/bumblebee.conf /etc/modprobe.d/bumblebee.conf ;; triggered) case "$2" in restart-bumblebeed) # Trigger a restart of the bumblebee service, only if it's already running if [ -d /run/systemd/system ]; then if deb-systemd-invoke is-active bumblebeed.service > /dev/null 2>&1; then deb-systemd-invoke restart bumblebeed.service || exit $? fi elif [ -x "/etc/init.d/bumblebeed" ]; then if invoke-rc.d bumblebeed status > /dev/null 2>&1; then invoke-rc.d bumblebeed restart || exit $? fi fi ;; esac esac # Automatically added by dh_installdeb/12 dpkg-maintscript-helper rm_conffile /etc/modprobe.d/bumblebee.conf 3.2.1-6\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/bash_completion.d/bumblebee 3.2.1-8\~ -- "$@" dpkg-maintscript-helper rm_conffile /etc/init/bumblebeed.conf 3.2.1-18\~ -- "$@" # End automatically added section # Automatically added by dh_installinit/12 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -x "/etc/init.d/bumblebeed" ]; then update-rc.d bumblebeed defaults >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d --skip-systemd-native bumblebeed $_dh_action || exit 1 fi fi # End automatically added section # Automatically added by dh_installsystemd/12 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'bumblebeed.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'bumblebeed.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'bumblebeed.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'bumblebeed.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/12 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi deb-systemd-invoke $_dh_action 'bumblebeed.service' >/dev/null || true fi fi # End automatically added section