You are not logged in.

#1 2007-12-25 14:02:23

fetid
Member
From: china
Registered: 2007-12-21
Posts: 19

my laptop network autoprobe

autonetwork.sh

#!/bin/sh

if [ `id -u` -ne 0 ]; then exit 1; fi

PROFILE_DIR="/etc/network-profiles"
STATE_DIR="/var/run/net"

if [ "$(ls $PROFILE_DIR 2>/dev/null | grep -v ^template$)" = "" -o ! -d $PROFILE_DIR ]; then
    echo "No profiles found.  Add profiles in $PROFILE_DIR"
    return
fi
# scan all profiles
unset profiles
i=0
for prof in $(ls $PROFILE_DIR); do
    # ignore the template
    [ "$prof" = "template" ] && continue
    NAME=$prof

    unset DESCRIPTION INTERFACE IFOPTS GATEWAY
    . $PROFILE_DIR/$NAME
    if [ "$DESCRIPTION" ]; then
        profiles[$i]=$NAME
        i=$((i+1))
        profiles[$i]=$DESCRIPTION
        i=$((i+1))
        if [ "$INTERFACE" ] && [ "$IFOPTS" ] ; then
            #echo $INTERFACE $IFOPTS $GATEWAY
            /sbin/ifconfig $INTERFACE $IFOPTS up >/dev/null 2>&1
            ping -c 2 $GATEWAY >/dev/null 2>&1

            if [ $? = "0" ]; then
                [ "$GATEWAY" ] && /sbin/route add default gw $GATEWAY >/dev/null 2>&1
                   mkdir -p $STATE_DIR
                   cp $PROFILE_DIR/$prof $STATE_DIR/$INTERFACE
                   hostname $HOSTNAME
                break
            else
                /sbin/ifconfig $INTERFACE down >/dev/null 2>&1
            fi
        fi
    fi
done

update /etc/rc.d/network

--- /etc/rc.d/network    2007-12-25 21:56:05.000000000 +0800
+++ network    2007-12-25 21:40:30.000000000 +0800
@@ -172,7 +172,9 @@
                 /usr/bin/netcfg $NET
             fi
         elif [ "$NET_PROFILES" ]; then
-            if [ "$NET_PROFILES" = "menu" ]; then
+            if [ "$NET_PROFILES" = "auto" ]; then
+                /usr/bin/autonetwork.sh
+            elif [ "$NET_PROFILES" = "menu" ]; then
                 /usr/bin/netcfg --menu --timeout 5
             else
                 for prof in ${NET_PROFILES[@]}; do

update /etc/rc.conf

...
#NET_PROFILES=(menu)
NET_PROFILES=(auto)
...

Last edited by fetid (2008-01-02 10:51:40)


Pleasing Archlinux the World Over.

Offline

Board footer

Powered by FluxBB