[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xAdmin, network start script



Would the following script be acceptable (in Debian and otherwise)?

----- s n i p p -----
#!/bin/sh
# Network start script, created by xAdmin/NET
# by Turbo Fredriksson <turbo@tripnet.se>

# Set some network variables...
IPADDR_lo=127.0.0.1
NETWORK_lo=127.0.0.0
BROADCAST_lo=127.255.255.255
ACTIVATE_lo=1
#
IPADDR_eth0=42.42.40.90
NETWORK_eth0=42.42.40.0
NETMASK_eth0=255.255.255.0
BROADCAST_eth0=42.42.40.255
GATEWAY_eth0=42.42.40.42
ACTIVATE_eth0=1

# Set the hostname...
if [ -f /etc/HOSTNAME ]; then
  hostname `cat /etc/HOSTNAME`
fi

# Set the domainname...
if [ -f /etc/defaultdomain ]; then
  domainname `cat /etc/defaultdomain`
fi

case "$1" in
  start)
    case "$2" in
      lo)
        # Start only the interface lo (loopback)
        if [ "${ACTIVATE_lo}" = 1 ]; then
          ifconfig lo ${IPADDR_lo} netmask ${NETMASK_lo} broadcast ${BROADCAST_lo}
          route add -net ${NETWORK_lo}
          route add default gw ${GATEWAY_lo} metric 1
        fi
        ;;
      eth0)
        # Start only the interface eth0 (ethernet)
        if [ "${ACTIVATE_eth0}" = 1 ]; then
          ifconfig eth0 ${IPADDR_eth0} netmask ${NETMASK_eth0} broadcast ${BROADCAST_eth0}
          route add -net ${NETWORK_eth0}
          route add default gw ${GATEWAY_eth0} metric 1
        fi
        ;;
      *)
        # Start ALL the configured devices...

        # Loopback device
        if [ "${ACTIVATE_lo}" = 1 ]; then
          ifconfig lo ${IPADDR_lo}
          route add -net ${NETWORK_lo}
        fi

        # Interface eth0 (ethernet)
        if [ "${ACTIVATE_eth0}" = 1 ]; then
          ifconfig eth0 ${IPADDR_eth0} netmask ${NETMASK_eth0} broadcast ${BROADCAST_eth0}
          route add -net ${NETWORK_eth0}
          route add default gw ${GATEWAY_eth0} metric 1
        fi
        ;;
    ;;
  stop)
    case "$2" in
      lo)
        # Stop only the interface lo (loopback)
        if [ "${ACTIVATE_lo}" = 1 ]; then
          ifconfig lo down
        fi
        ;;
      eth0)
        # Stop only the interface eth0 (ethernet)
        if [ "${ACTIVATE_eth0}" = 1 ]; then
          ifconfig eth0 down
        fi
        ;;
      *)
        # STOP all the configured devices...
        # Interface lo (loopback)
        if [ "${ACTIVATE_lo}" = 1 ]; then
          ifconfig lo down
        fi

        # Interface eth0 (ethernet)
        if [ "${ACTIVATE_eth0}" = 1 ]; then
          ifconfig eth0 down
        fi
      ;;
    ;;
  *)
    echo "Usage: $0 {start|stop} [lo|eth0]"
    exit 1
    ;;
esac

exit 0
----- s n i p p -----

-- 
-------------------------------------------------------------------------------
 Turbo  ___________     Debian GNU/Linux   Unix _IS_ user friendly - it's just
 ^^^^^  ___  /___(_)__________  _____  __  selective about who its friends are
        __  / __  /__  __ \  / / /_  |/_/
  _ /// _  /___  / _  / / / /_/ /__>  <   Turbo Fredriksson Tel: +46-704-697645
  \\\/  /_____/_/  /_/ /_/\__,_/ /_/|_|   S-415 10 Göteborg    turbo@tripnet.se
                  PGP#788CD1A9            SWEDEN         www5.tripnet.se/~turbo
----------- PGP:  B7 92 93 0E 06 94 D6 22  98 1F 0B 5B FE 33 A1 0B ------------
--
Panama Legion of Doom NSA smuggle [Hello to all my fans in domestic
surveillance] terrorist Ft. Meade Clinton ammunition Waco, Texas Nazi
CIA Croatian quiche class struggle


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-admintool-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: