home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / nsu / install / postinstall < prev    next >
Text File  |  1998-08-19  |  21KB  |  905 lines

  1. #ident    "@(#)postinstall    1.3"
  2. #ident    "$Header: $"
  3.  
  4. PKGMSG=${PKGINST}.pkg
  5. LOCALE=${LC_ALL:-${LC_MESSAGES:-${LANG:-"C"}}}
  6. HOW_INSTALL=NORMAL
  7. # We are installing from the boot floppy if
  8. # the script /etc/inst/scripts/postreboot.sh exists
  9. [ -f /etc/inst/scripts/postreboot.sh ] && {
  10.         HOW_INSTALL=ON_BFLOP
  11. }
  12.  
  13. if [ ! -f /usr/lib/locale/${LOCALE}/LC_MESSAGES/${PKGMSG} ]
  14. then
  15.    if [ -f ${REQDIR}/inst/locale/${LOCALE}/${PKGMSG} -a \
  16.     -d /usr/lib/locale/${LOCALE}/LC_MESSAGES ]
  17.    then
  18.     cp ${REQDIR}/inst/locale/${LOCALE}/${PKGMSG} \
  19.        /usr/lib/locale/${LOCALE}/LC_MESSAGES
  20.    fi
  21. fi
  22. SCRIPTS=/usr/sbin/pkginst
  23. . ${SCRIPTS}/updebug
  24.  
  25. [ "$UPDEBUG" = YES ] && {
  26.     set -x
  27.     goany
  28. }
  29.  
  30. error() {
  31.     [ "$UPDEBUG" = YES ] && set -x
  32.     errflag=1
  33.     case $1 in
  34.     1)
  35.         pfmt -s error -g ${PKGMSG}:1 " drvinstall on %s failed\n" $2 2>&1
  36.         ;;
  37.     2)
  38.         pfmt -s error -g ${PKGMSG}:2 " could not create %s\n" $2 2>&1
  39.         ;;
  40.     3)
  41.         pfmt -s error -g ${PKGMSG}:3 " could not create pseudo-terminal slave devices\n" 2>&1
  42.         ;;
  43.     4)
  44.         pfmt -s error -g ${PKGMSG}:4 " copy failed\n" 2>&1
  45.         ;;
  46.     5)
  47.         # message put out elsewhere
  48.         ;;
  49.     6)
  50.         pfmt -s error -g ${PKGMSG}:5 " installation error\n" 2>&1
  51.         ;;
  52.     7)
  53.         pfmt -s error -g ${PKGMSG}:6 " mkboot on KERNEL failed\n" 2>&1
  54.         ;;
  55.     *)
  56.         pfmt -s error -g ${PKGMSG}:7 " undefined error\n" 2>&1
  57.         ;;
  58.     esac
  59. }
  60.  
  61. # install a module.  $1 is the module name
  62.  
  63. do_install() {
  64.     [ "$UPDEBUG" = YES ] && set -x
  65.     ERR=/tmp/${1}.err
  66.     IDCOMPS="Driver.o Driver_atup.o Driver_mp.o Master System Mfsys Sfsys Rc Node Space.c Mtune Dtune"
  67.  
  68.     if [ -f ${1}.Dr ]; then mv ${1}.Dr Driver.o; fi
  69.     if [ -f ${1}_atup.Dr ]; then mv ${1}_atup.Dr Driver_atup.o; fi
  70.     if [ -f ${1}_mp.Dr ]; then mv ${1}_mp.Dr Driver_mp.o; fi
  71.  
  72.     if
  73.         [ -f ${1}.Sp ]
  74.     then
  75.         mv ${1}.Sp Space.c
  76.     fi
  77.     if
  78.         [ -f ${1}.Ma ]
  79.     then
  80.         grep -v "^[\*#]ident" ${1}.Ma > Master
  81.         rm -rf ${1}.Ma
  82.     fi
  83.     if
  84.         [ -f ${1}.Sy ]
  85.     then
  86.         grep -v "^[\*#]ident" ${1}.Sy |
  87.             sed "${SEDCMD1}"  > System
  88.         rm -rf ${1}.Sy
  89.     fi
  90.     if
  91.         [ -f ${1}.Mf ]
  92.     then
  93.         grep -v "^[\*#]ident" ${1}.Mf > Mfsys
  94.         rm -rf ${1}.Mf
  95.     fi
  96.     if
  97.         [ -f ${1}.Sf ]
  98.     then
  99.         grep -v "^[\*#]ident" ${1}.Sf |
  100.             sed "${SEDCMD2}" > Sfsys
  101.         rm -rf ${1}.Sf
  102.     fi
  103.     if
  104.         [ -f ${1}.No ]
  105.     then
  106.         grep -v "^[\*#]ident" ${1}.No > Node
  107.         rm -rf ${1}.No
  108.     fi
  109.     if
  110.         [ -f ${1}.Rc ]
  111.     then
  112.         grep -v "^[\*#]ident" ${1}.Rc > Rc
  113.         rm -rf ${1}.Rc
  114.     fi
  115.     if
  116.         [ -f ${1}.Mt ]
  117.     then
  118.         grep -v "^[\*#]ident" ${1}.Mt > Mtune
  119.         rm -rf ${1}.Mtune
  120.     fi
  121.     if
  122.         [ -f ${1}.Dt ]
  123.     then
  124.         grep -v "^[\*#]ident" ${1}.Dt > Dtune
  125.         rm -rf ${1}.Dtune
  126.     fi
  127.     ${CONFBIN}/idcheck -p ${1} > ${ERR} 2>&1
  128.     ret=$?
  129.     if [ ${ret} = 0 ] || [ ${ret} = 8 ]
  130.     then
  131.         ${CONFBIN}/idinstall -P ${PKGINST} -a ${1} > ${ERR} 2>&1
  132.         ret=$?
  133.     else
  134.         ${CONFBIN}/idinstall -P ${PKGINST} -u ${1} > ${ERR} 2>&1
  135.         ret=$?
  136.     fi
  137.     rm -rf ${IDCOMPS}
  138.     if [ ${ret} != 0 ]
  139.     then
  140.         message -d `pfmt -s nostd -g ${PKGMSG}:8 "The installation cannot be completed due to an error in the driver installation during the installation of the %s module of the %s.  The file %s contains the errors." ${1} ${NAME} ${ERR} 2>&1`
  141.             exit ${FAILURE}
  142.     fi
  143.     rm -rf ${ERR}
  144. }
  145.  
  146.  
  147. # main()
  148.  
  149.  
  150. UPINSTALL=/etc/conf.sav
  151. UPGRADE_STORE=/etc/inst/save.user
  152. UPGFILE=$UPGRADE_STORE/${PKGINST}.env
  153.  
  154. # If $UPGFILE exists, dot it in. This is where NREG always is
  155. # whether or not the request script was run.
  156. [ -f $UPGFILE ] && . $UPGFILE
  157.  
  158. FAILURE=1    # fatal error
  159.  
  160. CONFDIR=/etc/conf
  161. CONFBIN=${CONFDIR}/bin
  162.  
  163. NOTOOLS=`pfmt -s error -g ${PKGMSG}:15 " The Installable Driver feature has been removed. The %s cannot be installed." ${NAME} 2>&1`
  164.  
  165. SEDCMD1="s/[     ]N[     ]/    Y    /"
  166. SEDCMD2="s/[     ]N/    Y/"
  167.  
  168. cd /var/sadm/pkg/${PKG}/install
  169.  
  170. errflag=0
  171.  
  172.  
  173. # determine that ID/TP tools are available
  174.  
  175. if
  176.     [ ! -x ${CONFBIN}/idbuild -o ! -x ${CONFBIN}/idinstall \
  177.         -o ! -x ${CONFBIN}/idcheck ]
  178. then
  179.     message -d ${NOTOOLS}
  180.     exit $FAILURE
  181. fi
  182.  
  183. #
  184. #    need allprivs on rc2 for network startup (cannot use filepriv)
  185.  
  186. installf $PKGINST /sbin/rc2 f \? \? \? 2 NULL allprivs
  187.  
  188. if pkginfo -i es >/dev/null 2>&1
  189. then
  190.     USR_PUTDEV="range=SYS_RANGE_MAX-SYS_RANGE_MIN state=pub_priv
  191.         mode=static ual_enable=y other=>y startup=y
  192.         startup_level=USER_LOGIN startup_owner=root>rw-
  193.         startup_group=other>rw- startup_other=>rw-"
  194. else
  195.     USR_PUTDEV=""
  196. fi
  197. export USR_PUTDEV
  198.  
  199. VOLATILES=`echo /tmp/nsu/*`
  200. cd /tmp/nsu
  201. # install drivers/modules
  202.  
  203. for MODULE in timod tirdwr pckt ntty net md5
  204. do
  205.     do_install ${MODULE}
  206. done
  207. ${CONFBIN}/idbuild -M timod -M tirdwr -M pckt -M ntty -M net -M md5
  208. for i in ptm ptem pts
  209. do
  210.     if [ -f "${i}.Sy" ]
  211.     then
  212.         line=`grep "^$i[     ]" $i.Sy 2>/dev/null`
  213.         set - $line
  214.         DEFAULT=$3
  215.         if [ "$DEFAULT" -ne "$NREG" ]
  216.         then
  217.             ed - $i.Sy 1>/dev/null 2>&1 <<-!
  218.                 /^$i[     ]/
  219.                 s/$DEFAULT/$NREG/
  220.                 .
  221.                 w
  222.             !
  223.         fi
  224.     fi
  225. done
  226.  
  227. # The pseudo-tty tuneables in ptm mtune file will be customized 
  228. # for the number of licensed users.  The default setup is
  229. # for 10 and UNLIMITED users (AS) so we only have to change it 
  230. # if only 2 users (PE) are licensed.
  231. NUM_USERS=`keyadm -g USERS|cut -f1`
  232. if [ "$NUM_USERS" = "2" ]
  233. then
  234.     sed -e "/^NUMREGPT/s//#AS NUMREGPT/" \
  235.         -e "/^NUMSCOPT/s//#AS NUMSCOPT/" \
  236.         -e "/^#PE /s///" ptm.Mt >ptm.Mt.$$
  237.     cp ptm.Mt.$$ ptm.Mt
  238. fi
  239.  
  240. # The following is done only if the number of regular pseudo-ttys, NREG > 0
  241.  
  242.  
  243. if
  244.     [ "$NREG" -gt 0 ]
  245. then
  246.  
  247.     # add /dev/ptmx as major(clone), minor(ptm)
  248.  
  249.     echo "clone    ptmx    c    ptm" > /tmp/nsu/ptm.No
  250.  
  251.     # (re-)configure pseudo-terminal master device
  252.  
  253.     installf ${PKGINST} /dev/pts d 755 root root 4 NULL NULL || error 2 /dev/pts
  254.     /sbin/putdev -a pseudo_master cdevlist=/dev/ptmx \
  255.         desc="pseudo terminal master" $USR_PUTDEV >/dev/null 2>&1
  256.  
  257.     TEMP=0
  258.     until
  259.         [ "$TEMP" -eq "$NREG" ]
  260.     do
  261.         echo "pts    pts/${TEMP}    c    ${TEMP}" >> /tmp/nsu/pts.No
  262.         TEMP=`expr $TEMP + 1`
  263.     done
  264.  
  265.     > /tmp/nsu/pts.Rc
  266.     echo "if [ -c /dev/pts000 ]" >> /tmp/nsu/pts.Rc
  267.     echo "then" >> /tmp/nsu/pts.Rc
  268.     echo "exit" >> /tmp/nsu/pts.Rc
  269.     echo "fi" >> /tmp/nsu/pts.Rc
  270.     echo "cd /dev/pts" >> /tmp/nsu/pts.Rc
  271.     echo "for i in *" >> /tmp/nsu/pts.Rc
  272.     echo "do" >> /tmp/nsu/pts.Rc
  273.     STRING="NUM=\`echo \$i | awk '{printf(\"%.3d\",\$1)}'\`"
  274.     echo "$STRING" >> /tmp/nsu/pts.Rc
  275.     echo "ln \$i /dev/pts\${NUM} >> /dev/null 2>&1" >> /tmp/nsu/pts.Rc
  276.     echo "done" >> /tmp/nsu/pts.Rc
  277.  
  278.  
  279.     for MODULE in ptm ptem pts
  280.     do
  281.         do_install ${MODULE}
  282.     done
  283.     ${CONFBIN}/idbuild -M ptm -M ptem -M pts
  284.  
  285.     # 
  286.     # edit the just installed mtune values for PTM.
  287.     #
  288.     # create temporary /etc/conf/cf.d/mtune; it's blown away
  289.     # below after we're done playing w/the tuneables....
  290.     # do not clobber mtune if it exists already
  291.     MTUNEORG=/usr/tmp/mtune.$$
  292.     if [ -f /etc/conf/cf.d/mtune ]
  293.     then
  294.             cp /etc/conf/cf.d/mtune $MTUNEORG
  295.             cat /etc/conf/mtune.d/* >> /etc/conf/cf.d/mtune
  296.     else
  297.             cat /etc/conf/mtune.d/* > /etc/conf/cf.d/mtune
  298.     fi
  299.  
  300.     ${CONFBIN}/idtune -f NUMREGPT ${NREG}
  301.     
  302.         # if mtune existed restore it, else remove temp /etc/conf/cf.d/mtune
  303.         if [ -f $MTUNEORG ]
  304.         then
  305.                 cp $MTUNEORG /etc/conf/cf.d/mtune
  306.                 rm -f $MTUNEORG
  307.         else
  308.                 rm -f /etc/conf/cf.d/mtune 2>/dev/null 1>/dev/null
  309.         fi
  310.  
  311.     
  312. fi
  313.  
  314. #
  315. # Just in case NSU was removed and reinstalled while ACP is still in
  316. # and we have changed the # of pseudo terms, we install SCO again
  317. # so that the range willbe right after the new pseudo terms. The
  318. # scipt is written in such a way that in the most likely case of 
  319. # where this is being installed well in advance of ACP the script will
  320. # do nothing
  321. #
  322. #
  323. # create temporary /etc/conf/cf.d/mtune; it's blown away
  324. # below after we're done playing w/the tuneables....
  325. # do not clobber mtune if it exists already
  326. MTUNEORG=/usr/tmp/mtune.$$
  327. if [ -f /etc/conf/cf.d/mtune ]
  328. then
  329.            cp /etc/conf/cf.d/mtune $MTUNEORG
  330.            cat /etc/conf/mtune.d/* >> /etc/conf/cf.d/mtune
  331. else
  332.            cat /etc/conf/mtune.d/* > /etc/conf/cf.d/mtune
  333. fi
  334.  
  335. if [ "$PKGINSTALL_TYPE" != NEWINSTALL ]
  336. then
  337.     set `${CONFBIN}/idtune -g NUMSCOPT`
  338.     /sbin/sh /var/sadm/pkg/nsu/install/sco_pt.install $1
  339. else
  340.     /sbin/sh /var/sadm/pkg/nsu/install/sco_pt.install -1
  341. fi
  342.  
  343. # if mtune existed restore it, else remove temp /etc/conf/cf.d/mtune
  344. if [ -f $MTUNEORG ]
  345. then
  346.         cp $MTUNEORG /etc/conf/cf.d/mtune
  347.         rm -f $MTUNEORG
  348. else
  349.         rm -f /etc/conf/cf.d/mtune 2>/dev/null 1>/dev/null
  350. fi
  351.  
  352.  
  353. #    configure loopback transport providers
  354.  
  355. for MODULE in ticlts ticots ticotsor
  356. do
  357.     do_install ${MODULE}
  358. done
  359. ${CONFBIN}/idbuild -M ticlts -M ticots -M ticotsor
  360.  
  361.  
  362. #
  363. #The following defines the roles for the TFM database.
  364. #
  365.  
  366. #
  367. #The following while-loop reads the commands and the roles
  368. #to which these commands are to be assigned.  If privileges, 
  369. #separated by a colon, appear next to the role in the script that 
  370. #this while-loop reads in, it means that those privileges are to
  371. #be shutoff for that command when it is assigned to the role.
  372. #
  373.  
  374. # create the NET role; if it is already there, ignore error
  375. /usr/bin/adminrole -n NET > /dev/null 2>&1
  376.  
  377. while read cmd roles
  378. do
  379.     echo $cmd | egrep "^#" > /dev/null 2>&1 && continue    # Skip comments
  380.     base=`basename $cmd`
  381.     privs=`
  382.     egrep ":${cmd}$" /etc/security/tcb/privs|    # Find command in tcb database
  383.     sed 's/^.*%inher,\(.*\):.*/\1/p' |          # get the set of inher privs
  384.     sed 's/^.*%fixed,\(.*\):.*//p' |            # delete the fixed privs
  385.     sed 's/,/:/gp'                              # changed ,'s to :'s
  386.     `
  387.     if [ -z "$privs" ]
  388.     then
  389.     echo $cmd $roles >> /tmp/rolelist
  390.     continue
  391.     else
  392.         prvd="yes"
  393.     fi
  394.     set $roles
  395.     save="$privs"
  396.     while [ $# -gt 0 ]
  397.     do
  398.         role=$1
  399.         if echo "$1" | grep ":" > /dev/null
  400.         then
  401.             role=`
  402.             echo "$1" | sed 's/:.*$//p'`
  403.             if [ "$prvd" = "yes" ]
  404.             then
  405.                 shutoff=`
  406.                 echo "$1" | sed 's/^[A-Z]*://p'`
  407.                 shutoff=`echo "$shutoff"|sed 's/:/ /gp'`
  408.                 fullset=`echo "$save"|sed 's/:/ /gp'`
  409.                 for i in $shutoff    #check if privileges to be shut off
  410.                 do                    #are in full set of privilges
  411.                     found="false"
  412.                     for j in $fullset
  413.                     do
  414.                         if [ "$i" = "$j" ]
  415.                         then
  416.                             found="true"
  417.                             break
  418.                         fi
  419.                     done
  420.                     privs=""
  421.                     if [ "$found" = "false" ]
  422.                     then
  423.                         pfmt -s warn -g ${PKGMSG}:16 " %s privilege specified to be shut off for %s,\n         but it is NOT in its set of privileges." $i $cmd
  424.                         break
  425.                     fi
  426.                 done
  427.                 if [ -z "$shutoff" ]
  428.                 then
  429.                     privs="$save"
  430.                 else
  431.                     for i in $fullset
  432.                     do
  433.                         found="false"
  434.                         for j in $shutoff
  435.                         do
  436.                             if [ "$i" = "$j" ]
  437.                             then
  438.                                 found="true"
  439.                                 break
  440.                             fi
  441.                         done
  442.                         if [ "$found" = "false" ]
  443.                         then
  444.                             if [ -z "$privs" ]
  445.                             then
  446.                                 privs=$i
  447.                             else
  448.                                 privs=$privs:$i
  449.                             fi
  450.                         fi
  451.                     done
  452.                 fi
  453.             fi
  454.         else
  455.             privs="$save"
  456.         fi
  457.         if [ -z "$privs" ]
  458.         then
  459.             adminrole -a $base:$cmd $role > /dev/null 2>&1
  460.         else
  461.             adminrole -a $base:$cmd:$privs $role > /dev/null 2>&1
  462.         fi
  463.         shift
  464.     done
  465. done <<!
  466. /usr/bin/cat        NET
  467. /usr/bin/cp        NET:owner:compat:fsysrange:filesys
  468. /usr/lib/saf/dbfconv    NET
  469. /usr/sbin/idadmin    NET
  470. /usr/sbin/keymaster    NET
  471. /usr/sbin/nlsadmin    NET
  472. /usr/sbin/pmadm        NET
  473. /usr/sbin/rxservice    NET
  474. /usr/sbin/sacadm    NET
  475. !
  476.  
  477. ############# Begin UPGRADE AND OVERLAY #######################
  478.  
  479. [ "$AUTOMERGE" = "No" ] && rm -f $BASEDIR/etc/netconfig
  480.  
  481. ############# End UPGRADE AND OVERLAY #######################
  482.  
  483. if [ ! -s $BASEDIR/etc/netconfig ]
  484. then
  485.     echo "#
  486. #    The Network Configuration File.
  487. #
  488. # Each entry is of the form:
  489. #
  490. # network_id semantics flags protofamily protoname device nametoaddr_libs
  491. #" >$BASEDIR/etc/netconfig
  492. fi
  493.  
  494. if grep '[     ]loopback[     ][     ]*-[     ][     ]*/dev/ticlts[     ]' $BASEDIR/etc/netconfig >/dev/null 2>&1
  495. then
  496.     : Already there!
  497. else
  498.     echo "ticlts       tpi_clts      v    loopback    -    /dev/ticlts    /usr/lib/straddr.so" >>$BASEDIR/etc/netconfig
  499. fi
  500.  
  501. if grep '[     ]loopback[     ][     ]*-[     ][     ]*/dev/ticots[     ]' $BASEDIR/etc/netconfig >/dev/null 2>&1
  502. then
  503.     : Already there!
  504. else
  505.     echo "ticots       tpi_cots      v    loopback    -    /dev/ticots    /usr/lib/straddr.so" >>$BASEDIR/etc/netconfig
  506. fi
  507.  
  508. if grep '[     ]loopback[     ][     ]*-[     ][     ]*/dev/ticotsord[     ]' $BASEDIR/etc/netconfig >/dev/null 2>&1
  509. then
  510.     : Already there!
  511. else
  512.     echo "ticotsord  tpi_cots_ord      v    loopback    -    /dev/ticotsord    /usr/lib/straddr.so" >>$BASEDIR/etc/netconfig
  513. fi
  514.  
  515. # WARNING: This and all other packages using the netconfig file
  516. #    installf specifies a separate class, volatile, and 1 (i.e. SYS_PUBLIC)
  517. installf -c nsunetcnfg $PKGINST $BASEDIR/etc/netconfig \
  518.      v 0644 root other 1 NULL NULL
  519. #
  520. # put in device database entries for ticots, ticlts ticotsord
  521. #
  522. /sbin/putdev -a ticlts cdevlist=/dev/ticlts \
  523.     desc="Loopback connectionless" $USR_PUTDEV >/dev/null 2>&1
  524.  
  525. /sbin/putdev -a ticots cdevlist=/dev/ticots \
  526.     desc="Loopback virtual circuit" $USR_PUTDEV >/dev/null 2>&1
  527.  
  528. /sbin/putdev -a ticotsord cdevlist=/dev/ticotsord \
  529.     desc="Loopback virtual circuit orderly release" $USR_PUTDEV >/dev/null 2>&1
  530.  
  531.  
  532. #
  533. #    create the hosts and services files for the loopback drivers...
  534. #
  535.  
  536. UNAME=`/usr/bin/uname -n`
  537.  
  538. for i in ticots ticotsord ticlts
  539. do
  540.  
  541.     ############# Begin UPGRADE AND OVERLAY #######################
  542.     
  543.     [ "$AUTOMERGE" = "No" ] && {
  544.  
  545.         rm -f /etc/net/$i/services /etc/net/$i/hosts
  546.     }
  547.     
  548.     ############# End UPGRADE AND OVERLAY #######################
  549.  
  550.  
  551.     grep '^rpcbind    rpc' /etc/net/$i/services >/dev/null 2>&1
  552.     if [ $? != 0 ]
  553.     then
  554.         echo "rpcbind    rpc" >>/etc/net/$i/services
  555.     fi
  556.  
  557.     grep '^keyserv    keyserv' /etc/net/$i/services >/dev/null 2>&1
  558.     if [ $? != 0 ]
  559.     then
  560.         echo "keyserv    keyserv" >>/etc/net/$i/services
  561.     fi
  562.  
  563.     grep '^listen    serve' /etc/net/$i/services >/dev/null 2>&1
  564.     if [ $? != 0 ]
  565.     then
  566.         echo "listen    serve" >>/etc/net/$i/services
  567.     fi
  568.  
  569.     grep '^statd    statd' /etc/net/$i/services >/dev/null 2>&1
  570.     if [ $? != 0 ]
  571.     then
  572.         echo "statd    statd" >>/etc/net/$i/services
  573.     fi
  574.  
  575.     grep '^lockd    lockd' /etc/net/$i/services >/dev/null 2>&1
  576.     if [ $? != 0 ]
  577.     then
  578.         echo "lockd    lockd" >>/etc/net/$i/services
  579.     fi
  580.  
  581.     grep '^nfsd    nfsd' /etc/net/$i/services >/dev/null 2>&1
  582.     if [ $? != 0 ]
  583.     then
  584.         echo "nfsd    nfsd" >>/etc/net/$i/services
  585.     fi
  586.  
  587.     grep '^reportscheme    reportscheme' /etc/net/$i/services >/dev/null 2>&1
  588.     if [ $? != 0 ]
  589.     then
  590.         echo "reportscheme    reportscheme" >>/etc/net/$i/services
  591.     fi
  592.  
  593.     #
  594.     #    update the hosts files for the loopback drivers...
  595.     #
  596.  
  597.     grep $UNAME /etc/net/$i/hosts >/dev/null 2>&1
  598.     if [ $? != 0 ]
  599.     then
  600.         echo "$UNAME    $UNAME" >>/etc/net/$i/hosts
  601.     fi
  602.  
  603.     #
  604.     #    update the files within OAM
  605.     #
  606.  
  607.     installf $PKGINST $BASEDIR/etc/net/$i/hosts v 0644 root sys 1 NULL NULL
  608.     installf $PKGINST $BASEDIR/etc/net/$i/services v 0644 root sys 1 NULL NULL
  609.  
  610. done
  611.  
  612. #
  613. #    Install listen id (if not there) and fix up files.
  614. #    Also allow root to execute listen with appropriate privileges.
  615. #
  616. /usr/sbin/useradd  -u 37 -g 4 -c "Network Admin" -d /usr/net/nls listen \
  617.     >/dev/null 2>&1
  618. /usr/bin/adminuser -a listen:/usr/lib/saf/listen:allprivs root >/dev/null 2>&1
  619. if [ "$?" -ne 0 ]
  620. then
  621.     /usr/bin/adminuser -n -a listen:/usr/lib/saf/listen:allprivs root >/dev/null 2>&1
  622. fi
  623. STEM=$BASEDIR/etc/saf
  624. sacadm -L -t listen 2>/dev/null | cut -f1 -d: >/tmp/listeners
  625. #
  626. #    convert the listener files that are already under SAF
  627. #    control
  628. #
  629. for i in `cat /tmp/listeners`
  630. do
  631.     if [ -f $STEM/$i/_pmtab ]
  632.     then
  633.         
  634.         cp $STEM/$i/_pmtab $STEM/$i/_opmtab || error 4
  635.         /usr/lib/saf/dbfconv $STEM/$i/_opmtab $STEM/$i/_pmtab
  636.         if [ $? -ne 0 ]
  637.         then
  638.             error 5
  639.             pfmt -s error -g ${PKGMSG}:10 " listener database conversion failed\n" 2>&1
  640.         fi
  641.     fi
  642. done
  643. #
  644. #    now convert any old style listeners into new format
  645. #
  646. sacadm -L 2>/dev/null | cut -f1 -d: >/tmp/pms
  647. LHOME=$BASEDIR/usr/net/nls
  648. for i in $LHOME/*
  649. do
  650.     NETSPEC=`basename $i`
  651.     if test -d $i
  652.     then
  653.         grep $NETSPEC /tmp/listeners >/dev/null
  654.         if [ $? -eq 0 ]
  655.         then
  656. #
  657. #    old listener has already been converted
  658. #
  659.             continue
  660.         fi
  661. #
  662. #    does another port monitor exist with this name?
  663. #
  664.         grep $NETSPEC /tmp/pms >/dev/null
  665.         if [ $? -eq 0 ]
  666.         then
  667.             error 5
  668.             pfmt -s error -g ${PKGMSG}:11 " can not convert %s listener to new format, tag already exists\n" $NETSPEC 2>&1
  669.             continue
  670.         fi
  671. #
  672. #    ok to create new port monitor
  673. #
  674.         COMMAND=/usr/lib/saf/listen
  675.         if [ $NETSPEC = starlan ]
  676.         then
  677.             COMMAND="$COMMAND -m slan"
  678.         fi
  679.         sacadm -a -p $NETSPEC -t listen -c "$COMMAND $NETSPEC" -v `/usr/sbin/nlsadmin -V` -y "$NETSPEC listener"
  680.         if [ $? -ne 0 ]
  681.         then
  682.             error 5
  683.             pfmt -s error -g ${PKGMSG}:12 " can not create new port monitor entry for %s\n" $NETSPEC 2>&1
  684.             continue
  685.         fi
  686. #
  687. #    convert the database file and put it in the right place
  688. #
  689.         if test -f $i/dbf
  690.         then
  691.             cp $i/dbf /tmp/$$.dbf
  692.             /usr/lib/saf/dbfconv /tmp/$$.dbf $STEM/$NETSPEC/_pmtab
  693.             if [ $? -ne 0 ]
  694.             then
  695.                 error 5
  696.                 pfmt -s error -g ${PKGMSG}:13 " listener database conversion failed\n" 2>&1
  697.             else
  698.                 sacadm -x -p $NETSPEC
  699.             fi
  700.         fi
  701.     fi
  702. done
  703. rm /tmp/listeners
  704. rm /tmp/pms
  705. #
  706. # leave symbolic (and hard) links around for compatibility
  707. #
  708. if [ -d $LHOME ]
  709. then
  710.     if [ -f $LHOME/listen ]
  711.     then
  712.             rm $LHOME/listen
  713.     fi
  714.     if [ -f $LHOME/dbfconv ]
  715.     then
  716.             rm $LHOME/dbfconv
  717.     fi
  718.     if [ -f $LHOME/nlps_server ]
  719.     then
  720.             rm $LHOME/nlps_server
  721.     fi
  722.     if [ -f $BASEDIR/usr/bin/nlsadmin ]
  723.     then
  724.         rm $BASEDIR/usr/bin/nlsadmin 
  725.     fi
  726.         ln -s $BASEDIR/usr/lib/saf/listen $LHOME/listen
  727.         ln -s $BASEDIR/usr/lib/saf/dbfconv $LHOME/dbfconv
  728.         ln -s $BASEDIR/usr/lib/saf/nlps_server $LHOME/nlps_server
  729.         ln $BASEDIR/usr/sbin/nlsadmin /usr/bin/nlsadmin
  730.     installf ${PKGINST} $BASEDIR/usr/bin/nlsadmin=$BASEDIR/usr/sbin/nlsadmin l || error
  731. fi
  732.  
  733.  
  734. #
  735. #    Initialize reportscheme service codes for all installed 
  736. #    transport providers.
  737. #    Note: pmadm adds the entry to all currently defined listeners.
  738. #
  739. NLS=/usr/sbin/nlsadmin
  740.  
  741. pmadm -a -t listen -s reportscheme -i root -v `$NLS -V` -y "reportscheme service; execute ONLY with NULL authentication scheme" -m "`$NLS -c /usr/sbin/reportscheme`" >/dev/null 2>&1
  742.  
  743. #
  744. #    add entries to /etc/security/MLD/nsu for multi-level directories
  745. #
  746. echo "/var/iaf/cr1" >>/etc/security/MLD/nsu
  747. installf ${PKGINST} /etc/security/MLD/nsu f 0644 root sys 2 NULL NULL
  748.  
  749. #
  750. #    Do the following for TSA
  751. #
  752.  
  753. TCPPORT=${TCPPORT:-413}
  754. CONF=/etc/unixtsa.conf
  755. STARTUP=/etc/init.d/unixtsa
  756.  
  757. # add TCP entry to /etc/inet/services if it's not there already
  758. if egrep "^unixtsa[     ]*${TCPPORT}/tcp" /etc/inet/services >/dev/null
  759. then
  760.     :
  761. else
  762.     echo "unixtsa    ${TCPPORT}/tcp" >> /etc/inet/services
  763. fi
  764.  
  765. # Note: the nwnet package will add SPX entry to /etc/inet/services
  766.  
  767. # create initial /etc/unixtsa.conf file if it doesn't exist
  768. installf $PKG $CONF v 0644 root sys
  769. if [ ! -f $CONF ]
  770. then
  771.     cat > $CONF <<-EOF
  772.     #
  773.     # unixtsa.conf: TSA for Unix configuration file
  774.     # <Server name> <protocol> [<tsa codeset> <server codeset> <server locale>]
  775.     EOF
  776. fi
  777.  
  778. # create startup script in /etc/rc2.d
  779. installf $PKG $STARTUP f 0444 root sys
  780. cat > $STARTUP <<'EOF'
  781. #
  782. # unixtsa start/stop script
  783. #
  784.  
  785. if [ -z "$LC_ALL" -a -z "$LC_MESSAGES" ]
  786. then
  787.     if [ -z "$LANG" ]
  788.     then
  789.         LNG=`defadm locale LANG 2>/dev/null`
  790.         if [ "$?" != 0 ]
  791.         then LANG=C
  792.         else eval $LNG
  793.         fi
  794.     fi
  795.     export LANG
  796. fi
  797. LABEL="UX:$0"
  798. CAT="uxrc"
  799.  
  800. USAGE="$0 [ start | stop ]"
  801.  
  802. PATH=/etc:/bin:/usr/bin:/usr/sbin
  803.  
  804. DAEMON=tsad
  805. SERVER=tsaunix
  806.  
  807. case "$1" in
  808.     'start')
  809.     _tsad=
  810.     if [ -z "$_AUTOBOOT" ]
  811.     then
  812.         _tsad=`ps -e | egrep ' tsad$' 2>&1`
  813.     fi
  814.     if [ -z "$_tsad" ]
  815.     then
  816.         if [ ! -x /usr/sbin/$DAEMON ]
  817.         then
  818.             exit 0
  819.         fi
  820.         /usr/sbin/$DAEMON -p/usr/sbin/$SERVER
  821.     fi
  822.     ;;
  823.  
  824.     'stop')
  825.     if [ -z "$_AUTOKILL" ]    
  826.     then
  827.         pidlist=
  828.         Pid=
  829.         pidlist=`ps -e | sed -n '/ tsad /p
  830.             / tsad$/p
  831.             / tsaunix /p
  832.             / tsaunix$/p' |
  833.             while read Pid Junk
  834.             do
  835.                 echo $Pid
  836.             done`
  837.         if [ -n "$pidlist" ]
  838.         then
  839.             kill -15 "$pidlist" 2>/dev/null
  840.         fi
  841.     fi
  842.     ;;
  843.  
  844.     *)
  845.     pfmt -l $LABEL -s action -g $CAT:4 "Usage: %s\n" "$USAGE"
  846.     exit 1
  847.     ;;
  848. esac
  849.  
  850. exit 0
  851. EOF
  852.  
  853. # link startup script into rc2.d
  854. installf $PKG /etc/rc2.d/S70unixtsa=${STARTUP} l
  855.  
  856. # attempt to start daemon if at run level 2 or higher, may fail
  857. # set +e
  858. who -r | while read Dot Label Level Junk
  859. do
  860. [ "$Level" -ge 2 ] && [ "${HOW_INSTALL}" != "ON_BFLOP" ] && \
  861.     /bin/sh /etc/init.d/unixtsa start
  862. done
  863.  
  864. #    End of work for TSA
  865.  
  866. #
  867. #    finished installing files: tell OAM
  868. #
  869. installf -f $PKGINST || error 6
  870.  
  871. #
  872. #    make a new UNIX(R)
  873. #
  874. # rebuild for changes to take effect 
  875. # but do it only if no other pkgs in the set are being installed
  876.  
  877. # XXX ${CONFBIN}/idbuild 2>>${TMP}
  878. # XXX if
  879. # XXX     [ "$?" -ne "0" ]
  880. # XXX then
  881. # XXX     pfmt -s nostd -g ${PKGMSG}:14 "An error has occurred during the rebuild of the UNIX System.\nErrors have been written to the file %s\n" ${TMP} 2>&1
  882. # XXX     exit ${FAILURE}
  883. # XXX fi
  884.  
  885. removef ${PKGINST} ${VOLATILES} >/dev/null 2>&1
  886. removef ${PKGINST} /tmp/nsu >/dev/null 2>&1
  887. removef -f ${PKGINST} >/dev/null 2>&1
  888.  
  889. errflag=`expr ${errflag:=0} + 10`
  890.  
  891.  
  892. ############# Begin UPGRADE AND OVERLAY #######################
  893.  
  894.     ${SCRIPTS}/pkgmrgconf "${PKGINST}" "$AUTOMERGE" "$NAME"
  895.  
  896. # cleanup patch files from /var/sadm/install/contents and rm them
  897.  
  898. [ "$PKGINSTALL_TYPE" = NEWINSTALL ] || ${SCRIPTS}/up_cleanup "${PKGINST}"
  899.  
  900. [ "$UPDEBUG" = YES ] && goany
  901.  
  902. ############# End   UPGRADE AND OVERLAY #######################
  903.  
  904. exit $errflag
  905.