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
ATF-SH(1)						    BSD General Commands Manual 						 ATF-SH(1)

NAME
atf-sh [-s shell] -- interpreter for shell-based test programs SYNOPSIS
atf-sh script DESCRIPTION
atf-sh is an interpreter that runs the test program given in script after loading the atf-sh(3) library. atf-sh is not a real interpreter though: it is just a wrapper around the system-wide shell defined by ATF_SHELL. atf-sh executes the inter- preter, loads the atf-sh(3) library and then runs the script. You must consider atf-sh to be a POSIX shell by default and thus should not use any non-standard extensions. The following options are available: -s shell Specifies the shell to use instead of the value provided by ATF_SHELL. ENVIRONMENT
ATF_LIBEXECDIR Overrides the builtin directory where atf-sh is located. Should not be overridden other than for testing purposes. ATF_PKGDATADIR Overrides the builtin directory where libatf-sh.subr is located. Should not be overridden other than for testing purposes. ATF_SHELL Path to the system shell to be used in the generated scripts. Scripts must not rely on this variable being set to select a specific interpreter. EXAMPLES
Scripts using atf-sh(3) should start with: #! /usr/bin/env atf-sh Alternatively, if you want to explicitly choose a shell interpreter, you cannot rely on env(1) to find atf-sh. Instead, you have to hardcode the path to atf-sh in the script and then use the -s option afterwards as a single parameter: #! /path/to/bin/atf-sh -s/bin/bash ENVIRONMENT
ATF_SHELL Path to the system shell to be used in the generated scripts. SEE ALSO
atf-sh(3) BSD
September 27, 2014 BSD
All times are GMT -4. The time now is 09:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy