r570 - x86/trunk/scripts

justin at linuxfromscratch.org justin at linuxfromscratch.org
Thu Aug 11 22:28:49 PDT 2005


Author: justin
Date: 2005-08-11 23:28:48 -0600 (Thu, 11 Aug 2005)
New Revision: 570

Modified:
   x86/trunk/scripts/net-setup
Log:
Added modem configuration, dial and hangup functions to net-setup.  This is the last major thing on my list.  Next, it could be cleaned up a bit, a few doubled things removed and any changes people think the menus/etc need.

Modified: x86/trunk/scripts/net-setup
===================================================================
--- x86/trunk/scripts/net-setup	2005-08-11 23:59:20 UTC (rev 569)
+++ x86/trunk/scripts/net-setup	2005-08-12 05:28:48 UTC (rev 570)
@@ -178,7 +178,64 @@
         fi
 }
 
+# Modem Device options
+set_modem_cfg(){
+        # Default values (only apply on first run-through, meaning MODEM_OK doesn't exist)
+        if [ -z "$MODEM_OK" ] ; then
+                F_DEVICE=/dev/ttyS1
+                F_SPEED=115200
+        fi
 
+        DLG_COMMAND="dialog --title \"Modem Configuration\" --no-cancel \
+        --form \"Please enter the modem details below:\" 0 0 5 \
+        \"Telephone Number:\" 1 1 \"$F_PHONE\" 1 25 20 0 \
+        \"User:\" 2 1 \"$F_USERNAME\" 2 25 30 0 \
+        \"Password:\" 3 1 \"$F_PASSWORD\" 3 25 30 0 \
+        \"Device:\" 4 1 \"$F_DEVICE\" 4 25 20 0 \
+        \"Speed:\" 5 1 \"$F_SPEED\" 5 25 10 0"
+        SELECTION=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
+
+        STATUS=$?
+        if [ "$STATUS" -ne 0 ] ; then
+                exit 1
+        fi
+
+        unset F_PHONE F_USERNAME F_PASSWORD F_DEVICE F_SPEED
+        eval "`echo "$SELECTION" | sed -e '1s,^,F_PHONE=",' -e '2s,^,F_USERNAME=",' \
+              -e '3s,^,F_PASSWORD=",' -e '4s,^,F_DEVICE=",' -e '5s,^,F_SPEED=",' | sed -e 's,$,",'`"
+
+        # Validate entries (All values except password are required.)
+        MODEM_OK=1
+        if [ -z "$F_PHONE" -o -z "$F_USERNAME" -o -z "$F_DEVICE" -o -z "$F_SPEED" ] ; then
+                MODEM_OK=0
+                MODEM_ERRMSG="The telephone number, username, device and speed are required fields."
+        fi
+
+        if [ "$MODEM_OK" -eq 1 ] ; then
+                # Make a backup and restore before changes, so the sed's work correctly.
+                [ -f /etc/ppp/peers/dialup.orig ] || cp /etc/ppp/peers/dialup /etc/ppp/peers/dialup.orig
+                [ -f /etc/ppp/pap-secrets.orig ] || cp /etc/ppp/pap-secrets /etc/ppp/pap-secrets.orig
+                cp /etc/ppp/peers/dialup.orig /etc/ppp/peers/dialup
+                cp /etc/ppp/pap-secrets.orig /etc/ppp/pap-secrets
+
+                # Alter /etc/ppp/peers/dialup file.
+                sed -i -e "s at TTTTTTT@$F_PHONE at g" -e "s@/dev/ttyS1@$F_DEVICE at g" \
+                       -e "s at 115200@$F_SPEED at g" -e "s@\"jdoe\"@\"$F_USERNAME\"@g" \
+		       /etc/ppp/peers/dialup
+
+                # Alter /etc/ppp/pap-secrets
+		echo $F_USERNAME dialup $F_PASSWORD >> /etc/ppp/pap-secrets
+
+                unset F_PHONE F_USERNAME F_PASSWORD F_DEVICE F_SPEED DLG_COMMAND STATUS
+                unset SELECTION MODEM_OK MODEM_ERRMSG
+        else
+                DLG_COMMAND="dialog --title \"Modem Validation Error\" \
+                --msgbox \"$MODEM_ERRMSG\" 6 60"
+                eval $DLG_COMMAND
+                set_modem_cfg;
+        fi
+}
+
 # Main Menu for Network Devices
 net_service_menu(){
 	# Remove previous config, so ifup won't get confused.
@@ -234,7 +291,40 @@
 
 # Main Menu for ppp modem devices
 ppp_modem_menu(){
-	echo "Modems will be supported soon."
+        unset ARGS
+        ARGS="$ARGS configure \"Configure your modem.\""
+        ARGS="$ARGS dial \"Dial modem and exit.\""
+        ARGS="$ARGS hangup \"Hang up modem and exit.\""
+
+        DLG_COMMAND="dialog --title \"Modem - Actions\" --default-item configure \
+                --menu \"Select the action to perform for your modem:\" \
+                0 0 0 $ARGS"
+        SERVICE=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
+
+        unset DLG_COMMAND ARGS
+
+        case "$SERVICE" in
+
+                configure)
+                        set_modem_cfg;
+                        ;;
+
+                dial)
+                        [ -e /dev/ppp ] || mknod /dev/ppp c 108 0
+                        modprobe ppp-generic ; pppd call dialup
+                        exit 0
+                        ;;
+
+                hangup)
+                        killall pppd
+                        exit 0
+                        ;;
+                *)
+                        exit 0
+                        ;;
+        esac
+
+        ppp_modem_menu;
 }
 
 # Main Menu for ppp gprs devices




More information about the livecd mailing list