[ale] creating an init.d script

Todor Fassl fassl.tod at gmail.com
Tue Feb 17 16:31:29 EST 2015


Sorry, I use ubuntu server. But I thought my question was unique to 
debian/ubuntu. That is why I didn't bother specifying. I thought other 
linux systems had a completely different system for starting/stopping 
daemons.

On 02/17/2015 12:29 PM, Lightner, Jeff wrote:
>
> That reminds me of lock file.
>
> The OP didn’t mention which operating system he is using.  If he is 
> using a RedHat based distro (e.g. RHEL, CentOS, Fedora, Scientific) he 
> needs to be sure to have logic to create a lock file and remove it.  
>  RHEL’s start/stop assumes if there is no lock file that the service 
> is already stopped and won’t do the stop at shutdown (or with “service 
> <script> stop”
>
> *From:*ale-bounces at ale.org [mailto:ale-bounces at ale.org] *On Behalf Of 
> *Scott Plante
> *Sent:* Tuesday, February 17, 2015 12:41 PM
> *To:* Atlanta Linux Enthusiasts
> *Subject:* Re: [ale] creating an init.d script
>
> James' script is a good example. The basic idea is that you need a 
> script that takes a parameter "start" to start the service and "stop" 
> to stop it. You usually want a "status" and "restart" to tell you if 
> it's up and restart it. There's often a "condrestart" or I think 
> they're moving to "try-restart" that only restarts if the service is 
> already running. You can add your own if there are some specific 
> things you need--like a database might include an "init" for creating 
> a blank default database (like Postgresql does or used to do). If you 
> call the script with no params, or bad params, it's customary to print 
> a usage message.
>
> A lot of service binaries don't provide a way to stop themselves, so 
> James' script uses a common method of creating a PID file with the 
> process ID, and using that to kill the process on a stop. From a quick 
> Googling, it looks like your service doesn't want to be killed, and 
> provides a command to stop itself. That's fine--just replace the stop 
> logic in the script with your own stop command, such as:
>
> |lmutil lmdown -q -c license_file_name|
>
> The PID file may be useful for implementing the "status" unless lmutil 
> has that function too, that you can just call. Also, you might follow 
> the above command with a kill in your script if the above doesn't work 
> for some reason, but then you're just getting fancy!
>
> The only other thing you probably need is some specially formatted 
> comments. They are used by chkconfig and related commands for adding 
> the service and making sure it gets started and stopped in the right 
> spot. Here is a doc with some more info on the comment format.
>
> http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/initscrcomconv.html
>
> Scott
>
> ------------------------------------------------------------------------
>
> *From: *"Todor Fassl" <fassl.tod at gmail.com <mailto:fassl.tod at gmail.com>>
> *To: *"Atlanta Linux Enthusiasts" <ale at ale.org <mailto:ale at ale.org>>
> *Sent: *Tuesday, February 17, 2015 11:13:00 AM
> *Subject: *[ale] creating an init.d script
>
> My department runs a FlexLM license server for 2 mathematical programs,
> maple and matlab. I want to write some init.d scripts to restart the
> license server instances if we reboot the license server. Right now, I
> have to login and type the command. I can easily put it in a script but
> I want to do it right.
>
> I googled for examples but they all seem so complicated. I tried copying
> an existing script and modifying it (apprort) but after spending, I
> dunno, 10 minutes or so modifying it, I found it wasn't suitable as an
> example.
>
> What's a good generic init.d script to start with? Any good tutorials
> you are aware of? I don't want to spend all day learning how to write
> lsb scripts. An hour or 2 maybe but not all day. If I can't learn how to
> do it right in an hour or so, I'm just going to quick-and-dirty it.
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org <mailto:Ale at ale.org>
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo



More information about the Ale mailing list