Find the answer to your Linux question:
Results 1 to 4 of 4
I'm looking for the best way to create a chkconfig compatible script. Basically, I have some game servers I'm running (Counter-Strike Source and other HL2 mods) that I want to ...
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    2

    How to create initscript that is chkconfig compatible

    I'm looking for the best way to create a chkconfig compatible script. Basically, I have some game servers I'm running (Counter-Strike Source and other HL2 mods) that I want to start up when the box is fully booted and be able to control them easily by typing: "service cssource-server1 stop/start", and each server having a different service name so they are easily recognized. I already have a create a file which simply contains the line to execute and start the server, but how do I make it chkconfig compatible, include the script in /etc/init.d so it starts at boot up, and control it using the "service" command.

    Thanks in advance,

  2. #2
    Linux Newbie Ziplock's Avatar
    Join Date
    Jan 2009
    Location
    Adelaide
    Posts
    169
    Hi,

    The way I do it is to copy one of the existing scripts in /etc/init.d to a new name.

    You will see chkconfig related lines in the comments at the top. Modify these to suit your needs.

    Then:

    chkconfig --add <new_script_name>
    service <new_script_name> start|stop|restart...

  3. #3
    Just Joined!
    Join Date
    Mar 2009
    Posts
    2
    The scripts have so much code in them. Wouldn't I need to change all of that to suit the application that I'm trying to start?

  4. #4
    Linux Newbie Ziplock's Avatar
    Join Date
    Jan 2009
    Location
    Adelaide
    Posts
    169
    Quote Originally Posted by s1dest3pnate View Post
    The scripts have so much code in them. Wouldn't I need to change all of that to suit the application that I'm trying to start?
    Not really. Most of them have a initialization section, then a section for each of the start,stop,restart etc commands that you pass.

    Delete the bits that you don't need, and replace the start and stop commands with appropriate ones for your servers.

    Should be 10 mins work tops.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...