dslinux/user/pixil/apps/fltk/netconfig/scripts pixil-eth0.conf pixil-ifdown pixil-ifup pixil-network.conf

amadeus dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:24:28 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/pixil/apps/fltk/netconfig/scripts
In directory antilope:/tmp/cvs-serv11916/apps/fltk/netconfig/scripts

Added Files:
	pixil-eth0.conf pixil-ifdown pixil-ifup pixil-network.conf 
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it

--- NEW FILE: pixil-ifdown ---
#!/bin/sh

# Network configuration script for the Pixil Operating Environment
#
# Usage:  ./pixil-ifdown <device> 

# Explanation:
# Bring down the specified interface

CONFIG=${1}

[ -z "${CONFIG}" ] && {
  echo "usage:  ./pixil-ifdown <config | device>"
  exit 1
}

[ -f "${CONFIG}" ] || CONFIG=/usr/local/pixil/scripts/pixil-${CONFIG}.conf
[ -f "${CONFIG}" ] || {
  echo "Usage:  ./pixil-ifdown <config | device>"
  exit 1
}

source ${CONFIG}

# First, check if the interface is up

if [ -z ifconfig ${DEVICE} 2>/dev/null | grep " UP " >/dev/null 2>&1 ]; then
   echo "Device ${DEVICE} is not started!"
   exit 1
fi

if [ "${PROTO}" = dynamic ]; then
   [ -n "`/sbin/pidof -x pump`" ] && { 
     /sbin/pump -r -i ${DEVICE}
  }
fi

#if [ "${PROTO}" = dynamic ]; then
#   [ -n "'/sbin/pidof -x dhcpcd'" ] && {
#	/sbin/dhcpcd -k ${DEVICE}
#   }
#fi

/sbin/ifconfig ${DEVICE} down

# Wait a little while (thanks redhat for this code)

waited=0

while /sbin/ifconfig ${DEVICE} 2>/dev/null | grep " UP " >/dev/null 2>&1 && [ "$waited" -lt 50 ]; do
    sleep 1
   waited=$(($waited + 1))
done

--- NEW FILE: pixil-network.conf ---
DEVICE=eth0
PROTO=static
IPADDR=208.219.23.160
NETMASK=255.255.255.0
BROADCAST=208.219.23.255
GATEWAY=208.219.23.1

--- NEW FILE: pixil-ifup ---
#!/bin/sh

# Network configuration script for the Pixil Operating Environment
#
# Usage:  ./pixil-ifup <device> 

# TODO:
# This does some stupid stuff that only allows one device at at time
# We should do more checking for gateway / nameserver that will work
# across multiple interfaces

# RANT:
# I hate sed!

CONFIG=${1}
IFS=NULL

[ -z "${CONFIG}" ] && {
  echo "usage:  ./pixil-ifup <config | device>"
  exit 1
}

# We assume a default file of /usr/local/pixil/scripts/pixil-<device>.conf

[ -f "${CONFIG}" ] || CONFIG=/usr/local/pixil/scripts/pixil-${CONFIG}.conf 
[ -f "${CONFIG}" ] || {
  echo "No config '${CONFIG}' found"
  echo "Usage:  ./pixil-ifup <config | device>"
  exit 1
}

# Source the main configuration file
# provides HOSTNAME and GATEWAY

if [ -f ./pixil-network.conf ]; then
    source pixil-network.conf
fi

# Source the config file
source ${CONFIG}

# Verify that the device actually exists
/sbin/ifconfig ${DEVICE} 2>&1 | grep -s "not found" > /dev/null

if [ "$?" = "0" ]; then
   echo "Device ${DEVICE} is not available.  Delaying initialization..."
   exit 1
fi

# Make sure it is down

if /sbin/ifconfig ${DEVICE} 2>/dev/null | grep " UP " >/dev/null 2>&1; then
   echo "Device ${DEVICE} is already started....."
   exit 1
fi

# Ok, so now the fun stuff 

if [ "${PROTO}" = dynamic ]; then 
   PUMPARGS=
   
   if [ -n "HOSTNAME" ]; then 
      PUMPARGS="${PUMPARGS} -h ${HOSTNAME}"
   else
      PUMPARGS="${PUMPARGS} --lookup-hostname"
   fi

   if [ ! -x /sbin/pump ]; then
	echo "You don't have pump installed!"
	exit 1
   fi

   # Run the pump
  
   echo -n "Bringing up ${DEVICE}..."

   #if ! /sbin/dhcpcd -n ${DEVICE}; then
   #	echo "error"
   #	exit 1
   #else
   #	echo "done"
   #fi
 
   if [ ! -x "/sbin/pump ${PUMPARGS} -i ${DEVICE}" ]; then
     echo "error /sbin/pump ${PUMPARGS} -i ${DEVICE}"
      exit 1
   else
   	echo "done"
   fi

else # static

     # We need at least a IP address
     if [ -z "${IPADDR}" ]; then
	echo "No ip address was specified.  Bye!"
	exit 1
     fi

     # We can calculate the rest of the required functions
     if [ -z "${NETMASK}" ]; then
	eval `/bin/ipcalc --netmask ${IPADDR}`
     fi

     if [ -z "${BROADCAST}" ]; then
	eval `/bin/ipcalc --broadcast ${IPADDR} ${NETMASK}`	
     fi

     if [ -z "${NETWORK}" ]; then
	eval `/bin/ipcalc --network ${IPADDR} ${NETMASK}`	
     fi

     # Other flags make be required here
     /sbin/ifconfig ${DEVICE} ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST} 
	   
     # Go ahead and construct all of the routes
     /sbin/route add -net ${NETWORK} netmask ${NETMASK} dev ${DEVICE}
     
     # If there is no specified gateway, then add it
     # TODO:  Remove the previous one that is there????

    if ! /sbin/route -n 2>/dev/null | grep " UG " >/dev/null 2>&1; then
	if [ -n "${GATEWAY}" ]; then
	 /sbin/route add default gw ${GATEWAY} dev ${DEVICE}
	fi	
    fi

     # Make a new nameserver file
     # This is only possible because we have one interface.  Otherwise, we 
     # have a whole world of hurt here

     if [ -n "${NAMESERVER1}" ]; then 
	if [ -f /etc/resolv.conf ]; then
	   cp /etc/resolv.conf /etc/resolv.conf.backup-${DEVICE}
	fi

	echo "" > /etc/resolv.conf

	if [ -n "${DOMAIN}" ]; then
	  echo "search ${DOMAIN}" >> /etc/resolv.conf
	fi

	if [ -n "${NAMESERVER1}" ]; then
	  echo "nameserver ${NAMESERVER1}" >> /etc/resolv.conf
	fi

	if [ -n "${NAMESERVER2}" ]; then
	   echo "nameserver ${NAMESERVER2}" >> /etc/resolve.conf
	fi
    fi      
fi

# If we don't want to set any wireless settings, 
# then leave quietly

if [ ! -n "${ESSID}" ] && [ ! -n "${WEPID}" ]; then
    echo "No ESSID or WEPID key."
    exit 0
fi

if [ ! -x /sbin/iwconfig ]; then 
    echo "/sbin/iwconfig not found."
    exit 1
fi

if /sbin/iwconfig ${DEVICE} 2>&1 | grep "no wireless extensions" >/dev/null 2>&1; then
    echo "No wireless available for ${DEVICE}"
    exit 1
fi

IWCONFIG_ARGS=

if [ -n "${ESSID}" ]; then
    echo -n "setting essid to ${ESSID}..."
    IWCONFIG_ARGS="/sbin/iwconfig ${DEVICE} essid \"${ESSID}\""
    echo "done."
fi

if [ -n "${IWCONFIG_ARGS}" ]; then
	echo "${IWCONFIG_ARGS}"
	${IWCONFIG_ARGS}
fi

exit 0
    

   
   



--- NEW FILE: pixil-eth0.conf ---
DEVICE=eth0
PROTO=dhcp

IPADDR=

DOMAIN=censoft.com
NAMESERVER1=208.219.23.2




More information about the dslinux-commit mailing list