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

  1. #ident    "@(#)pkg.cmds:i386/pkg/cmds/postinstall    1.19.6.1"
  2.  
  3. PKGMSG=${PKGINST}.pkg
  4. LOCALE=${LC_ALL:-${LC_MESSAGES:-${LANG:-"C"}}}
  5.  
  6. if [ ! -f /usr/lib/locale/${LOCALE}/LC_MESSAGES/${PKGMSG} ]
  7. then
  8.    if [ -f ${REQDIR}/inst/locale/${LOCALE}/${PKGMSG} -a \
  9.     -d /usr/lib/locale/${LOCALE}/LC_MESSAGES ]
  10.    then
  11.     cp ${REQDIR}/inst/locale/${LOCALE}/${PKGMSG} \
  12.        /usr/lib/locale/${LOCALE}/LC_MESSAGES
  13.    fi
  14. fi
  15. do_install(){
  16.     ERR=/tmp/${1}.err
  17.     IDCOMPS="Driver.o Driver_atup.o Driver_mp.o Master System Space.c Stubs.c Mtune Dtune Node"
  18.  
  19.     ${CONFBIN}/idinstall -P ${PKGINST} -a ${1} > ${ERR} 2>&1
  20.     RET=$?
  21.  
  22.     if [ "$RET" != 0 ]
  23.     then
  24.         ${CONFBIN}/idinstall -P ${PKGINST} -u ${1} > ${ERR} 2>&1
  25.         RET=$?
  26.     fi
  27.  
  28.     rm -rf ${IDCOMPS}
  29.     if [ ${RET} != 0 ]
  30.     then
  31.         message -d `pfmt -s nostd -g ${PKGMSG}:1 "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`
  32.         exit ${FAILURE}
  33.     fi
  34.     rm -rf ${ERR}
  35. }
  36.  
  37. CONFDIR=/etc/conf
  38. CONFBIN=${CONFDIR}/bin
  39. FAILURE=1        #exit code if anything goes wrong
  40.  
  41. ### Install drivers
  42. ###  Any modules installed in /tmp should be added to
  43. ###  the removef loop below.
  44.  
  45. for MODULE in fp lockstat prf fc mirrorcon
  46. do
  47.     cd /tmp/${MODULE}
  48.     do_install ${MODULE}
  49. done
  50.  
  51. # rebuild for changes to take effect
  52.  
  53. TMP=/tmp/cmds.$$
  54. /etc/conf/bin/idbuild
  55.  
  56. ##########
  57. # moved from pkg.lp/postinstall
  58. if [ ! -z "`echo ${CLASSES} | grep post`" ]
  59. then
  60.     ETCLP=/etc/lp
  61.     USRSBIN=/usr/sbin
  62.     USRLIB=/usr/lib
  63.     LPADMIN=${USRSBIN}/lpadmin
  64.     LPFILTER=${USRSBIN}/lpfilter
  65.     LPSCHED=${USRLIB}/lp/lpsched
  66.     LPSHUT=${USRSBIN}/lpshut
  67.     ACCEPT=${USRSBIN}/accept
  68.     REJECT=${USRSBIN}/reject
  69.     LPSTAT=${USRBIN}/lpstat
  70.     DUMPOLP=${USRSBIN}/dumpolp
  71.     ENABLE=${USRBIN}/enable
  72.     DISABLE=${USRBIN}/disable
  73.     TMP=/tmp/cmds.err
  74.  
  75.     ##########
  76.     #
  77.     # ``Compile'' the filter table entries. This is a tad
  78.     # complicated, because we want to preserve the original
  79.     # filter.table and filter.table.i entries.
  80.     #
  81.     # Note: We do this whether or not we are installing any particular
  82.     # sub-package (e.g. PostScript), so that it gets done in one place.
  83.     # The OAM installation process won't install a class not listed
  84.     # in the $CLASSES variable, so we won't be compiling anything
  85.     # we shouldn't.
  86.     ##########
  87.  
  88.     FILTERTABLE=${ETCLP}/filter.table
  89.     FILTERTABLE_I=${ETCLP}/filter.table.i  #Factory-installed
  90.     FDTMP=${ETCLP}/fd
  91.     FILTERTABLE_TMP=${FDTMP}/filter.table
  92.     
  93.     if ls ${FDTMP}/*.fd > /tmp/FDLIST 2>/dev/null
  94.     then
  95.         #####
  96.         #
  97.         # The regular filter table:
  98.         #####
  99.         while read fd
  100.         do
  101.             filter=`expr "${fd}" : '.*/\([^/]*\)\.fd$'`
  102.             ${LPFILTER} -f ${filter} -F ${fd} 2>>${TMP}
  103.         done < /tmp/FDLIST
  104.  
  105.         #####
  106.         #
  107.         # The ``factory installed'' filter table:
  108.         #####
  109.         mv ${FILTERTABLE} ${FILTERTABLE_TMP}
  110.         mv ${FILTERTABLE_I} ${FILTERTABLE} 2>/dev/null
  111.     
  112.         while read fd
  113.         do
  114.             filter=`expr "${fd}" : '.*/\([^/]*\)\.fd$'`
  115.             ${LPFILTER} -f ${filter} -F ${fd} 2>>${TMP}
  116.         done < /tmp/FDLIST
  117.     
  118.         mv ${FILTERTABLE} ${FILTERTABLE_I}
  119.         mv ${FILTERTABLE_TMP} ${FILTERTABLE}
  120.     
  121.         removef ${PKGINST} - < /tmp/FDLIST > /dev/null 2>&1
  122.         rm -f ${FDTMP}/*.fd
  123.     fi
  124.     removef ${PKGINST} ${FDTMP} >/dev/null
  125.     rm -rf ${FDTMP} /tmp/FDLIST
  126.  
  127.     # If we are installing the PostScript filters, et al, then we need
  128.     # to compile the troff font-width tables.
  129.     ##########
  130.     FONTDIR=/usr/lib/font
  131.     DEVPOST=${FONTDIR}/devpost
  132.     CHARLIB=${DEVPOST}/charlib
  133.     MAKEDEV=${FONTDIR}/makedev
  134.     LINKFILE=${DEVPOST}/LINKFILE
  135.     ASCII="DESC ? ??"
  136.     FULLASCII="${DEVPOST}/DESC ${DEVPOST}/? ${DEVPOST}/??"
  137.     
  138.     cd ${DEVPOST}
  139.     
  140.     #
  141.     # Upgrade/Overlay support requires we remove the links that were made
  142.     # the first time through here.  Otherwise, we get warnings from the
  143.     # installf and the contents file gets updated incorrectly.
  144.     #
  145.  
  146.     `grep "^rm" ${LINKFILE}`
  147.     
  148.     ${MAKEDEV} ${ASCII} >/dev/null 2>&1
  149.     
  150.     (
  151.         for file in *.out
  152.             do
  153.                 echo "${DEVPOST}/${file} f 444 lp lp"
  154.             done
  155.             sed -n -e "s;^ln \(.*\) \(.*\);${DEVPOST}/\2=${DEVPOST}/\1 l;p" <${LINKFILE}
  156.     ) | installf ${PKGINST} -
  157.  
  158.     #####
  159.     #
  160.     # Remove the font-width-table source, add in the compiled.
  161.     #####
  162.     removef ${PKGINST} ${FULLASCII} >/dev/null
  163.     rm -f ${FULLASCII}
  164.  
  165.     #####
  166.     #
  167.     # Remove tools no longer needed.
  168.     #####
  169.     removef ${PKGINST} ${MAKEDEV} ${LINKFILE} 2>/dev/null
  170.     rm -f ${MAKEDEV} ${LINKFILE}
  171.  
  172. fi  # End of post class script
  173.  
  174. ### Remove temporary modules installed in /tmp
  175.  
  176. rm -f ${TMP}  > /dev/null 2>&1
  177.  
  178. rm -f /tmp/MOD_FILES
  179. for MODULE in fp lockstat prf fc mirrorcon
  180. do
  181.     echo "/tmp/${MODULE}/Driver_atup.o\n\
  182. /tmp/${MODULE}/Driver_mp.o\n\
  183. /tmp/${MODULE}/Driver.o\n\
  184. /tmp/${MODULE}/Space.c\n\
  185. /tmp/${MODULE}/Stubs.c\n\
  186. /tmp/${MODULE}/Master\n\
  187. /tmp/${MODULE}/System\n\
  188. /tmp/${MODULE}/Mtune\n\
  189. /tmp/${MODULE}/Dtune\n\
  190. /tmp/${MODULE}/Node\n\
  191. /tmp/${MODULE}" >> /tmp/MOD_FILES
  192. done
  193. ######################################################
  194. #
  195. # taken from pkg.perf postinstall
  196. #
  197. ######################################################
  198. #
  199. #
  200. #The following defines the roles for the TFM database.
  201. #
  202. #
  203.  
  204. #
  205. #The following while-loop reads the commands and the roles
  206. #to which these commands are to be assigned.  If privileges,
  207. #separated by a colon, appear next to the role in the script that
  208. #this while-loop reads in, it means that those privileges are to
  209. #be shutoff for that command when it is assigned to the role.
  210. #
  211. while read cmd roles
  212. do
  213.     base=`basename $cmd`
  214.     privs=`
  215.     egrep ":${cmd}$" /etc/security/tcb/privs|    # Find command in tcb database
  216.     sed 's/^.*%inher,\(.*\):.*/\1/p' |          # get the set of inher privs
  217.     sed 's/^.*%fixed,\(.*\):.*//p' |            # delete the fixed privs
  218.     sed 's/,/:/gp'                              # changed ,'s to :'s
  219.     `
  220.     if [ -z "$privs" ]
  221.     then
  222.     echo $cmd $roles >> /tmp/rolelist
  223.     continue
  224.  
  225.     else
  226.         prvd="yes"
  227.     fi
  228.     set $roles
  229.     save="$privs"
  230.     while [ $# -gt 0 ]
  231.     do
  232.         role=$1
  233.         if echo "$1" | grep ":" > /dev/null
  234.         then
  235.             role=`
  236.             echo "$1" | sed 's/:.*$//p'`
  237.             if [ "$prvd" = "yes" ]
  238.             then
  239.                 shutoff=`
  240.                 echo "$1" | sed 's/^[A-Z]*://p'`
  241.                 shutoff=`echo "$shutoff"|sed 's/:/ /gp'`
  242.                 fullset=`echo "$save"|sed 's/:/ /gp'`
  243.                 for i in $shutoff    #check if privileges to be shut off
  244.                 do                    #are in full set of privilges
  245.                     found="false"
  246.                     for j in $fullset
  247.                     do
  248.                         if [ "$i" = "$j" ]
  249.                         then
  250.                             found="true"
  251.                             break
  252.                         fi
  253.                     done
  254.                     privs=""
  255.                     if [ "$found" = "false" ]
  256.                     then
  257.                         pfmt -s warn -g ${PKGMSG}:3 " %s privilege specified to be shut off for %s,\n         but it is NOT in its set of privileges.\n" $i $cmd 2>&1
  258.                         break
  259.                     fi
  260.                 done
  261.                 if [ -z "$shutoff" ]
  262.                 then
  263.                     privs="$save"
  264.                 else
  265.                     for i in $fullset
  266.                     do
  267.                         found="false"
  268.                         for j in $shutoff
  269.                         do
  270.                             if [ "$i" = "$j" ]
  271.                             then
  272.                                 found="true"
  273.                                 break
  274.                             fi
  275.                         done
  276.                         if [ "$found" = "false" ]
  277.                         then
  278.                             if [ -z "$privs" ]
  279.                             then
  280.                                 privs=$i
  281.                             else
  282.                                 privs=$privs:$i
  283.                             fi
  284.                         fi
  285.                     done
  286.                 fi
  287.             fi
  288.         else
  289.             privs="$save"
  290.         fi
  291.         if [ -z "$privs" ]
  292.         then
  293.             adminrole -a $base:$cmd $role
  294.         else
  295.             adminrole -a $base:$cmd:$privs $role
  296.         fi
  297.         shift
  298.     done
  299. done <<!
  300. /usr/bin/at            SOP    SSO
  301. /usr/bin/logins    SSO
  302. /usr/bin/nice                SSO
  303. /usr/bin/strchg    SSO
  304. /usr/sbin/chroot            SSO
  305. /usr/sbin/ncheck            SSO
  306. /usr/sbin/sar        OP    SOP    SSO
  307. /usr/sbin/hwmetric    OP    SOP    SSO
  308. /usr/sbin/sttydefs    SOP    SSO
  309. /usr/sbin/sysdef    OP    SOP    SSO
  310. /usr/sbin/volcopy        SOP    SSO
  311. !
  312. #
  313. ############################################
  314. #
  315. #The following defines the users for the TFM database.
  316. #
  317. #
  318. for user in root bin sys adm lp
  319. do
  320.     adminuser $user >/dev/null 2>&1 || adminuser -n $user
  321. done
  322. #
  323. #The following while-loop reads the commands and the users
  324. #to which these commands are to be assigned.  If privileges,
  325. #separated by a colon, appear next to the user in the script that
  326. #this while-loop reads in, it means that those privileges are to
  327. #be shutoff for that command when it is assigned to the user.
  328. #
  329. #
  330. while read cmd users
  331. do
  332.     base=`basename $cmd`
  333.     privs=`
  334.     egrep ":${cmd}$" /etc/security/tcb/privs|# Find command in tcb database
  335.     sed 's/^.*%inher,\(.*\):.*/\1/p' |       # get the set of inher privs
  336.     sed 's/^.*%fixed,\(.*\):.*//p' |         # delete the fixed privs
  337.     sed 's/,/:/gp'                           # changed ,'s to :'s
  338.     `
  339.     if [ -z "$privs" ]
  340.     then
  341.     echo $cmd $users >> /tmp/userlist
  342.     continue
  343.     else
  344.         prvd="yes"
  345.     fi
  346.     set $users
  347.     save="$privs"
  348.     while [ $# -gt 0 ]
  349.     do
  350.         user=$1
  351.         if echo "$1" | grep ":" > /dev/null
  352.         then
  353.             user=`
  354.             echo "$1" | sed 's/:.*$//p'`
  355.             if [ "$prvd" = "yes" ]
  356.             then
  357.                 shutoff=`
  358.                 echo "$1" | sed 's/[a-z]*:\(.*\)$/\1/p'`
  359.                 shutoff=`echo "$shutoff"|sed 's/:/ /gp'`
  360.                 fullset=`echo "$save"|sed 's/:/ /gp'`
  361.                 for i in $shutoff    #check if privileges to be shut off
  362.                 do                   #are in full set of privilges
  363.                     found="false"
  364.                     for j in $fullset
  365.                     do
  366.                         if [ "$i" = "$j" ]
  367.                         then
  368.                             found="true"
  369.                             break
  370.                         fi
  371.                     done
  372.                     privs=""
  373.                     if [ "$found" = "false" ]
  374.                     then
  375.             pfmt -s warn -g ${PKGMSG}:3 " %s privilege specified to be shut off for %s,\n         but it is NOT in its set of privileges.\n" $i $cmd 2>&1
  376.                         break
  377.                     fi
  378.                 done
  379.                 if [ -z "$shutoff" ]
  380.                 then
  381.                     privs="$save"
  382.                 else
  383.                     for i in $fullset
  384.                     do
  385.                         found="false"
  386.                         for j in $shutoff
  387.                         do
  388.                             if [ "$i" = "$j" ]
  389.                             then
  390.                                 found="true"
  391.                                 break
  392.                             fi
  393.                         done
  394.                         if [ "$found" = "false" ]
  395.                         then
  396.                             if [ -z "$privs" ]
  397.                             then
  398.                                 privs=$i
  399.                             else
  400.                                 privs=$privs:$i
  401.                             fi
  402.                         fi
  403.                     done
  404.                 fi
  405.             fi
  406.         else
  407.             privs="$save"
  408.         fi
  409.         if [ -z "$privs" ]
  410.         then
  411.             adminuser -a $base:$cmd $user
  412.         else
  413.             adminuser -a $base:$cmd:$privs $user
  414.         fi
  415.         shift
  416.     done
  417. done <<!
  418. /usr/sbin/sar    sys
  419. /usr/sbin/rtpm    sys
  420. /usr/lib/sa/sadc    sys
  421. /usr/lib/sa/sa1    sys
  422. /usr/lib/sa/sa2    sys
  423. !
  424.  
  425. removef ${PKGINST} - < /tmp/MOD_FILES 2>/dev/null
  426. removef -f ${PKGINST} 2>/dev/null
  427. rm -f /tmp/MOD_FILES
  428. installf -f ${PKGINST}
  429.  
  430. # Save volatile files during upgrade or overlay
  431. SCRIPTS=/usr/sbin/pkginst
  432. ${SCRIPTS}/pkgmrgconf "${PKGINST}" "${AUTOMERGE}" "${NAME}"
  433.  
  434. errflag=`expr ${errflag:=0} + 10`
  435. exit ${errflag}
  436.