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

set INITD_PATH = "/etc/rc.d/init.d"
set RC0_PATH = "/etc/rc.d/rc0.d"
set RC2_PATH = "/etc/rc.d/rc2.d"
set RC3_PATH = "/etc/rc.d/rc3.d"
set RC6_PATH = "/etc/rc.d/rc6.d"
set RC_LIST = "$RC2_PATH $RC3_PATH"
set RC_K_LIST = ""
set NAME =   "mailboot"
set S_NAME = "S99mailboot"
set K_NAME = "K99mailboot"

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 " mailboot is on in $p"
         else
            echo " mailboot is off in $p"
         endif    
       end
       foreach p ( $RC_K_LIST)
         if ( -f $p/$K_NAME ) then
            echo " mailboot is on in $p"
         else
            echo " mailboot 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
     foreach p ( $RC_K_LIST)
       if ( ! -f $p/$K_NAME ) then
          if ( "$ECHO_ON" == "on" ) then
            echo "Creating $p/$K_NAME"
          endif
          ln -s $INITD_PATH/$NAME $p/$K_NAME
       endif
     end
     breaksw;
 case "-PreInstall" :
#    nothing to do here.
     breaksw;
 case "-PostInstall" :
#    nothing to do here.
     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
     foreach p ( $RC_K_LIST)
       if ( -f $p/$K_NAME ) then
          if ( "$ECHO_ON" == "on" ) then
            echo "Removing $p/$K_NAME"
          endif
          rm -f $p/$K_NAME
       endif
     end
     breaksw;
 default :
     echo "Unknown ACTION $ACTION"
     breaksw;
endsw
