Hello,
I need to create an init script for a daemon I created using Mono. It is just a common TCP service.
Unfortunately, I don’t know how to program with the shell. I love those scripts that allow me to start, stop and restart programs in seconds.
Can anyone help me? I found an init script generator but I’m unhappy with it because it doesn’t fit all my requirements. Here they are:
*I start the application typing “mono Daemon.exe --daemonize --force”. With this, Daemon.exe writes a PID file into /var/run directory
*I stop the application typing “mono Daemon.exe --shutdown”. The daemon finds its running “twin” from the PID file and sends “kill -INT $PID” as CTRL-C to allow proper shutdown
*I must run the program with low privileges, ie. NOT AS ROOT, possibly in chroot environment (will the program then be able to write to a specific storage directory?)
I would like to have a configurable script where I can set:
*Program name (to display on console… ;))
*Startup command/options
*Shutdown command/options
*User to impersonate
*Chroot environment (optional)
The init script could even do write PID file by itself rather than requesting the application to do it, since I own the code and I can modify it the way I want.
Look at /etc/init.d/skeleton. It is made to help you do exactly what you
are doing. The FOO references should be replaced with your application’s
name, executable, description, etc. Making it run as another user is also
possible.
Good luck.
djechelon wrote:
> Hello,
> I need to create an init script for a daemon I created using Mono. It
> is just a common TCP service.
>
> Unfortunately, I don’t know how to program with the shell. I love those
> scripts that allow me to start, stop and restart programs in seconds.
>
> Can anyone help me? I found an init script generator but I’m unhappy
> with it because it doesn’t fit all my requirements. Here they are:
>
>
> *I start the application typing “mono Daemon.exe --daemonize --force”.
> With this, Daemon.exe writes a PID file into /var/run directory
> *I stop the application typing “mono Daemon.exe --shutdown”. The daemon
> finds its running “twin” from the PID file and sends “kill -INT $PID” as
> CTRL-C to allow proper shutdown
> *I must run the program with low privileges, ie. NOT AS ROOT, possibly
> in chroot environment (will the program then be able to write to a
> specific storage directory?)
>
> I would like to have a configurable script where I can set:
> *Program name (to display on console… ;))
> *Startup command/options
> *Shutdown command/options
> *User to impersonate
> *Chroot environment (optional)
>
> The init script could even do write PID file by itself rather than
> requesting the application to do it, since I own the code and I can
> modify it the way I want.
>
> Thank you in advance for your help.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Look at /etc/init.d/skeleton. It is made to help you do exactly what you
>are doing. The FOO references should be replaced with your application’s
>name, executable, description, etc. Making it run as another user is also
>possible.
>
>Good luck.
>
>
>
>
>
>djechelon wrote:
>> Hello,
>> I need to create an init script for a daemon I created using Mono. It
>> is just a common TCP service.
>>
>> Unfortunately, I don’t know how to program with the shell. I love those
>> scripts that allow me to start, stop and restart programs in seconds.
>>
>> Can anyone help me? I found an init script generator but I’m unhappy
>> with it because it doesn’t fit all my requirements. Here they are:
>>
>>
>> *I start the application typing “mono Daemon.exe --daemonize --force”.
>> With this, Daemon.exe writes a PID file into /var/run directory
>> *I stop the application typing “mono Daemon.exe --shutdown”. The daemon
>> finds its running “twin” from the PID file and sends “kill -INT $PID” as
>> CTRL-C to allow proper shutdown
>> *I must run the program with low privileges, ie. NOT AS ROOT, possibly
>> in chroot environment (will the program then be able to write to a
>> specific storage directory?)
>>
>> I would like to have a configurable script where I can set:
>> *Program name (to display on console… ;))
>> *Startup command/options
>> *Shutdown command/options
>> *User to impersonate
>> *Chroot environment (optional)
>>
>> The init script could even do write PID file by itself rather than
>> requesting the application to do it, since I own the code and I can
>> modify it the way I want.
>>
>> Thank you in advance for your help.
>>
>>
That is cool. It really should be made into a sticky somewhere.
>
>I added a few lines on the page.
>I can still access the page from ‘:How to Create Your Own Init Script -
>openSUSE’ (http://tinyurl.com/yllww5z)
>
>but I agree now the page disappeared