Skip to content

Commit

Permalink
lnet: Properly set dhcp defaults when adding a new device
Browse files Browse the repository at this point in the history
- A new ethX file is now created immediately when adding a new device
  with dhcpcd as default instead of fooling the user into believing
  the options actually have been set while they actually were not
- Removed some annoying default texts
  • Loading branch information
Ratler committed Jun 25, 2012
1 parent c852f87 commit b1f03fc
Showing 1 changed file with 55 additions and 41 deletions.
96 changes: 55 additions & 41 deletions lnet/lnet
@@ -1,6 +1,6 @@
#!/bin/bash
############################################################
# Copyright 2002-2005 The Lunar Linux Team #
# Copyright 2002-2012 The Lunar Linux Team #
############################################################
# lnet is a menu driven configurator for the networking #
# init script #
Expand All @@ -10,6 +10,8 @@
# Just kidding. This is an adaption of the network config #
# contained within the Lunar install script. #
# #
# Copyright 2012 by Stefan Wold #
# #
# this code is GPLv2 #
############################################################

Expand Down Expand Up @@ -299,11 +301,46 @@ unset WIRELESS DEVICE AUTO MODULE MODULE_OPTIONS ADDRESS MANAGER
unset NETMASK BROADCAST GATEWAY DHCP_CLIENT DHCP_OPTIONS
unset WIRELESS_KEY WIRELESS_RATE WIRELESS_MODE WIRELESS_ESSID

if_template() {
cat > $CONFIG_DIR/$DEVICE << EOF
#
# configuration for "$DEVICE"
# automatically generated by lnet - do not edit, run 'lnet' instead
# -- `date`
#
AUTO="${AUTO:-Y}"
MODULE="$MODULE"
MODULE_OPTIONS="$MODULE_OPTIONS"
MANAGER="${MANAGER:-manual}"
WIRELESS="${WIRELESS:-N}"
WIRELESS_KEY="$WIRELESS_KEY"
WIRELESS_RATE="$WIRELESS_RATE"
WIRELESS_MODE="$WIRELESS_MODE"
WIRELESS_ESSID="$WIRELESS_ESSID"
ADDRESS="$ADDRESS"
NETMASK="$NETMASK"
BROADCAST="$BROADCAST"
IFCONF_OPTS="$IFCONF_OPTS"
DHCP_CLIENT="${DHCP_CLIENT:-dhcpcd}"
DHCP_OPTIONS="$DHCP_OPTIONS"
ROUTE_1="$ROUTE_1"
ROUTE_2="$ROUTE_2"
ROUTE_3="$ROUTE_3"
ROUTE_4="$ROUTE_4"
EOF
}

if [ -n "$1" ]; then
. $CONFIG_DIR/$1
. $CONFIG_DIR/$1
fi

DHCP_MODULE_MESSAGE="The DHCP client you have chosen is not installed. Before your device will work, you will need to install the following module: "

DHCP_MODULE_MESSAGE="The DHCP client you have chosen is not installed. Before your device will work, you will need to install the following module: "

if [ -z $1 ]; then
while [ -z $DEVICE ]; do
Expand All @@ -316,6 +353,12 @@ if [ -z $1 ]; then
fi
done
DEVICE=`inputbox "For more then one device, use the menu for each of them, ie: eth0, eth1 etc.." "$TDEV"`

# Generate a file immediately with some sane defaults
AUTO="Y"
ADDRESS="dhcp"
if_template
. $CONFIG_DIR/$DEVICE
done
else
DEVICE=$1
Expand Down Expand Up @@ -351,22 +394,23 @@ while true ; do
echo "C"
echo "Dhcp client [${DHCP_CLIENT:-dhcpcd}]"
echo "O"
echo "Dhcp options [${DHCP_OPTIONS:--h \`hostname\`}]"
echo "Dhcp options [${DHCP_OPTIONS}]"
fi
if [ "$ADDRESS" != "dhcp" ] ; then
echo "I"
echo "IP Address [${ADDRESS:-10.0.0.1}]"
echo "IP Address [${ADDRESS}]"
echo "N"
echo "Netmask [${NETMASK:-255.255.255.0}]"
echo "Netmask [${NETMASK}]"
echo "B"
echo "Broadcast [${BROADCAST:-10.0.0.255}]"
echo "Broadcast [${BROADCAST}]"
echo "F"
echo "Ifconfig options [${IFCONF_OPTS:-}]"
fi
)`
)`

if [ $? != 0 ]; then
return
return
fi

case $CHOICE in
Expand Down Expand Up @@ -431,7 +475,7 @@ while true ; do
fi ;;
esac
;;
O) DHCP_OPTIONS=`inputbox "Enter extra options passed to $DHCP_CLIENT" "${DHCP_OPTIONS:--h \`hostname\`}"`
O) DHCP_OPTIONS=`inputbox "Enter extra options passed to $DHCP_CLIENT" "${DHCP_OPTIONS}"`
;;
I) ADDRESS=`inputbox "Enter IP address" "$ADDRESS"`
;;
Expand All @@ -445,37 +489,7 @@ while true ; do

# save the config
cp -p $CONFIG_DIR/$DEVICE /tmp/lnet.$DEVICE
cat > $CONFIG_DIR/$DEVICE << EOF
#
# configuration for "$DEVICE"
# automatically generated by lnet - do not edit, run 'lnet' instead
# -- `date`
#
AUTO="$AUTO"
MODULE="$MODULE"
MODULE_OPTIONS="$MODULE_OPTIONS"
MANAGER="$MANAGER"
WIRELESS="$WIRELESS"
WIRELESS_KEY="$WIRELESS_KEY"
WIRELESS_RATE="$WIRELESS_RATE"
WIRELESS_MODE="$WIRELESS_MODE"
WIRELESS_ESSID="$WIRELESS_ESSID"
ADDRESS="$ADDRESS"
NETMASK="$NETMASK"
BROADCAST="$BROADCAST"
IFCONF_OPTS="$IFCONF_OPTS"
DHCP_CLIENT="$DHCP_CLIENT"
DHCP_OPTIONS="$DHCP_OPTIONS"
ROUTE_1="$ROUTE_1"
ROUTE_2="$ROUTE_2"
ROUTE_3="$ROUTE_3"
ROUTE_4="$ROUTE_4"
EOF
if_template

done
}
Expand Down

0 comments on commit b1f03fc

Please sign in to comment.