Author Topic: Starting bumblebeed on boot/login  (Read 1218 times)

0 Members and 1 Guest are viewing this topic.

Offline chemicalfan

  • Sr. Member
  • ****
  • Posts: 419
  • Karma: 9
  • Gender: Male
  • I've been here a little while!
    • View Profile
    • Awards
Starting bumblebeed on boot/login
« on: November 03, 2013, 05:50:30 pm »
This should be real simple, but I can't figure it out (never got my head around Upstart  ::))

I can start the Bumblebee daemon on my laptop manually by running the following in a terminal:
Code: [Select]
sudo bumblebeed start
(backgrounding doesn't seem to work, but I'm sure that's my syntax error somewhere).

The contents of /etc/init/bumblebeed.conf are:
Code: [Select]
# Upstart job for Bumblebee daemon

description "Bumblebee supporting NVIDIA Optimus cards"
author      "Lekensteyn <lekensteyn@gmail.com>"

# XXX: do we need to stop before / after a graphical DE like kdm?
start on    (desktop-session-start)
stop on     (desktop-shutdown)

# restart in case it crashed for some reason
respawn

script
libopts=

# When the user installs a nvidia package that is unknown,
# ignore the paths in bumblebee.conf and use detected ones
if ! driver=$(grep -Po '^Driver=\K.*' /etc/bumblebee/bumblebee.conf) \
|| [ -z "$driver" ] || [ "$driver" = "nvidia" ]; then
# find LibraryPath setting of nvidia section
libpath=$(awk -F[=:] '/^\[driver-nvidia\]/{d=1}/^LibraryPath=/{if(d){print $2;exit}}' \
/etc/bumblebee/bumblebee.conf) || true

# pick the first available nvidia installation (not necessary
# the latest, e.g. nvidia-current over nvidia-experimental-310)
pkgname=$(ls -1d /usr/lib/nvidia*/libGL.so | cut -d/ -f4 | head -1) || true

# When the default library path does not contain nvidia drivers,
# it is possibly not installed. If no driver is installed (no
# /usr/lib/nvidia-*), assume that the auto-detection will use
# nouveau instead and do not override paths.
if [ ! -e "$libpath/libGL.so" -a -n "$pkgname" ] && \
modprobe -nq "$pkgname"; then
# assume nvidia driver even if nouveau is already loaded
libopts="$libopts --driver nvidia"
libopts="$libopts --driver-module $pkgname"
libopts="$libopts --ldpath /usr/lib/$pkgname:/usr/lib32/$pkgname"
libopts="$libopts --module-path /usr/lib/$pkgname/xorg,/usr/lib/xorg/modules"
fi
fi

# don't use --daemon as Upstart gets confused by that.
exec '/usr/sbin/bumblebeed' --use-syslog $libopts
end script

Way out of my depth here, but how to I get this daemon to run automatically on boot up or login?

Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 12465
  • Karma: 306
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #1 on: November 03, 2013, 07:31:18 pm »
I'm lost here .. doesn't bumblebeed start with the desktop as I'd have expected it should ?

Which distro/version/architecture ?

is there a symlink to bumblebeed in any of the rc(n).d directories .. such as /etc/rc2.d ?
« Last Edit: November 04, 2013, 12:24:53 am by Mark Greaves (PCNetSpec) »
WARNING: You are logged into reality as 'root'

logging in as 'insane' is the only safe option.

Offline chemicalfan

  • Sr. Member
  • ****
  • Posts: 419
  • Karma: 9
  • Gender: Male
  • I've been here a little while!
    • View Profile
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #2 on: November 04, 2013, 08:43:34 am »
Sorry for the delay Mark - I've no idea why it isn't starting, this happened after an update (although I didn't spot it for ages, as I haven't tried to use it until now). I couldn't find an obvious log where errors had been written either.

This is running Mint 14 x64, Cinnamon as DE. I didn't dig through the rc folders as I thought Upstart did away with them? I'll have a look tonight and post back

Offline chemicalfan

  • Sr. Member
  • ****
  • Posts: 419
  • Karma: 9
  • Gender: Male
  • I've been here a little while!
    • View Profile
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #3 on: November 04, 2013, 07:07:33 pm »
Nothing under any of the rcX.d folders, although there is a script under the init.d folder:
Code: [Select]
#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.

set -e

INITSCRIPT="$(basename "$0")"
JOB="${INITSCRIPT%.sh}"

if [ "$JOB" = "upstart-job" ]; then
    if [ -z "$1" ]; then
        echo "Usage: upstart-job JOB COMMAND" 1>&2
exit 1
    fi

    JOB="$1"
    INITSCRIPT="$1"
    shift
else
    if [ -z "$1" ]; then
        echo "Usage: $0 COMMAND" 1>&2
exit 1
    fi
fi

COMMAND="$1"
shift


if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
ECHO=echo
else
ECHO=:
fi

$ECHO "Rather than invoking init scripts through /etc/init.d, use the service(8)"
$ECHO "utility, e.g. service $INITSCRIPT $COMMAND"

# Only check if jobs are disabled if the currently _running_ version of
# Upstart (which may be older than the latest _installed_ version)
# supports such a query.
#
# This check is necessary to handle the scenario when upgrading from a
# release without the 'show-config' command (introduced in
# Upstart for Ubuntu version 0.9.7) since without this check, all
# installed packages with associated Upstart jobs would be considered
# disabled.
#
# Once Upstart can maintain state on re-exec, this change can be
# dropped (since the currently running version of Upstart will always
# match the latest installed version).

UPSTART_VERSION_RUNNING=$(initctl version|awk '{print $3}'|tr -d ')')

if dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 0.9.7
then
    initctl show-config -e "$JOB"|grep -q '^  start on' || DISABLED=1
fi

case $COMMAND in
status)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted to an"
    $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
    $COMMAND "$JOB"
    ;;
start|stop)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted to an"
    $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
    if status "$JOB" 2>/dev/null | grep -q ' start/'; then
        RUNNING=1
    fi
    if [ -z "$RUNNING" ] && [ "$COMMAND" = "stop" ]; then
        exit 0
    elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
        exit 0
    elif [ -n "$DISABLED" ] && [ "$COMMAND" = "start" ]; then
        exit 0
    fi
    $COMMAND "$JOB"
    ;;
restart)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted to an"
    $ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities,"
    $ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available."
    if status "$JOB" 2>/dev/null | grep -q ' start/'; then
        RUNNING=1
    fi
    if [ -n "$RUNNING" ] ; then
        stop "$JOB"
    fi
    # If the job is disabled and is not currently running, the job is
    # not restarted. However, if the job is disabled but has been forced into the
    # running state, we *do* stop and restart it since this is expected behaviour
    # for the admin who forced the start.
    if [ -n "$DISABLED" ] && [ -z "$RUNNING" ]; then
        exit 0
    fi
    start "$JOB"
    ;;
reload|force-reload)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted to an"
    $ECHO "Upstart job, you may also use the reload(8) utility, e.g. reload $JOB"
    reload "$JOB"
    ;;
*)
    $ECHO
    $ECHO "The script you are attempting to invoke has been converted to an Upstart" 1>&2
    $ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2
    exit 1
esac

That seems to be legacy though...?

I'm reluctant to simply re-install bumblebee via apt, as it does work at the moment, and I'd worry that it would stop working completely! It's not very stable (bring on the kernel drivers!)

Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 12465
  • Karma: 306
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #4 on: November 04, 2013, 07:58:28 pm »
Where did you get bumblebee from ?

at the beginning of /etc/init/bumblebeed.conf from the PPA (ppa:bumblebee/stable) for 13.04 reads:-

Quote
# Upstart job for Bumblebee daemon

description "Bumblebee supporting NVIDIA Optimus cards"
author      "Lekensteyn <lekensteyn@gmail.com>"

# XXX: do we need to stop before / after a graphical DE like kdm?
start on    (login-session-start or desktop-session-start)
stop on     (desktop-shutdown)

# restart in case it crashed for some reason
respawn

[EDIT]

Full /etc/init/bumblebeed.conf attached below
« Last Edit: November 04, 2013, 08:17:53 pm by Mark Greaves (PCNetSpec) »
WARNING: You are logged into reality as 'root'

logging in as 'insane' is the only safe option.

Offline chemicalfan

  • Sr. Member
  • ****
  • Posts: 419
  • Karma: 9
  • Gender: Male
  • I've been here a little while!
    • View Profile
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #5 on: November 05, 2013, 08:56:24 am »
Yeah, mine read that, but I changed it in the hope that it might fix it. I thought, maybe it was supposed to be edited before use? Anyway, it doesn't work with the default conf file either...

Not sure where I got from (not at my laptop atm), I'd guess the bumblebee repo if it's not in the default Ubuntu or Mint repos?

How can I execute the "bumblebeed start" command with root privileges on login? I know it's not the right way to do it, but it saves me a step! Using the "Startup Applications" (Mint application) didn't work as (I guess) it didn't have root.

Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 12465
  • Karma: 306
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #6 on: November 05, 2013, 12:40:55 pm »
Add it to the autostart list.

or try:
Code: [Select]
sudo update-rc.d bumblebeed defaults

you can remove that with:
Code: [Select]
sudo /etc/rc*/*bumblebeed



If that doesn't work (load and allow shutdown/reboot), try creating your own bash script /etc/init.d/my-bumblebeed-start containing your command, and run:
Code: [Select]
sudo update-rc.d my-bumblebeed-start 2 3 4 5

you can remove that with:
Code: [Select]
sudo /etc/rc*/*my-bumblebeed-start
WARNING: You are logged into reality as 'root'

logging in as 'insane' is the only safe option.

Offline chemicalfan

  • Sr. Member
  • ****
  • Posts: 419
  • Karma: 9
  • Gender: Male
  • I've been here a little while!
    • View Profile
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #7 on: November 05, 2013, 01:22:35 pm »
Thanks very much Mark, will have a play tonight if I get time  :)

Offline chemicalfan

  • Sr. Member
  • ****
  • Posts: 419
  • Karma: 9
  • Gender: Male
  • I've been here a little while!
    • View Profile
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #8 on: November 05, 2013, 10:30:49 pm »
No dice with the update-rc.d command - it ran, listed what it had done, but a reboot later and it's the same story :(

I'll play with the custom script tomorrow, gonna eat dinner now  :o

Offline chemicalfan

  • Sr. Member
  • ****
  • Posts: 419
  • Karma: 9
  • Gender: Male
  • I've been here a little while!
    • View Profile
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #9 on: November 06, 2013, 10:06:29 pm »
Do I need the sudo in the script? Or do I just need it to read "bumblebeed"? I need to pass it a carriage return after it executes (it "hangs" the terminal; it doesn't background it). Do I need the shebang (sorry, should know that :-[)

Offline chemicalfan

  • Sr. Member
  • ****
  • Posts: 419
  • Karma: 9
  • Gender: Male
  • I've been here a little while!
    • View Profile
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #10 on: November 06, 2013, 10:14:05 pm »
Sorry for the DP, but I believe I've found the answer here - https://github.com/Bumblebee-Project/Bumblebee/issues/337
(actually, I found that ages ago, but only just spotted the link in the bookmarks, doh  :-[)

Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 12465
  • Karma: 306
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #11 on: November 06, 2013, 11:19:28 pm »
So did replacing

Code: [Select]
start on    (login-session-start or desktop-session-start)
stop on     (desktop-shutdown)

with

Code: [Select]
start on    (runlevel [2345])
stop on     (runlevel [016])

work then ?

--
« Last Edit: November 06, 2013, 11:21:32 pm by Mark Greaves (PCNetSpec) »
WARNING: You are logged into reality as 'root'

logging in as 'insane' is the only safe option.

Offline chemicalfan

  • Sr. Member
  • ****
  • Posts: 419
  • Karma: 9
  • Gender: Male
  • I've been here a little while!
    • View Profile
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #12 on: November 07, 2013, 08:40:08 am »
Yep, I'm guessing this is Ubuntu/Mint-specific, otherwise the dev would have just made it the default. My next upgrade will be the LTS next year - hopefully it'll be in Ubuntu's repo by then, and they can make the change themselves upstream of me. It's annoying to have to remember the manually update the conf file each time bumblebee gets an upgrade via APT (what am I running here, Slackware? :p)

Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 12465
  • Karma: 306
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #13 on: November 07, 2013, 09:32:10 am »
I've installed it in Ubuntu a few times and it always works in there .. and it would be all over the web if it didn't work in Ubuntu so I'm gonna guess it's Mint specific.

Either way, we now know the cure :)
WARNING: You are logged into reality as 'root'

logging in as 'insane' is the only safe option.

Offline chemicalfan

  • Sr. Member
  • ****
  • Posts: 419
  • Karma: 9
  • Gender: Male
  • I've been here a little while!
    • View Profile
    • Awards
Re: Starting bumblebeed on boot/login
« Reply #14 on: November 07, 2013, 11:47:18 am »
Doh, I doubt Mint will pull the package into their repo to maintain the conf file, so I guess I'll be stuck for the forseeable future...

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal