Easy startup vbox script for rc.d

Hey!

I am a complete newbie to FreeBSD and to scripting, too. I read a book, searched a lot in Google and tried on my own not to bother anybody, but I´m stuck and need help, please. So this is my first post and I hope I did it right...

I´m using FreeBSD 8.0p2 64bit as host in Virtualbox 3.1.6 with gnome2 and all ports are and the system is up to date. So far so good...

With the new virtualbox-ose-additions port using the clipboard for the Client is default not enabled. So I´m trying to run a simple command at startup with a rc.d script. I adjusted the script according to the man page and it is working when using it after login in a terminal as root. The echo is shown but the clipboard doesn`t work when starting it through a command in /etc/rc.conf. Here is what it looks like:

Code:
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE:	vboxclipboard
# REQUIRE:	DAEMON
# REQUIRE:      vboxguest
# KEYWORD:	nojail

#
# Add the following lines to /etc/rc.conf
# to enable this service:
#
# vboxclipboard_enable = (bool): Set to NO by default.
# Set it to YES to enable vboxclipboard on startup

. /etc/rc.subr

name="vboxclipboard"
rcvar=${name}_enable
command="/usr/X11R6/sbin/VBoxClient"
start_cmd='${command} --clipboard' && echo "Starting ${name}."

load_rc_config $name

: ${vboxclipboard_enable="NO"}

run_rc_command "$1"

I placed it in /home/tom/ and did the following:

Code:
$ su
$ cp /home/tom/vboxclipboard /usr/local/etc/rc.d/
$ chmod 755 /usr/local/etc/rc.d/vboxclipboard && chmod +x /usr/local/etc/rc.d/vboxclipboard
$ /usr/local/etc/rc.d/vboxclipboard onestart

As I said, it gets started and
Starting vboxclipboard.
is shown during startup, but the clipboard doesn`t work. Only thing I know is that it has to be run as root, but I don`t know how to do that. Perhaps it is started in the wrong order, but I told it to be started after vboxguest.

Hope it is a piece of cake for you and you can help me.

Thanks in advance
 
I think your script works fine.

Do you see a running VBoxClient process after reboot?

Have you ever been able to get # VBoxClient --clipboard to work as expected? Did you run it on the console or on an xterm?

I just did a quick test: VBoxClient is running and copy and paste did not work in a simple startx session.
 
How do I check if the process is running?

I have been able to get

Code:
$ su
$ VBoxClient --clipboard

to work inside gnome2 in an xterm, never tried it on the console. Does this mean I have to use the control center inside gnome to get the command running as autostart?

So to what exactly do the results of your quicktest point?
 
tombsd said:
How do I check if the process is running?

$ ps auxww | fgrep -i vboxclient

tombsd said:
I have been able to get

Code:
$ su
$ VBoxClient --clipboard

to work inside gnome2 in an xterm, never tried it on the console. Does this mean I have to use the control center inside gnome to get the command running as autostart?

Maybe, yes. I did not find a manual page for VBoxClient and did not find out the intended usage of it. So I took a look at the content of the virtualbox-ose-addons distfile.

This is the script you are looking for, remember VBoxClient is in /usr/local/sbin - maybe you think this is the reason for having it run as root?

/usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-3.1.51.r25618_OSE/src/VBox/Additions/x11/Installer/98vboxadd-xclient

I think you can copy it to /usr/local/sbin/VBoxClient-all. Then copy /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-3.1.51.r25618_OSE/src/VBox/Additions/x11/Installer/vboxclient.desktop to /usr/local/share/gnome/ and edit the path again.

If everything works fine for, do a send-pr for ports/emulators/virtualbox-ose-additions so this can be fixed for the future.
 
This is the script you are looking for, remember VBoxClient is in /usr/local/sbin - maybe you think this is the reason for having it run as root?

In my script it is used from "/usr/X11R6/sbin/VBoxClient". Does this make any difference? Do I have to change that?

I think I have to run it as root, because it only works after:
Code:
$ su
$ VBoxClient --clipboard

I don`t have a work folder in the additions port folder, because I do a
Code:
make install clean
on that. Do I have to make just this to leave the work folder in place?
Code:
make install

So what exactly would I have to try? Sorry, but you have to go slowly with me ;)

Code:
$ su
$ cp -fr /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-3.1.51.r25618_OSE/src/VBox/Additions/x11/Installer/98vboxadd-xclient /usr/local/sbin/VBoxClient-all/
$ cp -fr /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-3.1.51.r25618_OSE/src/VBox/Additions/x11/Installer/vboxclient.desktop /usr/local/share/gnome/

Is that what you recommend to try? And what is a send-pr?
 
/usr/X11R6/sbin/VBoxClient is the same as /usr/local/sbin/VBoxClient today. /usr/X11R6/ is obsolete.

Did you ever try to run $ /usr/local/sbin/VBoxClient --clipboard as normal user from an xterm inside your X session?

Just say # make oder just # make extract or maybe # make configure if you want to have a look at the content of the distfile in your work directory.

You want to try something like # cp -p /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-3.1.51.r25618_OSE/src/VBox/Additions/x11/Installer/98vboxadd-xclient /usr/local/sbin/VBoxClient-all and # cp -p /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-3.1.51.r25618_OSE/src/VBox/Additions/x11/Installer/vboxclient.desktop /usr/local/share/gnome/autostart/. And then edit both files to make sure the path names are correct.
 
Did you ever try to run $ /usr/local/sbin/VBoxClient --clipboard as normal user from an xterm inside your X session?

Yes, I tried this, but it doesn`t work...

I managed to get the two files to the suggested places and edited them. But unfortunately this still doesn`t work.

Any other suggestion? Or if you could get it to work, please post the content of the files...

Is it a good idea to point the maintainer to this thread?
 
tombsd said:
Is it a good idea to point the maintainer to this thread?

Yes. Or at least someone who is actively using virtualbox and X (I don't use X). I was just helping because of your "Userland Programming & Scripting" problem which turned out to be a pure virtualbox problem.
 
o.k. I sent an email to the maintainer and they will integrate a working script in one of the next releases. So they are aware of the problem...

Thanks for your help!!!
 
Back
Top