Novell is now a part of Micro Focus

HowTo: Create a Dialog Console-Based Configuration Helper - Part 3

Novell Cool Solutions: Feature
By Stomfi

Digg This - Slashdot This

Posted: 17 Nov 2005

This is part 3 of the fixit system, a utility for helping the newbie fix common SUSE configuration problems from the command line.

In Part One we developed the main menu, and the X window item. The utility displayed the contents of the X configuration file, or various parts of it, and context sensitive help. The help was extracted from the existing SUSE documentation and saved in help files for the fixit system. The fixit system was saved in a global directory tree "/usr/local/FIXIT" with root permissions, and a check performed when starting the utility to make sure that the user is "root", as only root can make system configuration changes.

In Part Two the content of the various X system help files were given and the scripts and help for configuring the mouse.

In the list of common configurations that can prevent a newbie from being able to access their system or use its services correctly, I had a mouse, netcard, printer, runlevel, services, and xconf.

While developing the scripts for netcard, I decided it was better to extend this item into one called "network". This means you will have to modify your fixit scripts and folder tree to reflect the name change accordingly.

Networking problems can be difficult for the Linux newbie to track down and fix, as there are quite a few things that can be set up wrongly. Networking is usually harder on Linux because of the focus on security. This makes Linux a good choice in avoiding viruses, worms, and other nasty attack methods. The networking item tries to cover the basic areas where your configuration can be causing problems.

The most basic problem is the cables. Checking cat 5 cables with RJ45 plugs can be fiddly without a tester, but these can cost $50 or more. If you are handy with a soldering iron it is quite possible to make one for less than $10 using the following circuit, which consists of 8 LEDs, 8 x 62ohm resistors, a couple of RJ45 sockets, two 1.5 volt AA batteries and holder, and a case to mount them all in. The connections of one of the RJ45 sockets are all wired together, and each of the other one's are wired into one of the LED/resistor circuits.

Plugging both ends of the cable to be tested into the unit will light up the LEDs, if its wire is not broken or connected improperly to the plug. So if one or more of the LEDs don't light, you know you have a faulty cable.

Here is the circuit:

If you can't make one yourself, do what I did and get your sister to make one, or two, as she wanted one too.

OK, so the cable is OK. The next bit is the card and then all the configurations, so they can all go in a network menu like this.



#Menu to choose fixit dialog box

# $Id: menubox,v 1.4 2003/08/15 19:40:37 tom Exp $

: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/fixit$$

trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --clear --title "NETWORK FIXIT MENU" \

--menu "Use the UP/DOWN arrow keys, the first \n\

letter of the choice as a hot key, or the \n\

number keys 1-9 to choose an option.\n\n\

Choose an Item:" 20 51 4 \

"Devices" "Network Device Configuration" \

"Settings" "Network Settings Configuration" \

"Services" "Network Services Configuration" 2> $tempfile


choice=`cat $tempfile`

case $retval in

0) case $choice in

"Devices") /usr/local/FIXIT/network/bin/devview ;;

"Settings") /usr/local/FIXIT/network/bin/setview ;;

"Services") /usr/local/FIXIT/network/bin/serview ;;

*) sh /usr/local/FIXIT/bin/fixit ;;


1) sh /usr/local/FIXIT/bin/fixit ;;

255) sh /usr/local/FIXIT/bin/fixit ;;


#delete old tempfiles

rm -f /tmp/fixit* 

This menu goes in /usr/local/FIXIT/network/bin and is called from the fixit script instead of the conview script.

Here is the new fixit window:

And here is the Network window:

This is the Devices script:

#! /bin/sh


#list network configs for devices

#fixit dir


# tmp file

rm -f $FIXITN/tmp/clist.txt

#set Config file

#Insert Overview as first item

echo "Devices \"\" off \\" > $FIXITN/tmp/clist.txt

echo "lan \"\" off \\" >> $FIXITN/tmp/clist.txt

echo "modem \"\" off \\" >> $FIXITN/tmp/clist.txt

cat $FIXITN/share/dial1 $FIXITN/tmp/clist.txt $FIXITN/share/dial2 > $FIXITN/tmp/fixitl

#add the argument for the help

sh $FIXITN/tmp/fixitl "Devices"

This is the dial2 script:

2> $tempfile


choice=`cat $tempfile`

case $retval in

0) rm -f $tmpfile

sh /usr/local/FIXIT/network/bin/conf $choice ;;

1) rm -f $tmpfile

sh /usr/local/FIXIT/bin/fixit ;;

2) temptext=/usr/local/FIXIT/network/tmp/ftext$$

trap "rm -f $temptext" 0 1 2 5 15

if [ ${#choice} -gt 0 ]


HELP=`echo $choice |cut -d" " -f2`



#use the supplied argument for the help file



test -f $TEXT

cat $TEXT | expand >> $temptext

rm -f $tmpfile

$DIALOG --keep-window --title "HELP MESSAGE" --textbox "$temptext" 22 77

case $? in

0) rm -f $temptext

sh /usr/local/FIXIT/network/tmp/fixitl ;;

255) rm -f $temptext

sh /usr/local/FIXIT/network/tmp/fixitl ;;

esac ;;

3) if [ ${#choice} -gt 0 ]


rm -f $tmpfile

MODULE=`echo $choice |cut -d" " -f2`

yast $MODULE

sh /usr/local/FIXIT/network/tmp/fixitl

fi ;;

255) rm -f $tmpfile

sh /usr/local/FIXIT/network/bin/netmenu ;;


Here is the window:

As you can see this is repeating the scripts we have already developed. The targets and paths are changed to reflect each item's needs.

The network/bin/conf file takes the argument $choice and uses this to decide which case procedures to perform and puts the result into network/tmp/conflist.txt ready to be displayed by network/bin/textbox.


#Show text and return to section list

#fixit dir


rm -f $FIXITN/tmp/conflist.txt


#What module is called

case $1 in

"lan") #cat the ifcfg-* files

#Use the file name as a header to split them up

#The brackets run both commands inside a sub shell, and then return to the calling shell

#This prevents the "cd" command from affecting the calling shell

FLIST=`(cd $SYSCON/network;ls ifcfg-*)`

for F in $FLIST


echo "Config for $F" >> $FIXITN/tmp/conflist.txt

cat $SYSCON/network/$F >> $FIXITN/tmp/conflist.txt

echo " " >> $FIXITN/tmp/conflist.txt

done ;;

"modem") #cat the wvdial.conf files

cat /etc/wvdial.conf > $FIXITN/tmp/conflist.txt ;;

"host") #cat /etc/hosts

cat /etc/hosts > $FIXITN/tmp/conflist.txt ;;

"proxy") #cat the sysconfig proxy

cat $SYSCON/proxy > $FIXITN/tmp/conflist.txt ;;

"routing") #cat the sysconfig routes

cat $SYSCON/network/routes > $FIXITN/tmp/conflist.txt ;;

"nfs") #cat /etc/exports

cat /etc/exports > $FIXITN/tmp/conflist.txt ;;

"nfs-server") #cat sysconfig nfs

cat $SYSCON/nfs > $FIXITN/tmp/conflist.txt ;;

"samba-server") #cat /etc/samba/smb.conf

cat /etc/samba/smb.conf > $FIXITN/tmp/conflist.txt ;;

"firewall") #use iptables -L

iptables -L > $FIXITN/tmp/conflist.txt ;;

"Devices") echo "Choose a item from the list" $FIXITN/tmp/conflist.txt ;;

"Settings") echo "Choose a item from the list" $FIXITN/tmp/conflist.txt ;;

"Services") echo "Choose a item from the list" $FIXITN/tmp/conflist.txt ;;


#Show the config

sh $FIXITN/bin/textbox

#Return to the config list

sh $FIXITN/tmp/fixitl

This file works for all cases of $choice in networking rather than having to create a separate one for each sub menu.

It also shows you where and how the configurations are accessed in SUSE as a bonus.

In the previous parts of this article I showed you where to find meaningful help texts, which need to be created for each choice item and put into network/share/doc.

Notice that the menu names which get put into choice are also the names YAST uses for calling its modules, so that the relevant YAST configuration is displayed.

These are the scripts for the "services", "settings", and "textbox":

#! /bin/sh


#list network configs for services

#fixit dir


# tmp file

rm -f $FIXITN/tmp/clist.txt

#set Config file

#Insert Overview as first item

echo "Services \"\" off \\" > $FIXITN/tmp/clist.txt

echo "nfs \"\" off \\" >> $FIXITN/tmp/clist.txt

echo "nfs-server \"\" off \\" >> $FIXITN/tmp/clist.txt

echo "samba-server \"\" off \\" >> $FIXITN/tmp/clist.txt

echo "firewall \"\" off \\" >> $FIXITN/tmp/clist.txt

cat $FIXITN/share/dial1 $FIXITN/tmp/clist.txt $FIXITN/share/dial2 > $FIXITN/tmp/fixitl

#add the argument for the help

sh $FIXITN/tmp/fixitl "Services"

Here is a picture of the services menu:

And the rest of the scripts:

#! /bin/sh


#list network configs for settings

#fixit dir


# tmp file

rm -f $FIXITN/tmp/clist.txt

#set Config file

#Insert Overview as first item

echo "Settings \"\" off \\" > $FIXITN/tmp/clist.txt

echo "host \"\" off \\" >> $FIXITN/tmp/clist.txt

echo "proxy \"\" off \\" >> $FIXITN/tmp/clist.txt

echo "routing \"\" off \\" >> $FIXITN/tmp/clist.txt

cat $FIXITN/share/dial1 $FIXITN/tmp/clist.txt $FIXITN/share/dial2 > $FIXITN/tmp/fixitl

#add the argument for the help

sh $FIXITN/tmp/fixitl "Settings"

# $Id: textbox,v 1.6 2003/08/15 19:40:37 tom Exp $

: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$

trap "rm -f $tempfile" 0 1 2 5 15


test -f $TEXT

cat $TEXT | expand >> $tempfile

$DIALOG --clear --title "CONFIG MESSAGE" --textbox "$tempfile" 22 77

case $? in

0) : ;;

255) : ;;


Probably the hardest network item for anyone, including moi, is routing, so I shall write a separate article on simplified routing configurations for an Ethernet and wireless lan network I am setting up at home, to give you some hopefully simple ideas. The main problems with routing for us newbies is understanding what the terms mean, and how the routes are configured at each end of a LAN connection.

This is all I'm going to show you about the fixit system as the rest of the items are very straight forward, being repetitions of scripts that you've already learned and developed with a few path and name changes. The beauty of this system is that you don't need the GUI to be able to use it, (although you can use it in a GUI terminal window), yet it gives a similar point and click operation, allowing newbies to administer their own computers and networks with a minimum of stress. It is also extensible so that it can be easily modified to include other areas that may need to be configured. Finally, it makes a good teaching aid for basic Linux configuration and administration.

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates