Skip to Content.
Sympa Menu

sm-discuss - [SM-Discuss] Different network provider

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: David Kowis <dkowis AT shlrm.org>
  • To: SM-Discuss <sm-discuss AT lists.ibiblio.org>
  • Subject: [SM-Discuss] Different network provider
  • Date: Wed, 23 Jan 2008 21:33:35 -0600

http://shlrm.org/gitweb/gitweb.cgi?p=grimoire/.git;a=summary

So I've spent some time replacing our network script system with the
same one that debian uses.
My reasoning is that it's more flexible and does more.

It doesn't require a great deal of knowledge to configure, and all the
man pages are included.

It greatly simplifies the init script as it replaces the start and stop
methods with ifup -a and ifdown -a

It's worked just fine for me in my xen vm, rebooted and I still had a
dhcp interface ;)

I'd like for you guys opinion on this, and perhaps we could integrate
it. The one time upgrade cost of it might be a bit high, but not really.
As the average user's interface is simply:

auto lo eth0

iface lo inet loopback

iface eth0 inet dhcp


--
David Kowis
==================================================================
| www.ronpaul2008.com | www.sourcemage.org |
| Ron Paul for President! | SourceMage GNU/Linux |
==================================================================
X-Git-Url:
http://shlrm.org/gitweb/gitweb.cgi?p=grimoire%2F.git;a=treediff_plain;h=17f81a09401269974fdb85aaf6c1a18615813987;hp=4f609f8cd8ddfc9f0e267d8ab246e37d7609e88c;hb=17f81a09401269974fdb85aaf6c1a18615813987;hpb=4f609f8cd8ddfc9f0e267d8ab246e37d7609e88c

---

diff --git a/net/ifupdown/BUILD b/net/ifupdown/BUILD
new file mode 100755
index 0000000..f5135ea
--- /dev/null
+++ b/net/ifupdown/BUILD
@@ -0,0 +1,2 @@
+make executables ifup.8.gz ifdown.8.gz interfaces.5.gz
+
diff --git a/net/ifupdown/DEPENDS b/net/ifupdown/DEPENDS
new file mode 100755
index 0000000..d147821
--- /dev/null
+++ b/net/ifupdown/DEPENDS
@@ -0,0 +1,2 @@
+depends run-parts &&
+depends net-tools
diff --git a/net/ifupdown/DETAILS b/net/ifupdown/DETAILS
new file mode 100755
index 0000000..e0f2520
--- /dev/null
+++ b/net/ifupdown/DETAILS
@@ -0,0 +1,16 @@
+ SPELL=ifupdown
+ VERSION=0.6.8
+ SOURCE=${SPELL}_$VERSION.tar.gz
+SOURCE_DIRECTORY=$BUILD_DIRECTORY/$SPELL-$VERSION
+ SOURCE_URL[0]=http://ftp.de.debian.org/debian/pool/main/i/ifupdown/$SOURCE
+
SOURCE_HASH=sha512:9842dce853b483e02cb2d0ca08d3fa66b42e9b7d37b9d86d2180e89835472260d1c2aeb445bf9cde274870c63584b0bd4d8035adf037cbb9ce167a522e1252df
+ LICENSE[0]=GPL
+ WEB_SITE=http://packages.debian.org/etch/ifupdown
+ ENTERED=20080123
+ KEYWORDS="tools net"
+ SHORT="Interface control tools"
+cat << EOF
+This package provides the tools ifup and ifdown which may be used to
configure
+(or, respectively, deconfigure) network interfaces based on interface
+definitions in the file /etc/network/interfaces.
+EOF
diff --git a/net/ifupdown/HISTORY b/net/ifupdown/HISTORY
new file mode 100644
index 0000000..5c50a57
--- /dev/null
+++ b/net/ifupdown/HISTORY
@@ -0,0 +1,3 @@
+2008-01-23 David Kowis <dkowis AT shlrm.org>
+ * DETAILS,BUILD,DEPENDS: Created this spell
+
diff --git a/net/ifupdown/INSTALL b/net/ifupdown/INSTALL
new file mode 100755
index 0000000..d7a7916
--- /dev/null
+++ b/net/ifupdown/INSTALL
@@ -0,0 +1,23 @@
+# the makefile doesn't ln -sf so it might fail. so we destroy an easily
+# creatable symlink for safety
+if [ -h $INSTALL_ROOT/sbin/ifdown ]; then
+ rm -f $INSTALL_ROOT/sbin/ifdown
+fi &&
+
+default_install &&
+
+# install the man pages to smart places
+cp *.8.gz $INSTALL_ROOT/usr/share/man/man8/. &&
+cp *.5.gz $INSTALL_ROOT/usr/share/man/man5/. &&
+
+# install the documentation type things
+mkdir -p $INSTALL_ROOT/usr/share/doc/$SPELL &&
+cp -va examples $INSTALL_ROOT/usr/share/doc/$SPELL/. &&
+
+# make the default directories
+mkdir -p /etc/network &&
+mkdir -p /etc/network/run &&
+mkdir -p /etc/network/if-post-down.d &&
+mkdir -p /etc/network/if-pre-up.d &&
+mkdir -p /etc/network/if-down.d &&
+mkdir -p /etc/network/if-up.d
diff --git a/net/net-tools/init.d/mountnetwork
b/net/ifupdown/init.d/mountnetwork
similarity index 100%
rename from net/net-tools/init.d/mountnetwork
rename to net/ifupdown/init.d/mountnetwork
diff --git a/net/net-tools/init.d/mountnetwork.conf
b/net/ifupdown/init.d/mountnetwork.conf
similarity index 100%
rename from net/net-tools/init.d/mountnetwork.conf
rename to net/ifupdown/init.d/mountnetwork.conf
diff --git a/net/ifupdown/init.d/network b/net/ifupdown/init.d/network
new file mode 100755
index 0000000..104563e
--- /dev/null
+++ b/net/ifupdown/init.d/network
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+. /etc/sysconfig/dhcpcd
+
+PROGRAM=/bin/false # To get auto_init functionality
+RUNLEVEL=3
+PROVIDES=network
+
+[ "$USE_SYSLOG" = "yes" ] && NEEDS="+syslog"
+
+. /etc/init.d/smgl_init
+
+required_executable /sbin/ifup
+required_executable /sbin/ifdown
+
+# this provides you with the ability to start/stop/check status on
+# one or more cards if you so desire.
+
+start()
+{
+ /sbin/ifup -a
+}
+
+stop()
+{
+ /sbin/ifdown -a
+}
+
+status()
+{
+ exit 0
+}
+
+reload() { exit 3; }
+
+usage()
+{
+ echo "Usage: $0 {start|stop|restart|status} [DEVICE]"
+}
diff --git a/net/net-tools/HISTORY b/net/net-tools/HISTORY
index 69e9113..2c460d3 100644
--- a/net/net-tools/HISTORY
+++ b/net/net-tools/HISTORY
@@ -1,3 +1,7 @@
+2008-01-23 David Kowis <dkowis AT shlrm.org>
+ * if*: removed all the ifupdown stuff
+ * init.d: removed the initscripts
+
2008-01-23 Vlad Glagolev <stealth AT sourcemage.org>
* init.d/network: fixed a weird bug ([DEVICE] was useless, now it
works)

diff --git a/net/net-tools/INSTALL b/net/net-tools/INSTALL
index b76d745..830a350 100755
--- a/net/net-tools/INSTALL
+++ b/net/net-tools/INSTALL
@@ -1,8 +1,2 @@
-make_normal &&
-make BASEDIR=${INSTALL_ROOT}/ install &&
-install -m 755 $SCRIPT_DIRECTORY/ifup ${INSTALL_ROOT}/sbin &&
-install -m 755 $SCRIPT_DIRECTORY/ifdown ${INSTALL_ROOT}/sbin &&
-install -m 755 $SCRIPT_DIRECTORY/ifup.8.gz \
- ${INSTALL_ROOT}/usr/share/man/man8/ &&
-install -m 755 $SCRIPT_DIRECTORY/ifdown.8.gz \
- ${INSTALL_ROOT}/usr/share/man/man8/
+make_normal &&
+make BASEDIR=${INSTALL_ROOT}/ install
diff --git a/net/net-tools/ifdown b/net/net-tools/ifdown
deleted file mode 100644
index 1917cf7..0000000
--- a/net/net-tools/ifdown
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/bash
-
-# $1 - needle
-exists_in_text()
-{
- [ "$1" = "" ] && return 0
-
- IFS="
-"
-
- for x in $( cat ) ; do
- [ "$1" = "$x" ] && return 0
- done
-
- return 1
-}
-
-_set_bridge()
-{
- for port in "$@"
- do
- brctl delif $DEV $port
- ifconfig $port 0.0.0.0 down
- done
-}
-
-_do_device_down()
-{
- [[ -n "$BRIDGE_PORTS" ]] && _set_bridge $BRIDGE_PORTS
- if [[ "$MODE" =~ ^dynamic ]]; then
- echo "Stopping dhcpcd on $DEV ..."
- dhcpcd -k $DEV &&
- sleep 2
- fi
- echo "Shutting down network interface $DEV ..."
- ifconfig $DEV 0.0.0.0 down
- [[ -n "$BRIDGE_PORTS" ]] && brctl delbr $DEV
-}
-
-_do_route_down()
-{
- true
-}
-
-_on_down()
-{
- true
-}
-
-# Handles function "overloading"
-run_func() {
- # If for example do_route_up exists then run it, otherwise run _do_route_up
- if [ "$( type -t $1 )" = function ] ; then
- $1
- else
- _$1
- fi
-}
-
-netdevdir=/etc/sysconfig/network
-
-#change this if your .pid file hides somewhere else
-DHCPCD_PATH="/var/run/dhcpcd-"
-DEV=$1
-
-if [ -z $DEV ]; then
- echo "Usage: ifdown <device>"
- exit 2
-fi
-
-if [ ! -f $netdevdir/$DEV.dev ]; then
- echo "$DEV: no such network device"
- exit 1
-fi
-
-if ! /sbin/ifconfig -a 2>&1 | exists_in_text $DEV ; then
- echo "$DEV already down"
- exit 0
-fi
-
-unset MODE MODULE IP BROADCAST NETMASK GATEWAY POINTTOPOINT MTU WIFI
-unset do_device_down do_route_down on_down
-
-. $netdevdir/$DEV.dev
-
-if [ -z "$MODE" ]; then
- echo "There are errors in $netdevdir/$DEV.dev"
- exit 1
-fi
-
-run_func do_device_down &&
-run_func do_route_down &&
-
-# only do this if network device is a module
-# sort needed to ensure unique lsmod module name (often 2x entries in table)
-if [ "$MODULE" ] && /sbin/lsmod | exists_in_text "$MODULE" ; then
- echo "Unloading module $MODULE for $DEV ..."
- modprobe -r $MODULE
-fi &&
-
-run_func on_down
diff --git a/net/net-tools/ifdown.8.gz b/net/net-tools/ifdown.8.gz
deleted file mode 100644
index 37fbdde..0000000
Binary files a/net/net-tools/ifdown.8.gz and /dev/null differ
diff --git a/net/net-tools/ifup b/net/net-tools/ifup
deleted file mode 100644
index fba1147..0000000
--- a/net/net-tools/ifup
+++ /dev/null
@@ -1,227 +0,0 @@
-#!/bin/bash
-
-# $1 - needle
-exists_in_text()
-{
- [ "$1" = "" ] && return 0
-
- IFS="
-"
-
- for x in $( cat ) ; do
- [ "$1" = "$x" ] && return 0
- done
-
- return 1
-}
-
-# $1 - device name
-device_is_up()
-{
- if [ -x /usr/bin/grep ]; then
- /sbin/ifconfig ${1} | grep -q "UP"
- else
- /sbin/ifconfig ${1} 2>&1 | exists_in_text "UP"
- fi
-}
-
-# $* - parameters for iwconfig, except device name
-# to be called from _do_device_up
-_set_wlan()
-{
- iwconfig $DEV $* &&
- IWC="$IWC $*"
-}
-
-_set_bridge()
-{
- # if the bridge doesn't exist add it
- if ! brctl show | grep $DEV
- then
- brctl addbr $DEV
- fi
- for port in "$@"
- do
- if ! brctl show $DEV | grep $port
- then
- brctl addif $DEV $port
- fi &&
- ifconfig $port 0.0.0.0 promisc up
- done
-}
-
-_do_device_up()
-{
- # collect settings for iwconfig
- local IWC=
- [[ -n "$WIFI_NWID" ]] && _set_wlan nwid $WIFI_NWID
- [[ -n "$WIFI_ESSID" ]] && _set_wlan essid $WIFI_ESSID
- [[ -n "$WIFI_RATE" ]] && _set_wlan rate $WIFI_RATE
- [[ -n "$WIFI_MODE" ]] && _set_wlan mode $WIFI_MODE
- [[ -n "$WIFI_KEY1" ]] && _set_wlan key $WIFI_KEY1 '[1]'
- [[ -n "$WIFI_KEY2" ]] && _set_wlan key $WIFI_KEY2 '[2]'
- [[ -n "$WIFI_KEY3" ]] && _set_wlan key $WIFI_KEY3 '[3]'
- [[ -n "$WIFI_KEY4" ]] && _set_wlan key $WIFI_KEY4 '[4]'
- [[ -n "$WIFI_DEFAULTKEY" ]] && _set_wlan key "[$WIFI_DEFAULTKEY]"
- [[ -n "$WIFI_SECMODE" ]] && _set_wlan key $WIFI_SECMODE
- [[ -n "$WIFI_KEY" ]] && _set_wlan key $WIFI_KEY
- [[ -n "$BRIDGE_PORTS" ]] && _set_bridge $BRIDGE_PORTS
-
- # make sure the wifi settings are applied if any of them are present
- [[ -n "$IWC" ]] && iwconfig $DEV commit && sleep 2
-
- case "$MODE" in
- dynamic )
- sed -i 's/MODE=.*/MODE=dynamic_set_hostname/' $netdevdir/$DEV.dev &&
- echo "Fixed error in $DEV.dev"
- . /etc/sysconfig/dhcpcd
- ARGS="-h $HOSTNAME"
-
- echo "Starting dhcpcd on $DEV ..."
- if [ -e $DHCPCD_PATH$DEV.pid ]; then
- dhcpcPid=`cat $DHCPCD_PATH$DEV.pid`
- dhcpcd -k $DEV 1>/dev/null 2>&1 &&
- renice 10 $dhcpcPid 1>/dev/null 2>&1 || rm -f $DHCPCD_PATH$DEV.pid &&
- sleep 1
- fi &&
- dhcpcd -t $TIMEOUT $ARGS $OPTIONS $DEV
- ;;
- dynamic_set_hostname )
- . /etc/sysconfig/dhcpcd
- ARGS="-h $HOSTNAME"
-
- echo "Starting dhcpcd on $DEV ..."
- if [ -e $DHCPCD_PATH$DEV.pid ]; then
- dhcpcPid=`cat $DHCPCD_PATH$DEV.pid`
- dhcpcd -k $DEV 1>/dev/null 2>&1 &&
- renice 10 $dhcpcPid 1>/dev/null 2>&1 || rm -f $DHCPCD_PATH$DEV.pid &&
- sleep 1
- fi &&
- dhcpcd -t $TIMEOUT $ARGS $OPTIONS $DEV
- ;;
- dynamic_get_hostname )
- . /etc/sysconfig/dhcpcd
- ARGS="-H"
-
- echo "Starting dhcpcd on $DEV ..."
- if [ -e $DHCPCD_PATH$DEV.pid ]; then
- dhcpcPid=`cat $DHCPCD_PATH$DEV.pid`
- dhcpcd -k $DEV 1>/dev/null 2>&1 &&
- renice 10 $dhcpcPid 1>/dev/null 2>&1 || rm -f $DHCPCD_PATH$DEV.pid &&
- sleep 1
- fi &&
- dhcpcd -t $TIMEOUT $ARGS $OPTIONS $DEV
- ;;
- static )
- echo "Setting up static networking on $DEV..."
- ARGS=""
- if [ "$POINTOPOINT" != "" ] ; then
- ARGS="$ARGS pointopoint $POINTOPOINT"
- fi
- if [ "$MTU" != "" ] ; then
- ARGS="$ARGS mtu $MTU"
- fi
-
- ifconfig $DEV $IP broadcast $BROADCAST netmask $NETMASK $ARGS
- ;;
- * )
- echo "There are errors in $netdevdir/$DEV.dev"
- exit 1
- ;;
- esac
-}
-
-_do_route_up()
-{
- # check if GATEWAY is set; gateway is set by PPP or other software in some
- # cases
- if [ "$GATEWAY" ]; then
- route add default gw $GATEWAY dev $DEV
- fi
-}
-
-_on_up()
-{
- true
-}
-
-# Handles function "overloading"
-run_func() {
- # If for example do_route_up exists then run it, otherwise run _do_route_up
- if [ "$( type -t $1 )" = function ] ; then
- $1
- else
- _$1
- fi
-}
-
-netdevdir=/etc/sysconfig/network
-
-#change this if your .pid file hides somewhere else
-DHCPCD_PATH="/var/run/dhcpcd-"
-DEV=$1
-
-if [ -z $DEV ]; then
- echo "Usage: ifup <device>"
- exit 2
-fi
-
-if [ ! -f $netdevdir/$DEV.dev ]; then
- echo "$DEV: no such network device"
- exit 1
-fi
-
-if device_is_up $DEV ; then
- echo "$DEV already up"
- exit 0
-fi
-
-unset MODE MODULE IP BROADCAST NETMASK GATEWAY POINTOPOINT MTU UP_ON_BOOT
MAC NEEDS
-unset WIFI_NWID WIFI_ESSID WIFI_RATE WIFI_MODE WIFI_SECMODE WIFI_ENCKEY
-unset do_device_up do_route_up on_up
-
-. $netdevdir/$DEV.dev
-
-for needed_device in ${NEEDS}; do
- echo -n "Checking if $needed_device is up... "
- if ( ifconfig | grep -q $needed_device ); then
- echo "yes it is" ;
- else
- echo "NO, it's not! Aborting!"
- exit 1 ;
- fi
-done
-
-if [ -z "$MODE" ]; then
- echo "There are errors in $netdevdir/$DEV.dev"
- exit 1
-fi
-
-if [ "${_OBEY_UP_ON_BOOT}" = 1 -a "$UP_ON_BOOT" = no ] ; then
- exit 0
-fi
-
-if [ "$MODULE" ] && ! /sbin/lsmod | exists_in_text "$MODULE" ; then
- echo "Loading module $MODULE for $DEV ..."
- modprobe $MODULE
-fi &&
-
-if [ "$WIFI" ]; then
- echo "Configuring wifi for $DEV ..."
- sleep 1 # to give the card time to start, needed on some cards.
- iwconfig $DEV ${WIFI}
-fi &&
-
-if [ "$MAC" ]; then
- echo "Setting custom MAC address for $DEV ..."
- if ( ifconfig $DEV | grep -q Ethernet ); then
- ifconfig $DEV hw ether $MAC
- echo "Custom MAC set for device $DEV";
- else
- echo "Can't set custom MAC for non-ethernet device $DEV";
- fi
-fi
-
-run_func do_device_up
-run_func do_route_up
-run_func on_up
diff --git a/net/net-tools/ifup.8.gz b/net/net-tools/ifup.8.gz
deleted file mode 100644
index ae72c22..0000000
Binary files a/net/net-tools/ifup.8.gz and /dev/null differ
diff --git a/net/net-tools/init.d/dhcpcd.conf
b/net/net-tools/init.d/dhcpcd.conf
deleted file mode 100644
index 368cbc9..0000000
--- a/net/net-tools/init.d/dhcpcd.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-# How many seconds should dhcpcd wait for an IP address?
-TIMEOUT=30
-
-# Set this variable to yes if you wish dhcpcd to use syslog for logging.
-USE_SYSLOG=no
-
-# Any command line options that should be passed to dhcpcd when it is
started.
-# Example usage: OPTIONS="-d -h $( hostname )"
-# See the manual page for dhcpcd for more information.
-OPTIONS=
diff --git a/net/net-tools/init.d/network b/net/net-tools/init.d/network
deleted file mode 100755
index bdfc2b2..0000000
--- a/net/net-tools/init.d/network
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/bin/bash
-
-. /etc/sysconfig/dhcpcd
-
-PROGRAM=/bin/false # To get auto_init functionality
-RUNLEVEL=3
-PROVIDES=network
-
-[ "$USE_SYSLOG" = "yes" ] && NEEDS="+syslog"
-
-. /etc/init.d/smgl_init
-
-required_executable /sbin/ifconfig
-required_executable /sbin/route
-required_executable /sbin/modprobe
-
-netdevdir=/etc/sysconfig/network
-
-# this provides you with the ability to start/stop/check status on
-# one or more cards if you so desire.
-
-if [ "$#" -le 1 ]; then
- devices="$(ls $netdevdir | grep dev$ | cut -d. -f1)"
-else
- devices="$(builtin echo $@ | sed s/$1//)"
-fi
-
-start()
-{
- required_executable /sbin/ifup
-
- export _OBEY_UP_ON_BOOT=1
- for DEVICE in $devices ; do
- [ "$DEVICE" = "lo" ] && continue
- echo "$(unset -f echo; /sbin/ifup $DEVICE)"
- evaluate_retval
- done
- unset _OBEY_UP_ON_BOOT
-}
-
-stop()
-{
- required_executable /sbin/ifdown
-
- for DEVICE in $devices ; do
- [ "$DEVICE" = "lo" ] && continue
- echo "$(unset -f echo; /sbin/ifdown $DEVICE)"
- evaluate_retval
- done
-}
-
-status()
-{
- for DEVICE in $devices ; do
- unset MODE on_status
-
- . $netdevdir/$DEVICE.dev
-
- if [ "$( type -t do_status )" = function ] ; then
- do_status # If on_status is defined in the device file
- elif [ -z "$MODE" ] ; then
- echo " There are errors in $netdevdir/$DEVICE.dev"
- else
- if [ "$MODE" = dynamic ]; then
- statusproc dhcpcd
- fi
- ifconfig $DEVICE
- fi
- done
-}
-
-reload() { exit 3; }
-
-usage()
-{
- echo "Usage: $0 {start|stop|restart|status} [DEVICE]"
-}

Attachment: signature.asc
Description: OpenPGP digital signature




Archive powered by MHonArc 2.6.24.

Top of Page