Revision 57

Date:
2008/01/10 20:11:42
Author:
dpavlin
Revision Log:
setup bridge between eth0 and wifi or other way around
Files:

Legend:

 
Added
 
Removed
 
Modified
  • trunk/dwm-status.pl

     
    17 17
    18 18 my $debug = shift @ARGV;
    19 19
    20 my $awesome = 0;
    21
    20 22 $|=1;
    21 23
    22 24 sub proc2hash {
     
    94 96
    95 97 my $i = 0;
    96 98
    99 if ( $awesome ) {
    100 undef $awesome;
    101 open( $awesome, '|-', 'awesome-client' ) || die "can't open awesome-client: $!";
    102 }
    103
    97 104 while ( 1 ) {
    98 105 my $s = strftime("%Y-%m-%d %H:%M:%S", localtime());
    99 106
     
    177 184 my $d_write = ( $d_w - $ld_w ) / $dt;
    178 185 ( $ld_r, $ld_w ) = ( $d_r, $d_w );
    179 186
    180 printf("%s | %s |%5s D %-5s|%5s > %-5s| %s%s\n",
    187 my $out = sprintf("%s | %s |%5s D %-5s|%5s > %-5s| %s%s\n",
    181 188 $s,
    182 189 $load,
    183 190 unit( $d_read ), unit( $d_write ),
     
    185 192 $bat, $temp,
    186 193 );
    187 194
    195 if ( $awesome ) {
    196 print $awesome "0 statusbar_set_text $out";
    197 } else {
    198 print $out;
    199 }
    200
    188 201 sleep $dt;
    189 202 }
    190 203
  • trunk/update-checkouts.sh

     
    17 17 ls -d */.git | sed 's#/.git##' | while read rep ; do
    18 18 echo "update $rep [git]"
    19 19 cd $rep && git pull || ./update.sh || echo "FATAL ERROR!"
    20 ln -sf `pwd`/.git /var/cache/git/$rep.git || echo "ERROR: can't update symlink to gitweb"
    20 21 cd -
    21 22 done
    22 23
  • trunk/wifi-bridge.sh

     
    1 #!/bin/sh
    2
    3 wif=`iwconfig 2>&1 | grep -i 802.11 | cut -d" " -f1`
    4
    5 essid=foobar
    6 key=s:secret
    7 ap=1
    8
    9 # doma
    10 essid=dreamhouse
    11 key=off
    12 ap=0
    13
    14 test -z "$wif" && (
    15 sudo rmmod ath_pci
    16 sudo modprobe ath_pci
    17 wif=`iwconfig 2>&1 | grep -i 802.11 | cut -d" " -f1`
    18 test -z "$wif" && echo "no wifi device" && exit
    19 )
    20
    21 echo "*** stop interfaces $wif eth0"
    22
    23 sudo ifconfig $wif down
    24 sudo ifconfig eth0 down
    25 sudo ifconfig br0 down
    26 sudo brctl delif br0 $wif
    27 sudo brctl delif br0 eth0
    28 sudo brctl delbr br0
    29
    30 if [ $ap == 1 ] ; then
    31 mode=ap
    32 else
    33 mode=managed
    34 fi
    35
    36 echo "*** setup wifi $mode $essid"
    37
    38 sudo wlanconfig $wif destroy || exit
    39 sudo wlanconfig $wif create wlandev wifi0 wlanmode $mode || exit
    40 wif=`iwconfig 2>&1 | grep -i 802.11 | cut -d" " -f1`
    41
    42 test -z "$wif" && echo "no wifi device" && exit
    43
    44 echo "*** using wifi $wif $essid"
    45
    46 sudo iwconfig $wif essid $essid
    47 sudo iwconfig $wif key $key
    48
    49 sudo ifconfig $wif up
    50 sudo iwconfig $wif
    51
    52 echo "*** creating bridge $wif eth0"
    53
    54 sudo brctl addbr br0
    55 sudo brctl delif br0 eth0
    56 sudo brctl delif br0 $wif
    57
    58 sudo ifconfig eth0 0.0.0.0 up
    59 sudo brctl addif br0 eth0
    60 sudo brctl addif br0 $wif
    61
    62 echo "*** getting public IP address"
    63
    64 sudo dhclient br0
    65 sudo ln -sf /etc/resolv.conf.dhclient-new /etc/resolv.conf-upstream
    66 sudo /etc/init.d/dnsmasq restart
    67