Generating an init script

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 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.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLEFxkAAoJEF+XTK08PnB5kCUP/02CO4ZNt39+bZOLSMCL4qC+
0xLGgufGPwgakRAIL8ZwnBXVfE7pqrLhu2Sv4VcpAxNwiDHEurSRNCy7MsKQgyHt
enN4yo5UfJGZ01iMO1VNjvmon2yAjMBiOMweEszP/jNOVQef9EKLppsp/YSrdMbo
bJMtrfjG8o6L7U7TEQVB8qkHaDbTuX6P4qlWXN+ZWKOPPnSdDNnFO0sqFlth9VZP
TyT0NRP1W24t5F0Mq+PPR3tddVhOlkcQL3LHUT1mk3FQMeQKG9Gf+trH5xFm0i/E
MbljFsBhmim9VUeVUPaDwFaILnJqs+qK0gQdSLmwWzr6Mg2xrd99PJWbVDfsKuyK
mPqw/QzR7OxlaHylaniTdbM8oIhBoyVLNhIJh/E+aBuoitCHSZHmOLuVVtS8GBuP
5pza6Bp4St1Wk/XbWQC62jRdQl8AW5rTwtsiHVA4Pj12u2Vru1s1rXMuQXa4DefC
DJLr16GIONt5aLK3le3Xg9Z8fnTxW2VXXIkjwiB3NcMxTFm9f/gkgL60Er/NKnQB
9EGuq5Aj6lc4d3OaJik3hwO6NRqesjb49kl6UjPIW9iOZFPXLQGa1d+Y3rkgBjfZ
HR/NaDZnTCqBzwExi9XMDI2GOoi6m3LEvN1s+mPLhF8yCWKtqPVgUDzeXsA6IDMG
DO0eOf/jrjp8XksTViDV
=XUlX
-----END PGP SIGNATURE-----

On Fri, 27 Nov 2009 23:10:29 GMT, “ab@novell.com” <ab@novell.com>
wrote:

>-----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.

Well…
http://en.opensuse.org/SDB:How_to_Create_Your_Own_Init_Script

I should have tried to find this before posting :smiley:

On Sat, 05 Dec 2009 12:56:01 GMT, djechelon
<djechelon@no-mx.forums.opensuse.org> wrote:

>
>Well…
>http://en.opensuse.org/SDB:How_to_Create_Your_Own_Init_Script
>
>I should have tried to find this before posting :smiley:

I just looked and the page is empty.

I added a few lines on the page.
I can still access the page from :How to Create Your Own Init Script - openSUSE](http://en.opensuse.org/index.php?title=:How_to_Create_Your_Own_Init_Script&oldid=113854)

but I agree now the page disappeared

On Sun, 06 Dec 2009 00:26:02 GMT, djechelon
<djechelon@no-mx.forums.opensuse.org> wrote:

>
>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

This link works. But it renders kind of funny.