Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
init script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
shoelesshunter78
n00b
n00b


Joined: 24 May 2010
Posts: 58

PostPosted: Fri Mar 28, 2014 10:50 pm    Post subject: init script Reply with quote

I created a basic startup script to launch a program. I saved this script in
Code:
/etc/init.d/foo.sh

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
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Fri Mar 28, 2014 10:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
lexflex
Guru
Guru


Joined: 05 Mar 2006
Posts: 363
Location: the Netherlands

PostPosted: Sat Mar 29, 2014 2:49 pm    Post subject: Re: init script Reply with quote

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
Code:
/etc/init.d/foo.sh


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
View user's profile Send private message
shoelesshunter78
n00b
n00b


Joined: 24 May 2010
Posts: 58

PostPosted: Sat Mar 29, 2014 6:24 pm    Post subject: Reply with quote

thank you. changing the name to foo (instead of foo.sh) worked.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum