|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
FreeBSD rc.subr wireless script
Hi, This is my first thread on Unix forums, so be gentle. ![]() I'm trying to write a simple start/stop script for my wireless networking adapter, under FreeBSD, using the rc.subr framework. Code:
#!/bin/sh
# PROVIDE Wireless
# KEYWORDS shutdown
. /etc/rc.subr
name="wireless"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
wireless_start()
{
#Check whether wlan0 already exists
for faces in `ifconfig -lu`
do
if [ "$faces" != "wlan0" ]
then
//Create the device
ifconfig wlan0 create wlandev iwn0
fi
done
#Add an ip address
ifconfig wlan0 inet 192.168.2.12 netmask 255.255.255.0
route add -net default 192.168.2.45
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf &
}
wireless_stop()
{
ifconfig wlan0 down 2> /dev/null
route delete -net default 192.168.2.45
ifconfig wlan0 destroy wlandev iwn0 2> /dev/null
}
load_rc_config $name
run_rc_command "$1"Is this ok? Is there a better way ? Regards Regexp |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
First off, let me congratulate you: this is by far the best first posting i have read here for ages. You even seem to understand how to use CODE-tags, which will earn you the eternal respect and heartfelt thankfulness of the complete moderation team.
This is OK. In fact, start-/stop-scripts have been written this way for a long time. Just as a suggestion, you might want to add a "restart" function, which simply consists of a call to "stop()" first and then a call to "start()". Another suggestion: do you really want to hard-code the IP address into a rc-script? You might want to make the script more generic by obtaining the IP-address in its own script. This would either read it from some configuration file or get it via DHCP, bootp or the like. I hope this helps. bakunin |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| FreeBSD new user login script | deshi | Shell Programming and Scripting | 9 | 11-05-2011 01:27 AM |
| Application crashes in FreeBSD 7.1 while working ok in FreeBSD 6.3 | Seenquev | Programming | 1 | 01-20-2009 08:07 AM |
| My Wireless Script Wont Work.....anyone?? | braze | Shell Programming and Scripting | 7 | 01-19-2009 05:34 PM |
| FreeBSD Wireless - Can do WPA but not WEP or even open | kpedersen | BSD | 4 | 08-24-2008 03:45 PM |
| Wireless | nickwinnie | HP-UX | 0 | 10-16-2005 11:58 PM |
|
|