Reputation: 602
I write a script to start/stop/restart a custom server application.
When starting the daemon server it should make the following:
#!/bin/sh -e
### BEGIN INIT INFO
...
...
### END INIT INFO
# Start service
pga_server_start()
{
/opt/pga/server/server -d
}
# Stop service
pga_server_stop()
{
PID=`cat /var/lock/pga_server.lock`
/bin/kill --signal SIGTERM $PID
}
pga_load_excalibur()
{
is_loaded=`lsmod | grep excalbr`
echo "Done"
if [ -z "$is_loaded" ]; then
/usr/local/bin/excload
echo "Driver excalibur loaded."
else
echo "Driver excalibur already loaded."
fi
}
case "$1" in
start)
pga_load_excalibur
pga_server_start
;;
...
...
Initialy it worked fine. Then I've added the pga_load_excalibur
function.
Afterward, it does not work anymore.
It never returns from the function pga_load_excalibur
.
It seems that the call to is_loaded=
lsmod | grep excalbrnever returns as the subsequent
echo` is never printed.
However, if I copy/paste this function in a separate shell script...it works.
But if I launch the starter script manually this way:
/etc/init.d/server start or service server start
it does not work. I'm using a Debian Wheezy 7.9 x64.
Although I'm not a schell script, it looks correct. I don't understand why it does not work when it's embedded into this service starter script.
Please note that I've also tried to replace the grep line with:
is_loaded=$(lsmod | grep excalbr)
But it does not work either. I'm running out of ideas :(
Z.
Upvotes: 1
Views: 1338
Reputation: 38
What do you get if you run the script in debug mode? try to run it with:
#!/bin/sh -xv
That may give some idea of why it's failing, post the output if you can't figure it out
Upvotes: 1