home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / lp / install / preinstall < prev    next >
Encoding:
Text File  |  1998-08-19  |  4.9 KB  |  198 lines

  1. #ident    "@(#)preinstall    1.2"
  2. #ident  "$Header: $"
  3.  
  4. PKGMSG=${PKGINST}.pkg
  5. LOCALE=${LC_ALL:-${LC_MESSAGES:-${LANG:-"C"}}}
  6.  
  7. if [ ! -f /usr/lib/locale/${LOCALE}/LC_MESSAGES/${PKGMSG} ]
  8. then
  9.    if [ -f ${REQDIR}/inst/locale/${LOCALE}/${PKGMSG} -a \
  10.     -d /usr/lib/locale/${LOCALE}/LC_MESSAGES ]
  11.    then
  12.     cp ${REQDIR}/inst/locale/${LOCALE}/${PKGMSG} \
  13.        /usr/lib/locale/${LOCALE}/LC_MESSAGES
  14.    fi
  15. fi
  16. ##########
  17. ##
  18. ## Make sure the user "lp" and group "lp" exist and are
  19. ## consistent.
  20. ##
  21. ##########
  22.  
  23. pfmt -s nostd -g ${PKGMSG}:1 "##checking that user \"lp\" and group \"lp\" exist. . .\n" 2>&1
  24.  
  25. PATH=${PATH}:/usr/sadm/bin
  26. export PATH
  27.  
  28. #chgflag=0
  29. if valgid lp
  30. then
  31.     entry=`grep '^lp:' /etc/group`
  32.     gid=`expr "${entry}" : "^lp:[^:]*:\([^:]*\):"`
  33. else
  34.     gid=7
  35.     until groupadd -g ${gid} lp >/dev/null 2>&1
  36.     do
  37.         gid=`expr ${gid} + 1`
  38.     done
  39.     #chgflag=1
  40.     pfmt -s nostd -g ${PKGMSG}:2 "\nThe group \"lp\" has been created with ID %s.\n\n" ${gid} 2>&1
  41. fi
  42.  
  43. if valuid lp
  44. then
  45.     entry=`grep '^lp:' /etc/passwd`
  46.     cgid=`expr "${entry}" : "lp:[^:]*:[^:]*:\([^:]*\):"`
  47.     if [ ${cgid} -ne ${gid} ]
  48.     then
  49.         pfmt -s nostd -g ${PKGMSG}:3 "##Moving the login \"lp\" from group ID %s to $s . . .\n" ${cgid} ${gid} 2>&1
  50.         usermod -g ${gid} lp
  51.         #chgflag=1
  52.     fi
  53. else
  54.     uid=7
  55.     until useradd -g ${gid} -u ${uid} -d /var/spool/lp lp >/dev/null 2>&1
  56.     do
  57.         uid=`expr ${uid} + 1`
  58.     done
  59.     #chgflag=1
  60.     pfmt -s nostd -g ${PKGMSG}:4 "\nThe login \"lp\" has been created with ID %s.\n\n" ${uid} 2>&1
  61. fi
  62.  
  63. ##########
  64. ##
  65. ## Ensure that "lp" can use cron:
  66. ##
  67. ##########
  68.  
  69. CRONALLOW=/etc/cron.d/cron.allow
  70. CRONDENY=/etc/cron.d/cron.deny
  71.  
  72. if [ -f "${CRONDENY}" ] 
  73. then
  74.     if grep '^lp$' ${CRONDENY} 1>/dev/null 2>&1
  75.     then
  76.     ed -s ${CRONDENY} <<-'EOF'
  77.         /^lp$/d
  78.         w
  79.         q
  80.     EOF
  81.     pfmt -s nostd -g ${PKGMSG}:5 "\nThe login \"lp\" has been removed from the list of logins\n\tdenied access to the cron service.\n\n" 2>&1
  82.     fi
  83. fi
  84.  
  85. if [ -f "${CRONALLOW}" ]
  86. then
  87.     if grep '^lp$' ${CRONALLOW} 1>/dev/null 2>&1
  88.     then
  89.         :
  90.     else
  91.         echo "lp" >>${CRONALLOW}
  92.         pfmt -s nostd -g ${PKGMSG}:6 "\nThe login \"lp\" has been added to the list of logins\n\tallowed to use the cron service.\n\n" 2>&1
  93.     fi
  94. fi
  95.  
  96. ############# Begin UPGRADE AND OVERLAY #######################
  97.  
  98. SCRIPTS=/usr/sbin/pkginst
  99. . ${SCRIPTS}/updebug
  100.  
  101. [ "$UPDEBUG" = YES ] && set -x
  102.  
  103. #  The volatile files saved for ${PKGINST} will be listed in 
  104. #  /etc/inst/save.user/${PKGINST}.sav
  105.  
  106. #  The initial V4 volatile files list for ${PKGINST} should be in 
  107. #  /etc/inst/up/patch/${PKGINST}.LIST
  108.  
  109. [ "$PKGINSTALL_TYPE" = NEWINSTALL ] || {
  110.  
  111.     #
  112.     # For an AUTOMATIC installation, PKGINSTALL_TYPE will not
  113.     # be set here.  Normally we could let pkgsavfiles deal with
  114.     # this case, but lp is special because for an upgrade, the
  115.     # the volatile files had to be saved before we installed
  116.     # the base.  So we need to determine the install type here
  117.     # using the generic tool chkpkgrel.  We're relying on the
  118.     # original pkginfo file (if any) to still be in place.
  119.     #
  120.  
  121.     UPGFILE=/etc/inst/save.user/lp.env
  122.  
  123.     [ ! "$PKGINSTALL_TYPE" ] && {
  124.  
  125.         #This code is run in automatic mode.
  126.         #For overlay we must remember to rm /etc/inst/save.user/lp.env 
  127.         #created by chkpkgrel being run here.  Therefore, set rm_lp_env.
  128.         #This must be done for pkgsavfiles to work correctly.
  129.  
  130.         rm_lp_env=1    
  131.  
  132.         PKGINSTALL_TYPE=NEWINSTALL
  133.  
  134. #chkpkgrel, returns a code, indicating which version of this pkg is installed.
  135. #Return code 2 indicates overlay of the same or older version. For overlay,
  136. #existence of the file $UPGRADE_STORE/$PKGINST.ver indicates presence of older
  137. #version. This file contains the old version.
  138.  
  139. #    ${SCRIPTS}/chkpkgrel returns    0 if pkg is not installed
  140. #                    1 if pkg if unknown version
  141. #                    2 if pkg is SVR4.2
  142. #                    4 if pkg is SVR4.0 V4
  143. #                    9 if newer pkg is installed
  144.         ${SCRIPTS}/chkpkgrel
  145.         PKGVERSION=$?
  146.  
  147.         case $PKGVERSION in
  148.             2)    PKGINSTALL_TYPE=OVERLAY ;;
  149.             4)    PKGINSTALL_TYPE=UPGRADE ;;
  150.             9)    #pkgrm newer pkg before older pkg is installed.
  151.                 exit 3    ;; 
  152.             *)    ;;
  153.         esac
  154.  
  155.         [ "$PKGINSTALL_TYPE" = NEWINSTALL ] && {
  156.  
  157.             echo AUTOMERGE=NULL > $UPGFILE
  158.             echo PKGINSTALL_TYPE=NEWINSTALL >> $UPGFILE
  159.             # I want CUSTOM here !
  160.             echo INSTALL_MODE=CUSTOM >> $UPGFILE
  161.             exit 0
  162.         }
  163.     }
  164.  
  165.     [ "$PKGINSTALL_TYPE" = UPGRADE ] && {
  166.  
  167.             # for upgrade the files have been saved already
  168.  
  169.         cp /etc/inst/up/patch/lp.LIST /etc/inst/save.user/lp.sav
  170.  
  171.         echo AUTOMERGE=Yes > $UPGFILE
  172.         echo PKGINSTALL_TYPE=UPGRADE >> $UPGFILE
  173.         # I want CUSTOM here !
  174.         echo INSTALL_MODE=CUSTOM >> $UPGFILE
  175.  
  176.         [ "$UPDEBUG" = YES ] && goany
  177.  
  178.         exit 0
  179.     }
  180.  
  181.     #The following line of code is run in automatic mode.
  182.     #For overlay we must rm /etc/inst/save.user/lp.env 
  183.     #created by chkpkgrel run in preinstall.  rm_lp_env was set earlier.
  184.     #This must be done for pkgsavfiles to work correctly.
  185.  
  186.     [ "$rm_lp_env" = "1" ] && rm -f /etc/inst/save.user/lp.env
  187.  
  188.     [ "$UPDEBUG" = YES ] && goany
  189.  
  190.     ${SCRIPTS}/pkgsavfiles ${PKGINST}
  191.  
  192.     [ "$UPDEBUG" = YES ] && goany
  193. }
  194.  
  195. ############# End  UPGRADE AND OVERLAY #######################
  196.  
  197. exit 0
  198.