Here the code:
#!/bin/sh # author: Alessandro Muratore # eMail: muratore.ale@gmail.com # # example shell script for setting up # on the fly your OpenBSD wifi # # wifi-home is static configuration # wifi-work is dynamic (dhcp) configuration pecora_chk_root(){ if [ $(whoami) != "root" ] ; then pecora_usage fi } pecora_usage(){ echo -e "you must be root: \n root ~ # $0 $1\n or \n user ~ \$ sudo $0 $1 \n" exit } case $1 in wifi-home) pecora_chk_root echo "wifi-home..." echo "insert wifi interface : " read wifi echo "insert IP : " read iph echo "insert ssid : " read sih echo "insert key : " read kh ifconfig $wifi up ifconfig $wifi $iph netmask 255.255.255.0 nwid $sih nwkey $kh echo "Setting nameserver..." echo "nameserver 212.216.112.112" > /etc/resolv.conf cat /etc/resolv.conf echo "Setting route..." echo "insert route : " read rh route add default $rh echo "Done." ;; wifi-work) pecora_chk_root echo "wifi-work..." echo "insert wifi interface : " read wifi echo "insert ssid : " read siw echo "insert key : " read kw ifconfig $wifi up ifconfig $wifi nwid $siw nwkey $kw echo "Start dhclient..." dhclient $wifi echo "nameserver 212.216.112.112" > /etc/resolv.conf echo cat /etc/resolv.conf ifconfig $wifi echo "done." ;; *) echo "args: [wifi-home | wifi-work]" ;; esac
Nessun commento:
Posta un commento