by wyhasany

SysVinit service generator

132 Stars 70 Forks Last release: Not found MIT License 60 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Note: You can acheive the same thing that this project tries to acheive by using the MetaInit package in debian: (

Sample service script for debianoids

This script enables fast daemonization apps as a Linux services with SysVinit init system.

Look at LSB init scripts for more information.

Original script taken from from naholyr's gist


Copy to

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
cp "" "/etc/init.d/$YOUR_SERVICE_NAME"
chmod +x /etc/init.d/$YOUR_SERVICE_NAME

Edit the script and replace following tokens:

  •  = 
  •  = Describe your service here (be concise)
  • Feel free to modify the LSB header, I've made default choices you may not agree with
  •  = Command to start your server (for example 
  •  = Login of the system user the script should be run as (for example 

Start and test your service:

service $YOUR_SERVICE_NAME start
service $YOUR_SERVICE_NAME stop

Install service to be run at boot-time:

update-rc.d $YOUR_SERVICE_NAME defaults

For rpm based distributions such as CentOS or Red Hat, you can use

chkconfig $YOUR_SERVICE_NAME --add

If you want to see which runlevel your script will run in

chkconfig $YOUR_SERVICE_NAME --list



The service can uninstall itself with

service $NAME uninstall
. Yes, that's very easy, therefore a bit dangerous. But as it's an auto-generated script, you can bring it back very easily. I use it for tests and often install/uninstall, that's why I've put that here.

Don't want it? Remove lines 56-58 of the service's script.


Your service will log its output to

. Don't forget to setup a logrotate :)

I'm noob and/or lazy

Yep, I'm lazy too. But still, I've written a script to automate this :)

wget '' && bash

In this script I will download
into a
, replace some tokens, and then show you commands you should run as superuser.

If you feel confident enough with my script, you can

the script directly:
wget '' && sudo bash

Note: the cool hipsterish

curl $URL | bash
won't work here, I don't really want to check why.

The script works offline so you can clone this repository then you can upload this script on your server and run it directly:

sudo bash

The script also handle parameters as showed below:

sudo bash "service_name" "description" "command to execute" "user which should run command"


Creating the service:


Looking at service files (logs, pid):


Uninstalling service:


We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.