Next Previous Contents

6. Auxiliary config commands.

Some system files require special configuration operations beyond the simple installation of system files. For example, after updating the printcap file one should restart the lpd daemon. Another special case is the crontab configuration: there is no crontab file as such, the current configuration is obtained by executing the command crontab -l. The output of the command must thus be stored into a temporary file to perform the sysf operation.

To achieve this, it is possible to force sysf to execute an auxiliary command. The command's name is the config name and the executable file, usually a script file, must be in the BIN sub-directory of the config directory. The auxiliary command is executed only if a special flag is set in the sysf.conf file (except for the -uninstall command).

The auxiliary commands make it possible for an administrator to get sysf to execute some configuration commands. An administrator can write his own auxiliary commands and get it to do anything that is required. The command executed is always the command named after the config name and located in the BIN sub-directory of the config dir. The auxiliary command is always called with 5 arguments:

    AUX_COM ACTION COM SYSTEM_FILE CONFIG_FILE ECHO_ON

The sysf flags listed in the sysf.conf govern when the auxiliary command is executed by sysf and which argument are passed to the command.

The argument passed to the auxiliary command correspond to the following:

Argument 1 : ACTION The first argument corresponds to the action to be performed. The valid names are listed below and the letter between brackets is the flag that must be set in the sysf.conf file for the auxiliary command to be executed.

Argument 2 : COM : the sysf command name. This can be tested to tailor some operations for some sysf commands. For example the -CreateSysFile can be used to display extra information (like the existence of some symbolic links in /etc/rc.d/rcN.d) when the info command is executed.

Argument 3 : SYSFILE_NAME : the full path name of the system file. When the system file does not really exist (like the crontab file) this is the file that must be created so that sysf can compare the config file and the system file.

Argument 4 : CONFIG_FILE: the full config file path name. This can be used to create the system file (as for crontab file).

Argument 5 : ECHO_ON: this is set to either "on" or "off" to specify if echo is on or not. One should check this and display some information about what is being done when echo is on.

Notice also that the config name can be extracted from the command name variable as the last name of the path (using $0:t under the csh shell).

Here follow some examples of auxiliary command files.

6.1 Auxiliary config command for the rc files.

On some versions of Unix/Linux (like Red Hat) the rc files need to be treated separately as the startup script files are symbolic links to files stored in a different directory. For example the xdm daemon can be started by the script file /etc/rc.d/rc3.d/S91xdm which is a symbolic link to the file /etc/rc.d/init.d/xdm. The system file will thus be /etc/rc.d/init.d/xdm and the xdm auxiliary command will create the symbolic link.

In the following example, the -UpdateSysFile action creates the symbolic links if they do not exist. The -CreateSysFile action reveals if the symbolic link exists or not when the info command is executed. The -Remove action removes the symbolic links when the uninstall command is executed.

The BIN/xdm script file:

#!/bin/csh 
set ACTION = $1
set COM = $2
set SYSFILE_NAME = $3
set CONFIG_FILE = $4
set ECHO_ON = $5

set INITD_PATH = "/etc/rc.d/init.d"
set RC2_PATH = "/etc/rc.d/rc2.d"
set RC3_PATH = "/etc/rc.d/rc3.d"
set RC_LIST = "$RC3_PATH"
set NAME =   "xdm"
set S_NAME = "S91xdm"
set K_NAME = "K91xdm"

switch( $ACTION )
 case "-CreateSysFile" :
     #    if command is info : check that the symbolic link exists
     if ( "$COM" == "info" ) then
       foreach p ( $RC_LIST)
         if ( -f $p/$S_NAME ) then
            echo " xdm is on in $p"
         else
            echo " xdm is off in $p"
         endif    
       end
     endif
     breaksw;
 case "-UpdateSysFile" :
     # create the symbolic link to the init.d command
     foreach p ( $RC_LIST)
       if ( ! -f $p/$S_NAME ) then
          if ( "$ECHO_ON" == "on" ) then
            echo "Creating $p/$S_NAME"
          endif
          ln -s $INITD_PATH/$NAME $p/$S_NAME
       endif
     end
     breaksw;
 case "-PreInstall"  :
     breaksw;
 case "-PostInstall" :
     breaksw;
 case "-Remove" :
     # remove the symbolic link from the RC directories
     foreach p ( $RC_LIST)
       if ( -f $p/$S_NAME ) then
          if ( "$ECHO_ON" == "on" ) then
            echo "Removing $p/$S_NAME"
          endif
          rm -f $p/$S_NAME
       endif
     end
     breaksw;
 default :
     echo "Unknown ACTION $ACTION"
     breaksw;
endsw

6.2 Auxiliary config command for the NIS files.

Despite the fact that NIS provides a similar functionality to sysf it is worth creating sysf entry for all the NIS files, if only to have a backup copy of the files.

There is nothing special about the NIS files except that when the sysf install, first_install or OS_install commands are executed on the master NIS server, the NIS maps must be updated by running make in the /var/yp directory. This will be done by the auxiliary command when the action is -UpdateSysFile.

The sysf.conf entries will look like this:

    aliases      =  nis   /etc/mail/alias   alias        C;
    bootparams   =  nis   /etc/bootparams   bootparams   C;
    ethers       =  nis   /etc/ethers       ethers       C;
    group        =  nis   /etc/group        group        C;
    hosts        =  nis   /etc/hosts        hosts        C;
    netgroup     =  nis   /etc/netgroup     netgroup     C;
    netmasks     =  nis   /etc/netmasks     netmasks     C;
    networks     =  nis   /etc/networks     networks     C;
    protocols    =  nis   /etc/protocols    protocols    C; 
    publickey    =  nis   /etc/publickey    publickey    C;
    rpc          =  nis   /etc/rpc          rpc          C;
    services     =  nis   /etc/services     services     C;
    timezone     =  nis   /etc/timezone     timezone     C;
    ypservers    =  nis   /var/yp/ypservers ypservers    C;

The same script file can be used for every NIS file, so we will create the file NIS in the BIN directory and create symbolic links to it named after every NIS files.

The BIN/NIS script file:

#!/bin/csh
set ACTION = $1
set COM = $2
set SYSFILE_NAME = $3
set CONFIG_FILE = $4
set ECHO_ON = $5
set NIS_SERVER = my_serv

switch( $ACTION )
 case "-CreateSysFile" : breaksw;
 case "-UpdateSysFile" :
     breaksw;
 case "-PreInstall" :
     breaksw;
 case "-PostInstall" :
     if (`uname -n` == $NIS_SERVER) then
       (cd /var/yp; make)
     endif
     breaksw;
 case "-Remove" :
     breaksw;
 default :
     echo "Unknown ACTION " $1
     breaksw;
endsw

6.3 Auxiliary config command for the crontab file.

As there is no crontab system file as such, one must create a temporary one using crontab -l. The entry in the sysf.conf file will look like this

    crontab        =  cron   /tmp/crontab.list     crontab        C;
and the crontab auxiliary command will create the temporary system file when called with the action -CreateSysFile and will update the crontab entry when called with the action -UpdateSysFile.

The BIN/crontab script file:

#!/bin/csh
set ACTION = $1
set COM = $2
set SYSFILE_NAME = $3
set CONFIG_FILE = $4
set ECHO_ON = $5

switch( $ACTION )
 case "-CreateSysFile" :
     crontab -l >! $SYSFILE_NAME
     breaksw;
 case "-UpdateSysFile" :
     crontab $SYSFILE_NAME
     breaksw;
 case "-PreInstall" :
     breaksw;
 case "-PostInstall" :
     breaksw;
 case "-Remove" :
     breaksw;
 default :
     echo "Unknown ACTION " $1
     breaksw;
endsw

6.4 Auxiliary config command for the printcap file.

After modifying the printcap file, one must restart the lpd daemon. This can be done by setting the flag I in the printcap entry in the sysf.conf file and using the lpd startup script file in the auxiliary command when the action is -PostInstall.

The BIN/printcap script file:

#!/bin/csh 
set ACTION = $1
set COM = $2
set SYSFILE_NAME = $3
set CONFIG_FILE = $4
set ECHO_ON = $5
set LPD = /etc/rc.d/init.d/lpd

switch( $ACTION )
 case "-CreateSysFile" : 
      breaksw;
 case "-UpdateSysFile" : 
      breaksw;
 case "-PreInstall" : 
      breaksw;
 case "-PostInstall" : 
      # restart the lpd daemon 
      $LPD restart
      breaksw;
 case "-Remove" : 
       breaksw;
 default :
     echo "Unknown ACTION " $1
     breaksw;
endsw

6.5 Auxiliary config command for the rpm file.

Red Hat and other versions of Linux use packages to install software. The list of installed software is stored in the rpm database and it can be extracted using the rpm command. To be able to check if new packages have been installed or compare different hosts, one can define the following sysf entry in sysf.conf:

    rpm.list     =  extra   /tmp/rpm.list           rpm.list        C;
As such there is no system file for rpm.list so we create it as the temporary file /tmp/rpm.list using the -CreateSysFile action in the auxiliary config command. Sysf can be used to check if new packages have been added on a system or compare the package lists on different hosts. Notice that the sysf -install command does not do anything useful in this case.

The following script file creates the file /tmp/rpm.list when required.

The BIN/rpm.list script file:

#!/bin/csh 
set ACTION = $1
set COM = $2
set SYSFILE_NAME = $3
set CONFIG_FILE = $4
set ECHO_ON = $5

switch( $ACTION )
 case "-CreateSysFile" :
     if ( $ECHO_ON == "on" ) then
        echo "Creating $SYSFILE_NAME"
     endif
     /bin/rpm -q -a >! $SYSFILE_NAME
     breaksw;
 case "-UpdateSysFile" :
      breaksw;
 case "-PreInstall" :
      breaksw;
 case "-PostInstall" :
      breaksw;
 case "-Remove" :
      breaksw;
 default :
     echo "Unknown ACTION " $1
     breaksw;
endsw


Next Previous Contents