LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 03-05-2006, 06:24 PM   #1
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Rep: Reputation: 51
startup script for wpasupplicant


hi

I have opensuse 10.0 and wlan running with WPA encryption.
if I start the wpasupplicant from CLI:
Code:
# /usr/local/sbin/wpa_supplicant -w -i ath0 -D madwifi -c /etc/wpa_supplicant.conf -dd
State: GROUP_HANDSHAKE -> COMPLETED
evrything is fine.

but I'd like to start it automatically, using this script:
Code:
#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin

DAEMON=/usr/local/sbin/wpa_supplicant
PIDFILE="/var/run/wpasupplicant.pid"
CONFIG="/etc/wpa_supplicant.conf"
PNAME="wpa_supplicant"

# insane defaults
OPTIONS="-Bw" # daemonize and wait for interface
ENABLED=0

[ -f /etc/default/wpasupplicant ] && . /etc/default/wpasupplicant

if [ "$ENABLED" = "0" ]; then
	echo "wpasupplicant: disabled, see /etc/default/wpasupplicant"
	exit 0;
fi

[ -f $CONFIG ] || ( echo "No configuration file found, not starting."; \
	exit 1; )

[ -f $DAEMON ] || exit 0

set -e

case "$1" in
	start)
		echo -n "Starting wpasupplicant: "
		start-stop-daemon --start --name $PNAME \
			--oknodo --startas $DAEMON -- -B $OPTIONS
		echo "done."
		;;
	stop)
		echo -n "Stopping wpasupplicant: "
		start-stop-daemon --stop --name $PNAME \
			--oknodo
		echo "done."
		if [ -f $PIDFILE ]; then
			rm -f $PIDFILE;
		fi		
		;;
	reload|force-reload)
		echo -n "Reloading wpasupplicant: "
		start-stop-daemon --stop --signal HUP \
			--name $PNAME
		echo "done."
		;;
	restart)
		echo -n "Restarting wpasupplicant: "
		start-stop-daemon --stop --name $PNAME \
			--retry 5 --oknodo
		if [ -f $PIDFILE ]; then
			rm -f $PIDFILE;
		fi		
		start-stop-daemon --start --name $PNAME \
			--oknodo --startas $DAEMON -- -B $OPTIONS
		echo "done."
		;;
	*)
		echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
		exit 1
		;;
esac

exit 0
but I get following error:
Code:
# /etc/init.d/wpasupplicant stop
Stopping wpasupplicant: start-stop-daemon: need at least one of --exec, --pidfile or --user
Try `start-stop-daemon --help' for more information.
linux:~ # /etc/init.d/wpasupplicant start
Starting wpasupplicant: start-stop-daemon: need at least one of --exec, --pidfile or --user
Try `start-stop-daemon --help' for more information.
knows someone what's wrong and howto solve this problem ?

Last edited by cccc; 03-05-2006 at 06:29 PM.
 
Old 03-06-2006, 10:23 AM   #2
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
You are not fulfilling the requirements of the start-stop-daemon command. Your missing an option ... guessing by the way the script is written you need to change the line:

start-stop-daemon --start --name $PNAME --oknodo --startas $DAEMON -- -B $OPTIONS

to:

start-stop-daemon --start --name $PNAME --oknodo --startas $DAEMON -- -B $OPTIONS --pidfile $PIDFILE

the above is 1 line btw ... in the script the line is divided by the "\" but i wasnt sure if you know what that means ... just means more of the same line on the next line basically.

im guessing however as i dont know your system ... i would make a copy of your file add that and then try ... but that will only work for the start option if you want the other options of this to work you will have to add the pidfile option to the other sections as well. but see if that works and post back

Last edited by skog; 03-06-2006 at 10:26 AM.
 
Old 03-07-2006, 06:14 PM   #3
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
thanks, I changed but still get the following error:
Code:
# /etc/init.d/wpasupplicant start
Starting wpasupplicant: start-stop-daemon: need at least one of --exec, --pidfile or --user
Try `start-stop-daemon --help' for more information.
 
Old 03-08-2006, 04:48 PM   #4
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
try this on the command line: (all 1 line btw)

start-stop-daemon --start --name wpa_supplicant --oknodo --startas /usr/local/sbin/wpa_supplicant --pidfile /var/run/wpasupplicant.pid -- -B -Bw
 
Old 03-12-2006, 09:14 AM   #5
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
Code:
# start-stop-daemon --start --name wpa_supplicant --oknodo --startas /usr/local/sbin/wpa_supplicant --pidfile /var/run/wpasupplicant.pid -- -B -Bw
 /usr/local/sbin/wpa_supplicantstart-stop-daemon: (null): Bad address
 
Old 03-12-2006, 10:49 AM   #6
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
ok i think we found your problem then.

where is wpa_supplicant installed?

try this one:
start-stop-daemon --start --name wpa_supplicant --oknodo --startas <***put-path-to-wpa_supplicant-here***> --pidfile /var/run/wpasupplicant.pid -- -B -Bw

dont put the <*** or the ***> in the command just trying to bring attention to it.
 
Old 03-12-2006, 10:59 AM   #7
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
but the path is correct:
Code:
# start-stop-daemon --start --name wpa_supplicant --oknodo --startas /usr/local/sbin/wpa_supplicant --pidfile /var/run/wpasupplicant.pid -- -B -Bw
 /usr/local/sbin/wpa_supplicantstart-stop-daemon: (null): Bad address
linux:/usr/local/sbin # cd /usr/local/sbin
linux:/usr/local/sbin # ls -la
total 500
drwxr-xr-x   2 root root   4096 Mar  5 23:11 .
drwxr-xr-x  10 root root   4096 Mar  5 13:41 ..
-rwxr-xr-x   1 root root  52641 Mar 11 17:16 wpa_cli
-rwxr-xr-x   1 root root  40586 Mar 11 17:15 wpa_passphrase
-rwxr-xr-x   1 root root 400562 Mar  5 23:20 wpa_supplicant
 
Old 03-12-2006, 11:13 AM   #8
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
change the --startas to --exec

start-stop-daemon --start --name wpa_supplicant --oknodo --exec /usr/local/sbin/wpa_supplicant --pidfile /var/run/wpasupplicant.pid -- -B -Bw
 
Old 03-12-2006, 12:08 PM   #9
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
now I don't get any errors from the command line,
but the wpa_supplicant will be NOT executed and I cannot find any pid file
 
Old 03-12-2006, 12:45 PM   #10
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
did it start the wpa_supplicant program? it should start it if all the options are correct.

look with:

ps -aux | grep wpa_supplicant
 
Old 03-12-2006, 12:52 PM   #11
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
try this:

startproc -f -p /var/run/wpa_supplicant.pid /usr/local/sbin/wpa_supplicant -Ba


debian uses the start-stop-daemon util to start/stop services ... SuSE uses the LSB method. the above is the way SuSE does it ... im not to familiar with debs util if you just want it to work would be pretty easy to rewrite into a LSB script. but see if this works too
 
Old 03-12-2006, 01:02 PM   #12
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
wpa_supplicant program won't start
Code:
# start-stop-daemon --start --name wpa_supplicant --oknodo --exec /usr/local/sbin/wpa_supplicant --pidfile /var/run/wpasupplicant.pid -- -B -Bw
linux:~ # startproc -f -p /var/run/wpa_supplicant.pid /usr/local/sbin/wpa_supplicant -Bw
linux:~ # ps -aux | grep wpa_supplicant
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
root     13630  0.0  0.0   1860   604 pts/1    R+   20:02   0:00 grep wpa_supplicant

Last edited by cccc; 03-12-2006 at 01:03 PM.
 
Old 03-12-2006, 01:08 PM   #13
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
hmmm just a sec made a post ... and i guess its not right
 
Old 03-12-2006, 01:16 PM   #14
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
try this:

start-stop-daemon --start --name wpa_supplicant --oknodo --exec /usr/local/sbin/wpa_supplicant --pidfile /var/run/wpasupplicant.pid -- -B -w -i ath0 -D madwifi -c /etc/wpa_supplicant.conf -dd




***** this post just went to 2 pages make sure to check page 2

Last edited by skog; 03-12-2006 at 02:05 PM.
 
Old 03-12-2006, 01:55 PM   #15
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 51
thanks a lot !

now it starts the wpa_supplicant program, but don't create any pid file
 
  


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 Larsza SUSE / openSUSE 7 10-21-2005 06:59 AM
Startup Script djinniyah Linux - Newbie 3 09-18-2003 05:20 AM
startup script c0c0deuz Linux - Newbie 3 03-29-2003 03:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 12:17 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