[CONTACT]

[ABOUT]

[POLICY]

Log gph Files gph Refs gph

Found at: gopher.r-36.net:70/scm/conn/commit/8872fbb3f2e895252c738c246dc5491c9413d603.gph

Redoing the the Make system. Examples are now separate. - conn - A script repository to manage connections in Linux.

Log

Files

Refs

LICENSE

---

commit 8872fbb3f2e895252c738c246dc5491c9413d603

parent 60b63579a4dd28c88b7da1623c7e0277c641d42b

Author: Christoph Lohmann <20h@r-36.net>

Date:   Sun, 27 Feb 2011 18:27:34 +0100
Redoing the the Make system. Examples are now separate.
Diffstat:
  Makefile                            |      11 ++++++++++-
  README.md                           |       7 +++++++
  etc/conn/eth/README.md              |       6 ------
  etc/conn/eth/run.sh                 |      34 -------------------------------
  etc/conn/wifi/README.md             |      14 --------------
  etc/conn/wifi/networks.tbl          |       2 --
  etc/conn/wifi/networks/skkmswp.sh   |      22 ----------------------
  etc/conn/wifi/run.sh                |      36 -------------------------------
  etc/conn/wifi/wlan0-action.sh       |      39 -------------------------------
  etc/conn/wwan/README.md             |      11 -----------
  etc/conn/wwan/f3507g-x201-init      |      47 -------------------------------
  etc/conn/wwan/f3507g-x201-usbnet    |      26 --------------------------
  etc/conn/wwan/run.sh                |      13 -------------
  etc/conn/wwan/wwan0-run.sh          |      34 -------------------------------
  examples/eth/README.md              |       6 ++++++
  examples/eth/run.sh                 |      34 +++++++++++++++++++++++++++++++
  examples/wifi/README.md             |      14 ++++++++++++++
  examples/wifi/networks.tbl          |       2 ++
  examples/wifi/networks/skkmswp.sh   |      22 ++++++++++++++++++++++
  examples/wifi/run.sh                |      36 +++++++++++++++++++++++++++++++
  examples/wifi/wlan0-action.sh       |      39 +++++++++++++++++++++++++++++++
  examples/wwan/README.md             |      11 +++++++++++
  examples/wwan/f3507g-x201-init      |      47 +++++++++++++++++++++++++++++++
  examples/wwan/f3507g-x201-usbnet    |      26 ++++++++++++++++++++++++++
  examples/wwan/run.sh                |      13 +++++++++++++
  examples/wwan/wwan0-run.sh          |      34 +++++++++++++++++++++++++++++++
26 files changed, 301 insertions(+), 285 deletions(-)
---

diff --git a/Makefile b/Makefile

@@ -12,6 +12,11 @@ dist:
         @gzip conn-${VERSION}.tar
         @rm -rf conn-${VERSION}
+examples:
+        @echo installing example connections to ${DESTDIR}/etc/conn
+        @mkdir -p ${DESTDIR}/etc/conn
+        @cp -R examples/* ${DESTDIR}/etc/conn
+
 pm:
         @echo installing pm file to ${DESTDIR}/etc/pm/sleep.d
         @mkdir -p ${DESTDIR}/etc/pm/sleep.d
@@ -32,4 +37,8 @@ uninstall:
         @echo removing conn script from ${DESTDIR}${PREFIX}/bin
         @rm -f ${DESTDIR}${PREFIX}/bin/conn
-.PHONY: dist install uninstall
+uninstalletc:
+        @echo removing etc files from ${DESTDIR}/etc/conn
+        @rm -rf ${DESTDIR}${PREFIX}/etc/conn
+
+.PHONY: dist examples pm etc install uninstall

diff --git a/README.md b/README.md

@@ -17,12 +17,19 @@ many different connections in a Unix like environment.
 ## Installation
+Needed:
+
         # For installing the conn script.
         make install
         # For installing the etc files.
         make etc
+
+Optional:
+
         # For installing the pm sleep.d script.
         make pm
+        # For installing the example connections
+        make examples
 ## Architecture

diff --git a/etc/conn/eth/README.md b/etc/conn/eth/README.md

@@ -1,6 +0,0 @@
-## Ethernet - stable and gross
-
-Much could be done here, but the most obvious setup is to run dhcp on it.
-
-A combination with ifplugd could be done.
-

diff --git a/etc/conn/eth/run.sh b/etc/conn/eth/run.sh

@@ -1,34 +0,0 @@
-#!/bin/sh
-
-. ../common.sh
-
-interfce=$2
-t[ "$2" == "" ] && interface="eth0"
-
-case "$1" in
-        -s)
-                if ! islinkup $interface;
-                then
-                        setlinkup $interface
-                fi
-                startdhcp $interface
-                exit $?
-                ;;
-        -k)
-                stopdhcp $interface
-                islinkup $interface && setlinkdown $interface
-                exit $?
-                ;;
-        -u)
-                exit $?
-                ;;
-        -r)
-                $0 -k $interface;
-                $0 -s $interface;
-                ;;
-        *)
-                echo "usage: $0 [-s|-k|-u|-r] interface"
-                exit 1
-                ;;
-esac
-

diff --git a/etc/conn/wifi/README.md b/etc/conn/wifi/README.md

@@ -1,14 +0,0 @@
-# Wifi resolving
-
-1. run.sh starts wpa-supplicant and wpa-cli.
-2. wpa-cli runs $interface-action.sh on an event.
-3. $interface-action.sh greps in networks.tbl for the ssid of the
-   relevant network and calls the given script.
-4. The script networks/$script is run and gets the interface and
-   the changed state as argument.
-
-## WPA Supplicant
-
-The configuration file for wpa-supplicant is given in conn/common.sh;
-$WPA_CONF. Nearly everything can be changed there too.
-

diff --git a/etc/conn/wifi/networks.tbl b/etc/conn/wifi/networks.tbl

@@ -1,2 +0,0 @@
-skkmswp.sh        SKKMSWP
-

diff --git a/etc/conn/wifi/networks/skkmswp.sh b/etc/conn/wifi/networks/skkmswp.sh

@@ -1,22 +0,0 @@
-#!/bin/sh
-
-interface="$1"
-
-case "$2" in
-        CONNECTED)
-                # This is dangerous, but assumed.
-                ip addr flush dev $interface 2>&1 >/dev/null
-                ip addr add 192.168.1.6/24 dev $interface \
-                        brd 192.168.1.255 2>&1 >/dev/null
-                ip route add default via 192.168.1.2 dev $interface \
-                        2>&1 >/dev/null
-                echo "nameserver 8.8.8.8" > /etc/resolv.conf
-                ;;
-        DISCONNECTED)
-                ip addr del 192.168.1.6/24 dev $interface 2>&1 >/dev/null
-                ;;
-        *)
-                exit 1;
-                ;;
-esac
-

diff --git a/etc/conn/wifi/run.sh b/etc/conn/wifi/run.sh

@@ -1,36 +0,0 @@
-#!/bin/sh
-
-. ../common.sh
-
-interface=$2
-t[ "$2" == "" ] && interface="wlan0"
-
-case "$1" in
-        -s)
-                if ! islinkup $interface;
-                then
-                        setlinkup $interface
-                fi
-                startwpa $interface
-                exit $?
-                ;;
-        -k)
-                stopwpa $interface
-
-                islinkup $interface && setlinkdown $interface
-                exit $?
-                ;;
-        -u)
-                hupwpa $interface
-                exit $?
-                ;;
-        -r)
-                $0 -k $interface;
-                $0 -s $interface;
-                ;;
-        *)
-                echo "usage: $0 [-s|-k|-u|-r] interface"
-                exit 1
-                ;;
-esac
-

diff --git a/etc/conn/wifi/wlan0-action.sh b/etc/conn/wifi/wlan0-action.sh

@@ -1,39 +0,0 @@
-#!/bin/sh
-
-. ../common.sh
-
-interface="$1"
-action="$2"
-ssid=`getssid $interface`
-
-t[ $LOGGING -eq 1 ] && \
-        logger -t "$interface-action" "Got request for $interface $ssid $action."
-
-getscript() {
-        cat networks.tbl \
-                | grep "$ssid\$" \
-                | awk -F'\t' '{print $1}'
-}
-
-script=`getscript $ssid`
-if [ "$script" != "" ];
-tthen
-        cd networks
-        ./$script $interface $action
-        exit $?
-fi
-
-case "$action" in
-        CONNECTED)
-                startdhcp $interface
-                ;;
-        DISCONNECTED)
-                stopdhcp $interface
-                ;;
-        *)
-                exit 1;
-                ;;
-esac
-
-exit 0
-

diff --git a/etc/conn/wwan/README.md b/etc/conn/wwan/README.md

@@ -1,11 +0,0 @@
-# WWAN - the never ending story
-
-Wwan on Linux depends on the hardware you are using and how to initialize
-it. On my Laptop (X200), this is an Ericsson F3507g modem, which is setup
-via AT commands and exports an usb ethernet device for communication.
-
-Since it's my only device, the script for init and the usbnet are run
-in serial, after which dhcp is run on it. Besides this a ping is started,
-which increases the stability of a wwan connection; at least here in Ger-
-many.
-

diff --git a/etc/conn/wwan/f3507g-x201-init b/etc/conn/wwan/f3507g-x201-init

@@ -1,47 +0,0 @@
-#!/bin/bash
-
-CONTROL_DEVICE="/dev/ttyACM1"
-PIN="XXXXX"
-APN="surfo2"
-
-case "$1" in
-        -s)
-                modprobe zaurus
-
-                echo -n "Powering up F3507g card.."
-                echo enable > /proc/acpi/ibm/wan
-                rfkill unblock wwan
-                while [ ! -c $CONTROL_DEVICE ]; do sleep 0.5; echo -n "."; done
-                echo "done"
-                echo -n "Turning on F3507g card..."
-                sleep 5
-                if [ -n "$PIN" ]; then
-                        echo -n "PIN..."
-                            /usr/sbin/chat -v "" "AT+CPIN?" "SIM PIN" "AT" "OK" "AT+CPIN=\"$PIN\"" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
-                fi
-                echo -n "CFUN..."
-                /usr/sbin/chat -v "" "AT+CPIN?" "OK" "AT+CFUN=1" "+PACSP0" "AT" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
-                echo "done"
-        ;;
-        -k)
-                echo -n "Turning off F3507g card..."
-                /usr/sbin/chat -v "" "AT+CFUN=4" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
-                echo "done"
-                echo -n "Powering down F3507g card.."
-                rfkill block wwan
-                echo disable > /proc/acpi/ibm/wan
-                while [ -c $CONTROL_DEVICE ]; do sleep 0.5; echo -n "."; done
-                echo "done"
-
-                rmmod zaurus
-                rmmod cdc_ether
-        ;;
-        -r)
-                $0 -k
-                $0 -s
-        ;;
-        *)
-                echo "usage: $0 [-s|-k|-r]"
-esac
-exit 0
-

diff --git a/etc/conn/wwan/f3507g-x201-usbnet b/etc/conn/wwan/f3507g-x201-usbnet

@@ -1,26 +0,0 @@
-#!/bin/bash
-
-CONTROL_DEVICE="/dev/ttyACM1"
-APN="surfo2"
-
-case "$1" in
-        -s)
-                echo -n "Starting usbnet connection..."
-                /usr/sbin/chat -v "" "AT+CGDCONT=1,\"IP\",\"$APN\"" "OK" "AT*ENAP=1,1" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
-                sleep 1
-                echo "done"
-        ;;
-        -k)
-                echo -n "Stopping usbnet connection..."
-                /usr/sbin/chat -v "" "AT*ENAP=0" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
-                echo "done"
-        ;;
-        -r)
-                $0 -k
-                $0 -s
-        ;;
-        *)
-                echo "usage: $0 [-s|-k|-r]"
-esac
-exit 0
-

diff --git a/etc/conn/wwan/run.sh b/etc/conn/wwan/run.sh

@@ -1,13 +0,0 @@
-#!/bin/sh
-
-. ../common.sh
-
-inteface=$2
-t[ "$2" == "" ] && interface="wwan0"
-
-iffile="${WWANDIR}/${interface}-run.sh"
-
-t[ ! -e $iffile ] && exit 1
-
-$iffile $1
-

diff --git a/etc/conn/wwan/wwan0-run.sh b/etc/conn/wwan/wwan0-run.sh

@@ -1,34 +0,0 @@
-#!/bin/sh
-
-. ../common.sh
-
-interface=`getinterface $0`
-
-case "$1" in
-        -s)
-                ${WWANDIR}/f3507g-x201-init -s
-                ${WWANDIR}/f3507g-x201-usbnet -s
-                startdhcp $interface
-                startpingd $interface
-                exit $?
-                ;;
-        -k)
-                stoppingd $interface
-                stopdhcp $interface
-                ${WWANDIR}/f3507g-x201-usbnet -k
-                ${WWANDIR}/f3507g-x201-init -k
-                exit $?
-                ;;
-        -u)
-                exit 0
-                ;;
-        -r)
-                $0 -k $interface;
-                $0 -s $interface;
-                ;;
-        *)
-                echo "usage: $0 [-s|-k|-u|-r] interface"
-                exit 1
-                ;;
-esac
-

diff --git a/examples/eth/README.md b/examples/eth/README.md

@@ -0,0 +1,6 @@
+## Ethernet - stable and gross
+
+Much could be done here, but the most obvious setup is to run dhcp on it.
+
+A combination with ifplugd could be done.
+

diff --git a/examples/eth/run.sh b/examples/eth/run.sh

@@ -0,0 +1,34 @@
+#!/bin/sh
+
+. ../common.sh
+
+interfce=$2
+t[ "$2" == "" ] && interface="eth0"
+
+case "$1" in
+        -s)
+                if ! islinkup $interface;
+                then
+                        setlinkup $interface
+                fi
+                startdhcp $interface
+                exit $?
+                ;;
+        -k)
+                stopdhcp $interface
+                islinkup $interface && setlinkdown $interface
+                exit $?
+                ;;
+        -u)
+                exit $?
+                ;;
+        -r)
+                $0 -k $interface;
+                $0 -s $interface;
+                ;;
+        *)
+                echo "usage: $0 [-s|-k|-u|-r] interface"
+                exit 1
+                ;;
+esac
+

diff --git a/examples/wifi/README.md b/examples/wifi/README.md

@@ -0,0 +1,14 @@
+# Wifi resolving
+
+1. run.sh starts wpa-supplicant and wpa-cli.
+2. wpa-cli runs $interface-action.sh on an event.
+3. $interface-action.sh greps in networks.tbl for the ssid of the
+   relevant network and calls the given script.
+4. The script networks/$script is run and gets the interface and
+   the changed state as argument.
+
+## WPA Supplicant
+
+The configuration file for wpa-supplicant is given in conn/common.sh;
+$WPA_CONF. Nearly everything can be changed there too.
+

diff --git a/examples/wifi/networks.tbl b/examples/wifi/networks.tbl

@@ -0,0 +1,2 @@
+skkmswp.sh        SKKMSWP
+

diff --git a/examples/wifi/networks/skkmswp.sh b/examples/wifi/networks/skkmswp.sh

@@ -0,0 +1,22 @@
+#!/bin/sh
+
+interface="$1"
+
+case "$2" in
+        CONNECTED)
+                # This is dangerous, but assumed.
+                ip addr flush dev $interface 2>&1 >/dev/null
+                ip addr add 192.168.1.6/24 dev $interface \
+                        brd 192.168.1.255 2>&1 >/dev/null
+                ip route add default via 192.168.1.2 dev $interface \
+                        2>&1 >/dev/null
+                echo "nameserver 8.8.8.8" > /etc/resolv.conf
+                ;;
+        DISCONNECTED)
+                ip addr del 192.168.1.6/24 dev $interface 2>&1 >/dev/null
+                ;;
+        *)
+                exit 1;
+                ;;
+esac
+

diff --git a/examples/wifi/run.sh b/examples/wifi/run.sh

@@ -0,0 +1,36 @@
+#!/bin/sh
+
+. ../common.sh
+
+interface=$2
+t[ "$2" == "" ] && interface="wlan0"
+
+case "$1" in
+        -s)
+                if ! islinkup $interface;
+                then
+                        setlinkup $interface
+                fi
+                startwpa $interface
+                exit $?
+                ;;
+        -k)
+                stopwpa $interface
+
+                islinkup $interface && setlinkdown $interface
+                exit $?
+                ;;
+        -u)
+                hupwpa $interface
+                exit $?
+                ;;
+        -r)
+                $0 -k $interface;
+                $0 -s $interface;
+                ;;
+        *)
+                echo "usage: $0 [-s|-k|-u|-r] interface"
+                exit 1
+                ;;
+esac
+

diff --git a/examples/wifi/wlan0-action.sh b/examples/wifi/wlan0-action.sh

@@ -0,0 +1,39 @@
+#!/bin/sh
+
+. ../common.sh
+
+interface="$1"
+action="$2"
+ssid=`getssid $interface`
+
+t[ $LOGGING -eq 1 ] && \
+        logger -t "$interface-action" "Got request for $interface $ssid $action."
+
+getscript() {
+        cat networks.tbl \
+                | grep "$ssid\$" \
+                | awk -F'\t' '{print $1}'
+}
+
+script=`getscript $ssid`
+if [ "$script" != "" ];
+tthen
+        cd networks
+        ./$script $interface $action
+        exit $?
+fi
+
+case "$action" in
+        CONNECTED)
+                startdhcp $interface
+                ;;
+        DISCONNECTED)
+                stopdhcp $interface
+                ;;
+        *)
+                exit 1;
+                ;;
+esac
+
+exit 0
+

diff --git a/examples/wwan/README.md b/examples/wwan/README.md

@@ -0,0 +1,11 @@
+# WWAN - the never ending story
+
+Wwan on Linux depends on the hardware you are using and how to initialize
+it. On my Laptop (X200), this is an Ericsson F3507g modem, which is setup
+via AT commands and exports an usb ethernet device for communication.
+
+Since it's my only device, the script for init and the usbnet are run
+in serial, after which dhcp is run on it. Besides this a ping is started,
+which increases the stability of a wwan connection; at least here in Ger-
+many.
+

diff --git a/examples/wwan/f3507g-x201-init b/examples/wwan/f3507g-x201-init

@@ -0,0 +1,47 @@
+#!/bin/bash
+
+CONTROL_DEVICE="/dev/ttyACM1"
+PIN="XXXXX"
+APN="surfo2"
+
+case "$1" in
+        -s)
+                modprobe zaurus
+
+                echo -n "Powering up F3507g card.."
+                echo enable > /proc/acpi/ibm/wan
+                rfkill unblock wwan
+                while [ ! -c $CONTROL_DEVICE ]; do sleep 0.5; echo -n "."; done
+                echo "done"
+                echo -n "Turning on F3507g card..."
+                sleep 5
+                if [ -n "$PIN" ]; then
+                        echo -n "PIN..."
+                            /usr/sbin/chat -v "" "AT+CPIN?" "SIM PIN" "AT" "OK" "AT+CPIN=\"$PIN\"" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
+                fi
+                echo -n "CFUN..."
+                /usr/sbin/chat -v "" "AT+CPIN?" "OK" "AT+CFUN=1" "+PACSP0" "AT" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
+                echo "done"
+        ;;
+        -k)
+                echo -n "Turning off F3507g card..."
+                /usr/sbin/chat -v "" "AT+CFUN=4" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
+                echo "done"
+                echo -n "Powering down F3507g card.."
+                rfkill block wwan
+                echo disable > /proc/acpi/ibm/wan
+                while [ -c $CONTROL_DEVICE ]; do sleep 0.5; echo -n "."; done
+                echo "done"
+
+                rmmod zaurus
+                rmmod cdc_ether
+        ;;
+        -r)
+                $0 -k
+                $0 -s
+        ;;
+        *)
+                echo "usage: $0 [-s|-k|-r]"
+esac
+exit 0
+

diff --git a/examples/wwan/f3507g-x201-usbnet b/examples/wwan/f3507g-x201-usbnet

@@ -0,0 +1,26 @@
+#!/bin/bash
+
+CONTROL_DEVICE="/dev/ttyACM1"
+APN="surfo2"
+
+case "$1" in
+        -s)
+                echo -n "Starting usbnet connection..."
+                /usr/sbin/chat -v "" "AT+CGDCONT=1,\"IP\",\"$APN\"" "OK" "AT*ENAP=1,1" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
+                sleep 1
+                echo "done"
+        ;;
+        -k)
+                echo -n "Stopping usbnet connection..."
+                /usr/sbin/chat -v "" "AT*ENAP=0" "OK" > $CONTROL_DEVICE < $CONTROL_DEVICE
+                echo "done"
+        ;;
+        -r)
+                $0 -k
+                $0 -s
+        ;;
+        *)
+                echo "usage: $0 [-s|-k|-r]"
+esac
+exit 0
+

diff --git a/examples/wwan/run.sh b/examples/wwan/run.sh

@@ -0,0 +1,13 @@
+#!/bin/sh
+
+. ../common.sh
+
+inteface=$2
+t[ "$2" == "" ] && interface="wwan0"
+
+iffile="${WWANDIR}/${interface}-run.sh"
+
+t[ ! -e $iffile ] && exit 1
+
+$iffile $1
+

diff --git a/examples/wwan/wwan0-run.sh b/examples/wwan/wwan0-run.sh

@@ -0,0 +1,34 @@
+#!/bin/sh
+
+. ../common.sh
+
+interface=`getinterface $0`
+
+case "$1" in
+        -s)
+                ${WWANDIR}/f3507g-x201-init -s
+                ${WWANDIR}/f3507g-x201-usbnet -s
+                startdhcp $interface
+                startpingd $interface
+                exit $?
+                ;;
+        -k)
+                stoppingd $interface
+                stopdhcp $interface
+                ${WWANDIR}/f3507g-x201-usbnet -k
+                ${WWANDIR}/f3507g-x201-init -k
+                exit $?
+                ;;
+        -u)
+                exit 0
+                ;;
+        -r)
+                $0 -k $interface;
+                $0 -s $interface;
+                ;;
+        *)
+                echo "usage: $0 [-s|-k|-u|-r] interface"
+                exit 1
+                ;;
+esac
+
.


AD: