LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

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

Rep: Reputation: 15
Script no in init.d


Hello

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:

#!/bin/sh
#
# 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
return
}

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

VBoxManage controlvm Windows7 savestate

rm -f /var/lock/subsys/virtualbox
return
}

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

Last edited by davidedwardgill; 08-21-2011 at 09:14 AM. Reason: Adding status line.
 
Old 08-21-2011, 09:07 AM   #2
davidedwardgill
Member
 
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.
 
  


Reply


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 04:40 PM
Init.d Script pliqui Debian 11 06-16-2009 08:58 AM
script init.d anna611 Linux - Newbie 9 11-28-2007 12:22 PM
need help with init script batymahn Linux - Server 1 08-23-2007 11:12 AM
could use some help with my init.d script.... BrianK Linux - General 3 10-31-2002 07:21 PM


All times are GMT -5. The time now is 12:16 AM.

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