View previous topic :: View next topic |
Author |
Message |
shoelesshunter78 n00b
Joined: 24 May 2010 Posts: 58
|
Posted: Fri Mar 28, 2014 10:50 pm Post subject: init script |
|
|
I created a basic startup script to launch a program. I saved this script in
however when I issue
Code: | rc-update add foo.sh default |
I am informed that no such service exists.
I am very new to scripting and I appreciate any guidance in this area. |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Fri Mar 28, 2014 10:55 pm Post subject: |
|
|
is it a proper init script or is it a script with commands
This is an init script I wrote when I ran an ET:QW server
Code: |
depend() {
need net
}
start() {
ebegin "Starting ET:QW dedicated server"
screen -A -m -d -S etqw-ded su - games -c "/usr/games/bin/etqw-ded ${etqw_OPTS}"
eend $?
}
stop() {
ebegin "Stopping ET:QW dedicated server"
pid=`screen -list | grep etqw-ded | awk -F . '{print $1}' | sed -e s/.//`
if [ -z "${pid}" ] ; then
eend 1 "Lost screen session"
else
pid=`pgrep etqwded.x86`
if [ -z "${pid}" ] ; then
eend 1 "Lost etqwded session"
else
kill -9 ${pid}
eend $? "Could not kill etqwded"
fi
fi
}
status() {
screen -list | grep etqw-ded
} |
NOTE the depend, start,stop,status function
if you are just after additional commands at startup, there should be a local service & a /etc/local.d/ directory and bash/sh compliant script named: *.start and *.stop will be executed _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
lexflex Guru
Joined: 05 Mar 2006 Posts: 363 Location: the Netherlands
|
Posted: Sat Mar 29, 2014 2:49 pm Post subject: Re: init script |
|
|
Indeed, as Naib, says I think it has to be a propor initfile.
Next to this, two more points to check:
shoelesshunter78 wrote: | I created a basic startup script to launch a program. I saved this script in
|
I think naming it "foo.sh" is not allowed, since they are not shellscripts. So, try with the file called "foo" and "rc-update add foo default "
Also , check the permissions, it has to be executable ( so also perform chmod +x foo ).
Alex. |
|
Back to top |
|
|
shoelesshunter78 n00b
Joined: 24 May 2010 Posts: 58
|
Posted: Sat Mar 29, 2014 6:24 pm Post subject: |
|
|
thank you. changing the name to foo (instead of foo.sh) worked. |
|
Back to top |
|
|
|