Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-20-2011, 05:58 PM   #1
Registered: Apr 2008
Location: Michigan
Distribution: RedHat EE 5
Posts: 37

Rep: Reputation: 15
Script no in init.d


I've created a quick init.d script for a virtualbox VM.

For simple startup, and shutdown.

It works when I run it from the directory I created it in. When I copy it to the init.d and chmod 755 it. It does not run, no errors. Infact I get:

Stopping virtualbox-windows7 (via systemctl): [ OK ].

This IS the default init.d output. NONE of the script is being run. I slipped in dummy echoes to be certain.

I can add it with chkconfig --add.
I've attempted running the links after the add command with the exact same results.
Have attempted removing via chkconfig, deleting and recreating.
Have attempted creating the file directly in the init.d directory.
Have attempted cp the file to the init.d directory.
Have attempted running it from /etc/rc.d/init.d, and /etc/init.d.
Have manually checked the /var/lock/subsys/virtualbox, it is not there.

I'm not actually certain what I am doing wrong. This is NOT my first init.d script.

though I doubt this matters, the script is:

# chkconfig: 345 98 11
# description: controls the auto start of a virtual machine via virtualbox

# Source function library.
. /etc/init.d/functions

start() {
echo -n "Starting : Virtual Box"

VBoxManage startvm --type headless Windows7

touch /var/lock/subsys/virtualbox

stop() {
echo -n "Shutting down : Virtual Box"

VBoxManage controlvm Windows7 savestate

rm -f /var/lock/subsys/virtualbox

case "$1" in
VBoxManage showvminfo Windows7
echo -n "The stop start commands must be used to restart this service."
echo "Usage: <servicename> {start|stop|status|reload|restart[|probe]"
exit 1
exit $?

Last edited by davidedwardgill; 08-21-2011 at 10:14 AM. Reason: Adding status line.
Old 08-21-2011, 10:07 AM   #2
Registered: Apr 2008
Location: Michigan
Distribution: RedHat EE 5
Posts: 37

Original Poster
Rep: Reputation: 15
After forcing the script to run with /bin/sh, it ran fine after that.

I am not certain why it worked this way. I had thought the '!/bin/sh' in the script at the top was to declare the file a script.

With that said, it works fine now. Not only on shutdown and startup, but getting the status also.

I'm going to be marking this thread as solved.

If anyone has any insight as to why it worked this way I would love to know why.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Init script in /etc/init.d does not start at boot tdnnash25 Linux - Server 4 12-18-2009 05:40 PM
Init.d Script pliqui Debian 11 06-16-2009 09:58 AM
script init.d anna611 Linux - Newbie 9 11-28-2007 01:22 PM
need help with init script batymahn Linux - Server 1 08-23-2007 12:12 PM
could use some help with my init.d script.... BrianK Linux - General 3 10-31-2002 08:21 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:58 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration