LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Help with linmodem startup script (https://www.linuxquestions.org/questions/linux-software-2/help-with-linmodem-startup-script-281141/)

short101 01-23-2005 05:34 AM

Help with linmodem startup script
 
Hi all. I've had linux for a while now and have finally gotten sick of having to load my modem from the command line every time that I want to use it. So, I found a start up script that was included in later smartlink drivers. (not smart enough to write my own - yet) To start with, I had better say that this is on debian sarge. Now what I did was copy the script into /etc/init.d. Then I linked it with /etc/rd5.d and rc6.d for startup and shutdown. It doesn't work when I boot up but if I run /etc/init.d/slmodemd start, then the modem starts up. Now here is the funny part, in that now when I shut down my computer it appears that the modem is being started then. I get the following messages "--exec requires argument and also "see start-stop-daemon --help" and then I get the message that I normally get when the modem starts up and the computer wont shut down. The exec argument is in the script that I will include shortly. Does anyone know what I have done wrong? Obviously the script works as it starts the modem, its just my setting it up in init.d I think. In rc5.d the link is "S92slmodemd" which is linked to /etc/init.d and in rc6.d its "K29slmodemd" Hers the script


#!/bin/sh
#
# slmodemd: Starts the SmartLink Modem Daemon
#
# chkconfig: 345 90 10
# description: This is the user space part of the SmartLink Modem driver
# processname: slmodemd
# config: /etc/sysconfig/slmodem

# Source function library.
#. /etc/init.d/functions

NAME=slmodemd
DAEMON=/usr/sbin/slmodemd
PIDFILE=/var/run/$NAME.pid
RETVAL=0

# Default configuration
SLMODEMD_DEVICE=slamr0
SLMODEMD_COUNTRY=AUSTRALIA

# Test presence of daemon binary
test -f $DAEMON || exit 0

# Source configuration
CONFIG=/etc/default/$NAME
if [ -f $CONFIG ]; then
. $CONFIG
else
echo "
#
# This is the default configuration for the slmodem driver daemon
# running on Debian systems.
#
# Edit device node and country code here ...
#
# possible country codes are:
#
# USA
# GERMANY
# BELGIUM
# etc.
#
# use \'$DAEMON --countrylist\' to check out other countries
#

SLMODEMD_DEVICE=slamr0
SLMODEMD_COUNTRY=AUSTRALIA
" > $CONFIG
fi

# uncomment this if you want this feature (if necessary edit module
#pattern):
# do not try to start on a kernel which does not support it
grep 'slamr\..*o' /lib/modules/`uname -r`/modules.dep > /dev/null || { \

echo "SmartLink modem driver not supported by Kernel `uname -r`. Exiting
..."
exit 0

}

start() {
cat /proc/modules | grep 'slamr' >/dev/null || {
echo -n "Loading SmartLink Modem driver into kernel ... "
modprobe slamr && echo "done." || { i
echo "failed."
exit -1
}
}
echo -n "Starting SmartLink Modem driver for: $SLMODEMD_DEVICE"
start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --make-pidfile
--background --quiet -- -c $SLMODEMD_COUNTRY /dev/$SLMODEMD_DEVICE
RETVAL=$?
}

stop() {
echo -n "Shutting down SmartLink Modem driver normally"
ps -A | grep $NAME >/dev/null 2>/dev/null && {
start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec
$DAEMON ||
{
echo " probably failed."
echo -n "Trying it the hard way (send SIGKILL all $NAME processes): "
killall -KILL $NAME
/bin/true
RETVAL=0
}
} || { echo -n " ... no $NAME daemon running"; RETVAL=0; }

}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
echo ""
rm $PIDFILE
start
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
exit 1
esac


if [ $? == 0 ]; then
echo "."
if [ $1 == "stop" ]; then
rm $PIDFILE &>/dev/null
fi
exit 0
else
echo " failed."
exit -1
fi
## END


Much appreciated if someone can help me sort this out. By the way it's slmodem 2.9.3 that I am using.

Cheers

whansard 01-23-2005 06:31 AM

you could probably just put a
modprobe slamr
at the end of your rc.local if that's what debian has

/bin/bash 01-23-2005 06:43 AM

# Source function library.
#. /etc/init.d/functions

If there is a file /etc/init.d/functions then you should un-comment the above line.

Otherwise I don't see where the function start-stop-daemon is comming from. Debian has a file that is equivalent to /etc/init.d/functions but I don't remember the name of the file. Try looking through some of the other scripts in /etc/init.d to see how dameons are started.

Sorry I can't be more help but I'm stuck on a windows machine right now.

short101 01-23-2005 06:46 AM

The slamr module is already in /etc/modules and gets loaded at startup. (Dont think that has anything to do with it as I can start the modem from the script, without having to load the module) its just that it wont start at startup. Could be wrong though. Debian doesnt have rc.local. Just rc.0 ,.1, .2 etc.

short101 01-23-2005 06:52 AM

/bin/bash
Not sure what you are saying. Is the command not working cause there is no link to the function? Like its not a shell command? Sorry but as I said, I dont know much about scripting.

dustu76 01-23-2005 07:04 AM

I'm a fedora user so you get an idea about my Debian knowledge ;)

Try replacing "start-stop-daemon" with the full path i.e. "/usr/bin/start-stop-daemon" etc. since this doesn't look like a function but a program.

HTH.

/bin/bash 01-23-2005 07:08 AM

Your script is calling the function start-stop-daemon but that function is not in your script anywhere so I think it is probably in the functions script. If that is the case then you need to un-comment the line that sources the functions script.
#. /etc/init.d/functions
Of course if you don't have the functions script then that will just cause an error.

<edit> If it is a program like dustu76 suggested then nevermind :)

short101 01-24-2005 02:55 AM

Start-stop-daemon is a program (script?) and functions isnt in init.d. Its funny because I only get that error when the modem isnt running and I shut down the computer. The machine wont shut down cause the modem has just started up, but if the modem is running then the machine shuts down ok. Like I said, if I start it by running the script from a shell ie /etc/init.d/slmodemd start, then the modem starts up. This makes me think that the script is ok, its just that for some reason, it wont start as it enters runlevel 5. From what I can tell, its doing something as it goes into runlevel 6 but I cant tell whats really going on cause I dont really know that much about the whole process

dustu76 01-24-2005 03:36 AM

My suggestion was based on the following:

1. The script is starting when the user is firing the command but not during startup. One of the difference between these two situations could be environment like the variable PATH. If Start-stop-daemon is a program then it is possible that it is a directory which is not the PATH. What you could try is creating a softlink to the program in /usr/bin :

$ ln -s <Full_path_to_Start-stop-daemon> /usr/bin/Start-stop-daemon

2. The modem & shutdown problem could be due to chkconfig setup. Depends on when it gets called up & with what arguments.

HTH.

short101 01-24-2005 05:49 AM

Cheers dusta, but no joy with that suggestion. Might try this in the debian forum as i'm pretty sure that its got to do with the links and something with the run levels.

/bin/bash 01-24-2005 06:00 AM

Make sure this command is all on one line, if it spans multiple lines you need a "\" at the end of the line:
Code:

SHOULD BE:
 start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON  -make-pidfile --background --quiet -- -c $SLMODEMD_COUNTRY /dev/$SLMODEMD_DEVICE


THIS WILL ALSO WORK:
start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON --make-pidfile \
--background --quiet -- -c $SLMODEMD_COUNTRY /dev/$SLMODEMD_DEVICE


short101 01-24-2005 06:51 AM

Solved
 
Thanks to all.
?bin/bash, yep had to edit a couple of lines, cause where I copied it from, the web site must have cut it and when I ran it, was getting that error about needing an argument. Once that was fixed, I couldn't work out why it wouldn't work at bootup and shutdown. Then read something in the init.d readme about the policy manual, and lo and behold, the answer was in there. All I had to do was run "rcd-update" pointing to the script and it did the rest.
Rebooted and all worked beautifully. :)


All times are GMT -5. The time now is 11:43 PM.