View previous topic :: View next topic |
Author |
Message |
dasPaul Apprentice
Joined: 14 Feb 2012 Posts: 243 Location: Dresden
|
Posted: Sun May 08, 2016 7:42 am Post subject: custom init script instruction? |
|
|
Hi there
I want to write my own init script for the tvheadend executable.
I know there is already an initscript from the portage package BUT
I want to write it from scratch to learn how to write a proper init script
because I had a lot situations where local.d was not sufficient and I wished
an custom init script.
I have read Writing_initscripts but there is no explanation
what arguments has to be passed to start-stop-daemon and what to the executable*. Unfortunately the Wiki stays quite unclear if there are:
In "start()":
- Arguments to be passed to the executable (not the start-stop-daemon)... (proper syntax, must there be an "--" bevore every argument or just once?)
- Do I need extra "--background" after "start-stop-daemon" if the executable* is already called with an daemon/fork argument?
- Do I need extra "--pidfile" after "start-stop-daemon" if the executable* itself is already called with an "create pid" argument or can I call the executable without pid argument if --pidfile was passed to the start-stop-daemon?
- Do I have to use "-m" to "Create a pidfile" if the executable* itself is already called with an "create pid" argument?
In stop():
- do I need to use "--exec" and if yes why and when not? When to use --name? How does it find the process which receives the sigint signal?
(*tvheadend)
For example my tvheadend scipt:
Code: | #!/sbin/runscript
# Distributed under the terms of the GNU General Public License v2
# $Id$
TVUSER=paul
TVGROUP=video
depend() {
after udev # because the tv-stick is detected there
}
start() {
ebegin "Starting tvheadend..."
start-stop-daemon -m --background --start --pidfile /var/run/tvheadend.pid --exec /mnt/c2/store/build/kodi/opt/bin/tvheadend -- -S -p /var/run/tvheadend.pid -u $THUSER -f -g $TVGROUP
eend $?
}
stop() {
ebegin "Stopping tvheadend..."
start-stop-daemon --stop --pidfile /var/run/tvheadend.pid --exec /mnt/c2/store/build/kodi/opt/bin/tvheadend
eend $?
} |
|
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Sun May 08, 2016 11:21 am Post subject: Re: custom init script instruction? |
|
|
dasPaul wrote: | [*]Arguments to be passed to the executable (not the start-stop-daemon)... (proper syntax, must there be an "--" bevore every argument or just once?) |
your answer is given here no?
Code: | start-stop-daemon -m --background --start --pidfile /var/run/tvheadend.pid --exec /mnt/c2/store/build/kodi/opt/bin/tvheadend -- -S -p /var/run/tvheadend.pid -u $THUSER -f -g $TVGROUP |
after -- is arguments for the program: -S -p /var/run/tvheadend.pid -u $THUSER -f -g $TVGROUP
and i see many given there.
info start-stop-deamon will answer you a lot (--background and all). |
|
Back to top |
|
|
|