Tuesday, January 31, 2006

Instant gateway

I've written a script that will turn my laptop into an instant gateway if I have a connection on the lan port. It uses dnsmasq for dns forwarding and DHCP while iptables provides the forwarding/masquerading for ip.

I use this for providing my Nokia 770 a link when I only have a wired connection, or when I want to ssh into my Nokia 770.

#!/bin/sh
#
# Requires: dnsmasq, iptables debian packages

function start () {
  ifdown --force eth1
  ifconfig eth1 10.2.5.2 netmask 255.255.255.0
  iwconfig eth1 mode ad-hoc
  iwconfig eth1 essid maemo
  /etc/acpi/ibm-wireless.sh on
  iptables -F
  iptables -t nat -F
  iptables -t mangle -F
  iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  echo 1 > /proc/sys/net/ipv4/ip_forward
  /etc/init.d/dnsmasq start
}

function stop () {
  /etc/acpi/ibm-wireless.sh off
  ifdown --force eth1
  iptables -F
  iptables -t nat -F
  iptables -t mangle -F
  echo 0 > /proc/sys/net/ipv4/ip_forward
  /etc/init.d/dnsmasq stop
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    stop
    start
    ;;
  *)
    echo "Usage: maemo {start|stop|restart}" >&2
    exit 1
    ;;
esac

exit 0

Monday, January 16, 2006

DVI working!

So using fglrx and selecting the mirror config from fglrx-config I was able to get my computer working with my DVI monitor such that I can unhook my laptop from the port replicator and dynamically readjust my resolution from 1600x1200 to the laptop display's 1400x1050 size. Initially I had to manually change resolutions by executing xrandr and FvwmCommand from a terminal. Now I've gotten it down to a small script. Yay for learning awk and sed . . .

#!/bin/bash
lcd=`xrandr|awk '/1400 x 1050/ {print $1}'|sed 's/*//'`
dvi=`xrandr|awk '/1600 x 1200/ {print $1}'|sed 's/*//'`

res=`xrandr|awk '/*/ {print $2 "x" $4}'`

if [[ $res = '1600x1200' ]]; then
  xrandr -s $lcd
  FvwmCommand 'Restart'
else
  xrandr -s $dvi
  FvwmCommand 'Restart'
fi

I would eventually like to have udev/hotplug/whatever thinger automatically detect when the monitor is connected and switch resolutions right then and there.

I would also like to make it so that I don't have to use the X11 output driver for media so that I can watch movies on the external display.

In other news, I enabled the experimental features of ibm-acpi so that I can use fanctrld

-->

Links

Me

Not Me

Archives

The views and opinions expressed in the blog are of Joe LaPenna. Google has nothing to do with these pages.
For information about Google please visit: Google Press Center