Real Software Forums
http://forums.realsoftware.com/

Startup Script
http://forums.realsoftware.com/viewtopic.php?f=8&t=45891
Page 1 of 1

Author:  Jason_Adams [ Tue Nov 13, 2012 1:17 pm ]
Post subject:  Startup Script

Using the latest Debian Squeeze. I'm not a Linux expert by any means, so this is really more a of "is this right?" question.

I have a WE application that I want to run on startup, and I understand I create a bash script, make it executable, toss it in the /etc/init.d directory, and use update-rc.d MyScript. Now, if there's an extra step or parameter that should be here, please say so, because I will do exactly what I wrote here.

Where I'm uncertain is if there's supposed to be anything extra in the script, or if this is literally all that's needed:
#!/bin/bash
/usr/bin/myapp/myapp


Sorry if I'm missing something elementary. :?

Thanks!

Author:  Nux [ Wed Nov 14, 2012 11:10 pm ]
Post subject:  Re: Startup Script

Jason_Adams wrote:
Using the latest Debian Squeeze. I'm not a Linux expert by any means, so this is really more a of "is this right?" question.

I have a WE application that I want to run on startup, and I understand I create a bash script, make it executable, toss it in the /etc/init.d directory, and use update-rc.d MyScript. Now, if there's an extra step or parameter that should be here, please say so, because I will do exactly what I wrote here.

Where I'm uncertain is if there's supposed to be anything extra in the script, or if this is literally all that's needed:
#!/bin/bash
/usr/bin/myapp/myapp


Sorry if I'm missing something elementary. :?

Thanks!


A quick look at your script it looks good, and your steps are sound are you able to put your script in a test environment that replicates your production?
are you having a certain problem with your script?

I'm not a nerd with Debian/Linux, my day job forces me to work with Linux variants.

Hope it helps

Author:  Jason_Adams [ Thu Nov 15, 2012 10:58 am ]
Post subject:  Re: Startup Script

Nux wrote:
A quick look at your script it looks good, and your steps are sound are you able to put your script in a test environment that replicates your production?
are you having a certain problem with your script?

Honestly I haven't even tired, yet. I was hoping someone would do exactly what you did — look at it can go, "Looks fine." :)

Nux wrote:
I'm not a nerd with Debian/Linux, my day job forces me to work with Linux variants.

Exactly, I'm in the same boat. I don't work with Linux in my own time, but started using it for server purposes back in May. I dabble in it just enough to do what I need to, but not often enough to really retain everything. :P

Thanks for the feedback, Nux!

Author:  charonn0 [ Thu Nov 15, 2012 1:45 pm ]
Post subject:  Re: Startup Script

The script should work, I don't see any errors in it. It's a little spartan compared to some of the startup scripts I've seen (like this one for a Minecraft server), but that just means it's easier to debug.

Author:  Nux [ Thu Nov 15, 2012 8:57 pm ]
Post subject:  Re: Startup Script

Nothing wrong with the kiss philosophy
Keep it simple stupid. :) I follow it everyday
Take it easy all ;)

Author:  charonn0 [ Thu Nov 15, 2012 9:01 pm ]
Post subject:  Re: Startup Script

Over-Engineered By Design® :lol:

Author:  J.Sh3ppard [ Thu Nov 15, 2012 9:07 pm ]
Post subject:  Re: Startup Script

A little off topic but do you guys know if startup scripts will still work on OS X Mountain Lion?

Have there been any changes with startup scripts since 10.6?

Does sandboxing effect anything regarding startup scripts?

I have not yet upgraded to ML.


TIA.

Author:  Jason_Adams [ Fri Nov 16, 2012 2:33 pm ]
Post subject:  Re: Startup Script

charonn0 wrote:
The script should work, I don't see any errors in it. It's a little spartan compared to some of the startup scripts I've seen (like this one for a Minecraft server), but that just means it's easier to debug.

Hahah! I could throw in some more stuff in just to make sure it has something to crash. Shortly, though, I'll be writing a cron bash script for backing up the pg database. I'm sure I'll break something there. :)


Nux wrote:
Nothing wrong with the kiss philosophy
Keep it simple stupid. :) I follow it everyday
Take it easy all ;)

I've generally managed to avoid this philosophy, but sometimes I get sloppy and forget to over complicate my work. ;)


J.Sh3ppard wrote:
A little off topic but do you guys know if startup scripts will still work on OS X Mountain Lion?

Have there been any changes with startup scripts since 10.6?


Not that I mind this being tossed in here, but I do recommend posing the question in the Mac section. I don't know how many of the Mac guys come in here looking to solve Mountain Lion questions. :)

Author:  J.Sh3ppard [ Fri Nov 16, 2012 4:45 pm ]
Post subject:  Re: Startup Script

Jason_Adams wrote:
Not that I mind this being tossed in here, but I do recommend posing the question in the Mac section. I don't know how many of the Mac guys come in here looking to solve Mountain Lion questions. :)


Yah it was a shot in the dark while walking a tightrope :)

I'll probably ask it in the Mac section later.

Author:  Jason_Adams [ Fri Nov 16, 2012 5:39 pm ]
Post subject:  Re: Startup Script

For those like me to didn't know, I learned you have to add the LSB tag to the script. This tells the system how to handle your script in run-level detail.

I also added detection to find the file and used one of them fancy constant things:

#!/bin/bash

### BEGIN INIT INFO
# Provides: runwebapplication.sh
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Runs Application Daemon
# Description: Finds and checks the Application permissions, and runs it if it can
### END INIT INFO

file=/usr/bin/appdirectory/app

if [ -x "$FILE" ]; then
echo "Starting Web Application"
"$FILE" &
else
echo "Web Application not found or isn't executable"
fi


I knew I'd figure out a way to complicate this. :D

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/