Sponsored Content
Top Forums Shell Programming and Scripting FreeBSD rc.subr wireless script Post 302657147 by regexp on Saturday 16th of June 2012 12:18:09 PM
Old 06-16-2012
FreeBSD rc.subr wireless script

Hi,

This is my first thread on Unix forums, so be gentle.Smilie

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
 

10 More Discussions You Might Find Interesting

1. HP-UX

Wireless

Can someone please point me in the correct direction for setting up a wireless card using HP-UX 11iV1? I know its different depending on the type of card I have, but im looking for a direction. Thanks! (0 Replies)
Discussion started by: nickwinnie
0 Replies

2. BSD

OpenBSD and wireless

I've just installed OpenBSD on my laptop (IBM Thinkpad T42) and since this is my first time with wireless networking in OpenBSD I'm a bit lost. What I would like to do is connect to a wireless network using WEP or WPA. Where do I place the key and essid? (3 Replies)
Discussion started by: Timmy66
3 Replies

3. BSD

FreeBSD Wireless - Can do WPA but not WEP or even open

Hello, I am using FreeBSD on my laptop (R60) and currently it is working great, however, I am having trouble connecting to open or WEP secured networks. I have read the FreeBSD handbook regarding this many times. That is how I found out how to connect to WPA networks. If anyone could post a... (4 Replies)
Discussion started by: kpedersen
4 Replies

4. Shell Programming and Scripting

My Wireless Script Wont Work.....anyone??

ive been trying to write a simple (at least i thought it was) script to launch my wireless usb under ubuntu with kde. im using nano. when i run it from a terminal it works fine, but it just wont run from the script. there is a caveat, but first heres the script. ... (7 Replies)
Discussion started by: braze
7 Replies

5. Programming

Application crashes in FreeBSD 7.1 while working ok in FreeBSD 6.3

Hello there, My mulithreaded application (which is too large to represent the source code here) is crashing after installing FreeBSD 7.1-RELEASE/amd64. It worked properly on others machines (Dual Cores with 4GB of RAM - FreeBSD 6.2-RELEASE/i386). The current machine has 2x Core 2 Duo... (1 Reply)
Discussion started by: Seenquev
1 Replies

6. Linux

how to configure wireless now ?

Hi, I've installed wireless card and I didn't receive any error in the installation process. Now I want to use it but I can't make internet to work. if I check my card with iwconfig I get the following message wlan0 IEEE 802.11g ESSID:"Alice-34376718" Mode:Managed ... (2 Replies)
Discussion started by: aneuryzma
2 Replies

7. Shell Programming and Scripting

FreeBSD new user login script

I am a beginner programmer and would like to know where to start to modify the login process so that a user can login as username new password new and have it prompt user for username and password and nothing else and then create said user account on the system so they can ssh back in and login... (9 Replies)
Discussion started by: deshi
9 Replies

8. UNIX for Dummies Questions & Answers

'awk' help for script to clean out wireless.

I've been working on a script to clean out the wireless connections on my MAC. I know the terminal command to do this (that part is not rocket science ;) ) So I thought I would have a go at automating this but I'm having trouble with the 'awk' command & the correct context. My code is := ... (7 Replies)
Discussion started by: Lord Lien
7 Replies

9. BSD

An installation script on freeBSD

Hello So i got my hands on some freebsd iso, installed it in a qcow2 image and installled git and bash. So far, so good. Git repositry retireved install script executed files got copied files have exec flag files are in $PATH / found by which / bash-completion works But still,... (3 Replies)
Discussion started by: sea
3 Replies

10. Programming

Changing script to work with freeBSD

hi all, i have made my machine a freeBSD machine instead of a centos machine and my script doesnt work anymore and i was wondering if anyone can help me into why, i thought the commands are the same, here it is - #!/bin/bash source=/vol/cha-work/_ARCHIVE/to_be_archived/audio... (9 Replies)
Discussion started by: robertkwild
9 Replies
WPI(4)							   BSD Kernel Interfaces Manual 						    WPI(4)

NAME
wpi -- Intel 3945ABG Wireless LAN IEEE 802.11 driver SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device wpi device wpifw device pci device wlan device wlan_amrr device firmware Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): if_wpi_load="YES" DESCRIPTION
The wpi driver provides support for the Intel 3945ABG Wireless network adapter wpi supports station, adhoc, and monitor mode operation. Only one virtual interface may be configured at any time. For more information on configuring this device, see ifconfig(8). This driver requires the firmware built with the wpifw module to work. FILES
/usr/share/doc/legal/intel_wpi/LICENSE wpi firmware license EXAMPLES
Join an existing BSS network (i.e., connect to an access point): ifconfig wlan0 create wlandev wpi0 inet 192.168.0.20 netmask 0xffffff00 Join a specific BSS network with network name ``my_net'': ifconfig wlan0 create wlandev wpi0 ssid my_net up Join a specific BSS network with 64-bit WEP encryption: ifconfig wlan0 create wlandev wpi0 ssid my_net wepmode on wepkey 0x1234567890 weptxkey 1 up Join a specific BSS network with 128-bit WEP encryption: ifconfig wlan0 create wlandev wpi0 wlanmode adhoc ssid my_net wepmode on wepkey 0x01020304050607080910111213 weptxkey 1 DIAGNOSTICS
wpi%d: could not load firmware image '%s' The driver failed to load the firmware image using the firmware(9) subsystem. Verify the wpifw firmware module is installed. wpi%d: fatal firmware error An unknown error has occurred in the uploaded firmware, you may have to unload/reload the driver to continue. wpi%d: Radio transmitter is switched off The hardware switch controlling the radio is currently turned off. Data transmission is not possi- ble in this state. BUGS
Not all the error messages are documented here. Background scanning is not currently supported. SEE ALSO
wpifw(4), pci(4), wlan(4), wlan_ccmp(4), wlan_tkip(4), wlan_wep(4), ifconfig(8), wpa_supplicant(8). AUTHORS
The original wpi driver was written for OpenBSD by Damien Bergamini <damien.bergamini@free.fr>. Benjamin Close <benjsc@FreeBSD.org> ported wpi to FreeBSD. BSD
October 5, 2008 BSD
All times are GMT -4. The time now is 06:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy