[Lunar-commits] CVS: lunar-tools/lnet lnet,1.1.1.1,1.2
Auke Kok
sofar at lunar-linux.org
Wed Nov 10 13:46:11 UTC 2004
Update of /var/cvs/lunar/lunar-tools/lnet
In directory espresso.foo-projects.org:/home/sofar/active/lunar-tools/lnet
Modified Files:
lnet
Log Message:
Heavily modified lnet: it is now more intuitive, has 'exit' buttons in the proper places. The main menuitems are also human readable
Index: lnet
===================================================================
RCS file: /var/cvs/lunar/lunar-tools/lnet/lnet,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- lnet 19 Oct 2004 10:39:38 -0000 1.1.1.1
+++ lnet 10 Nov 2004 13:46:09 -0000 1.2
@@ -46,41 +46,47 @@
exit 0
}
-main() {
-
-export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin"
-while true; do
- unset PROMPT COUNTER
- COUNTER=1
- CONFIGDIR="/etc/config.d/network"
+main ()
+{
+ unset PROMPT COUNTER
+ COUNTER=1
+ for DEVICE in `ls -1 $CONFIG_DIR`; do
+ if [ -L $CONFIG_DIR/$DEVICE ]; then
+ continue
+ fi
+ INTERFACES[$COUNTER]=$DEVICE
+ if [ -z "$LIST" ]; then
+ LIST="$COUNTER\nEdit device $DEVICE\n"
+ else
+ LIST="$LIST$COUNTER\nEdit device $DEVICE\n"
+ fi
+ (( COUNTER++ ))
+ done
- for DEVICE in `ls -1 $CONFIGDIR`; do
- if [ -L $CONFIGDIR/$DEVICE ]; then continue; fi;
- INTERFACES[$COUNTER]=$DEVICE
- echo $DEVICE
- PROMPT="$PROMPT $COUNTER $DEVICE"
- let COUNTER=$COUNTER+1
- done;
- COMMAND=`$DIALOG --title "Networking Device" \
- --nocancel \
+ while true; do
+ COMMAND=`$DIALOG --title "Network configuration" \
+ --ok-label "Select" \
+ --cancel-label "Exit" \
--menu \
- "Select a device to edit" \
+ "" \
0 0 0 \
- $PROMPT \
- 'A' 'Add' \
- 'D' 'DNS' \
- 'G' 'Gateway' \
- 'E' 'Exit' `
+ $(echo -en $LIST) \
+ "A" "Add a network device" \
+ "D" "Setup DNS configuration" \
+ "G" "Setup global Gateway"`
- case $COMMAND in
- [0-9]) ethernet_menu ${INTERFACES[$COMMAND]} ;;
+ if [ $? != 0 ] ; then
+ return
+ fi
+
+ case $COMMAND in
+ [0-9]*) ethernet_menu ${INTERFACES[$COMMAND]} ;;
A) ethernet_config ;;
D) dns_config ;;
G) gateway_config ;;
- E) return ;;
esac
- done
+ done
}
function dns_config() {
@@ -130,25 +136,25 @@
}
function gateway_config() {
- GATEWAY_PROMPT="Enter Gateway IP Address"
-
- GATEWAY=`inputbox "$GATEWAY_PROMPT" "$GATEWAY"`
-
-cat > /etc/config.d/gateway << EOF
-$GATEWAY
-EOF
+ GATEWAY_PROMPT="Enter Gateway IP Address"
+ GATEWAY=`inputbox "$GATEWAY_PROMPT" "$GATEWAY"`
+ echo "$GATEWAY" > /etc/config.d/gateway
}
function ethernet_menu() {
-
- COMMAND=`$DIALOG --title "Networking Device" \
- --nocancel \
+ PROMPT="Select an action for interface $1"
+ COMMAND=`$DIALOG --title "Modify device $1" \
+ --ok-label "Select" \
+ --cancel-label "Exit" \
--menu \
- "Select a device to edit" \
+ $PROMPT \
0 0 0 \
'C' 'Configure' \
- 'D' 'Delete' \
- 'E' 'Exit' `
+ 'D' 'Delete'`
+
+ if [ $? != 0 ] ; then
+ return
+ fi
case $COMMAND in
C) ethernet_config $1;;
@@ -320,15 +326,17 @@
}
+. /etc/lunar/config
-if [ "$UID" == 0 ]; then
- DIALOG="dialog --backtitle lnet --stdout"
- trap catch_sig INT
- trap ":" QUIT
- main
-else
- echo ""
- echo "User must have root privileges to run this program"
- echo ""
-fi
+root_check
+export IFS="$TAB_ENTER_IFS"
+DIALOG="dialog
+--backtitle
+lnet
+--stdout"
+
+trap catch_sig INT
+trap ":" QUIT
+
+main
More information about the Lunar-commits
mailing list