LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-23-2005, 05:34 AM   #1
short101
Member
 
Registered: May 2004
Location: Aust.
Distribution: Debian
Posts: 424

Rep: Reputation: 30
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
 
Old 01-23-2005, 06:31 AM   #2
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
you could probably just put a
modprobe slamr
at the end of your rc.local if that's what debian has
 
Old 01-23-2005, 06:43 AM   #3
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
# 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.
 
Old 01-23-2005, 06:46 AM   #4
short101
Member
 
Registered: May 2004
Location: Aust.
Distribution: Debian
Posts: 424

Original Poster
Rep: Reputation: 30
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.
 
Old 01-23-2005, 06:52 AM   #5
short101
Member
 
Registered: May 2004
Location: Aust.
Distribution: Debian
Posts: 424

Original Poster
Rep: Reputation: 30
/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.

Last edited by short101; 01-23-2005 at 06:57 AM.
 
Old 01-23-2005, 07:04 AM   #6
dustu76
Member
 
Registered: Sep 2004
Distribution: OpenSuSe
Posts: 153

Rep: Reputation: 30
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.
 
Old 01-23-2005, 07:08 AM   #7
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
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

Last edited by /bin/bash; 01-23-2005 at 07:10 AM.
 
Old 01-24-2005, 02:55 AM   #8
short101
Member
 
Registered: May 2004
Location: Aust.
Distribution: Debian
Posts: 424

Original Poster
Rep: Reputation: 30
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
 
Old 01-24-2005, 03:36 AM   #9
dustu76
Member
 
Registered: Sep 2004
Distribution: OpenSuSe
Posts: 153

Rep: Reputation: 30
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.
 
Old 01-24-2005, 05:49 AM   #10
short101
Member
 
Registered: May 2004
Location: Aust.
Distribution: Debian
Posts: 424

Original Poster
Rep: Reputation: 30
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.
 
Old 01-24-2005, 06:00 AM   #11
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
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
 
Old 01-24-2005, 06:51 AM   #12
short101
Member
 
Registered: May 2004
Location: Aust.
Distribution: Debian
Posts: 424

Original Poster
Rep: Reputation: 30
Talking 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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
How to call a script from a system startup script? jonatito Linux - Newbie 7 11-11-2005 09:40 PM
startup script ... again. Vindane Linux - Wireless Networking 2 03-04-2005 02:57 AM
startup script? ilnli Slackware 14 01-03-2005 12:07 PM
startup script djinniyah Linux - Newbie 2 09-18-2003 05:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration