# !/usr/bin/ksh # # (c)Copyright 1996 Hewlett-Packard Co., All Rights Reserved. # $Header: /ignite/cold_fusion/src/scripts/os_arch_post_c 10.19 1998/08/22 00:00:24 paulc Exp $ # ## ## This file is the post_configure script which runs when an OS ## archive has been loaded onto a system as part of the Ignite-UX process. ## There are 3 classes of steps taken here: ## - In some cases, the archive creation/extraction tools don't do a ## complete job, so we account for that here. ## - Some SD configure scripts make changes based on the hardware of ## the machine. Since the machine where the archive is created may ## have different hardware than the target machine, we need to account for ## those actions here. ## - Defects which were found too late to fix in the SD ctrl scripts are ## sometimes handled here. ## ## WARNING: If you need to modify this file, you should copy this file to ## /var/opt/ignite/scripts and modify that copy. You will ## then need to change any config files that reference this ## file to reference the modified copy. Otherwise the ## version of this file in /opt/ignite/scripts will get ## overwritten the next time Ignite-UX is updated and any ## changes would be lost. ## ARCHIVE_SAVE_DIR="/tmp/ign_configure/os/archive_save" ARCHIVE_SAVE_FILE="/tmp/ign_configure/os/archive_save/ig_save_file" INSTALL_VARS_FILE=/tmp/install.vars RECOVERY_MODE=FALSE ############################################################################### # # Function: chmog() # # Purpose: Change mode, owner and group on the specified file(s) # If mode is 0, the mode is left unchanged # If any value is the null string, that value is not changed. chmog () { if [[ $# -lt 4 ]]; then echo "Usage: chmog mode owner group files..." >&2 return 1 fi typeset mode="$1" typeset owner="$2" typeset group="$3" typeset -i cmd_result=0 shift 3 if [[ -n "$group" ]] then chgrp $group $* || cmd_result=1 fi if [[ -n "$owner" ]] then chown $owner $* || cmd_result=1 fi if [[ -n "$mode" && "$mode" != 0 ]] then chmod $mode $* || cmd_result=1 fi return $cmd_result } # end of chmog() ############################################################################### # # Function: restore_files # # Purpose: Restore all files that were previously saved by save_file() in # os_arch_post_l. # restore_files() { if [[ ! -f $ARCHIVE_SAVE_FILE ]]; then return fi while read target; do source="$ARCHIVE_SAVE_DIR$target" if [[ -f $source ]]; then cp -pf $source $target else echo "WARNING: Could not restore $target: file not found" fi done < $ARCHIVE_SAVE_FILE } # end of restore_files() ############################################################################### # # Function: fix_dev_file_links # # Purpose: When the archive contains device files which are links to # other device files, some of the archive/extraction tools # do not put the link back as a link. This routine fixes a # bunch of the known offenders. # # This routine should not be needed if: # - device files are not included in the archive -or- # - the archive was created by pax # fix_dev_file_links() { ## ## Handle the ptys. ## find /dev/pty /dev/ptym -type c | while read dev do if [[ -c /dev/${dev##*/} ]] ; then # The same file exists both places. Link them. rm -f /dev/${dev##*/} ln $dev /dev/${dev##*/} fi done ## ## Handle the audio device files. ## for audio_file in /dev/audi*[a-zA-Z] ; do if [[ -c ${audio_file}_0 ]] ; then rm -f ${audio_file}_0 ln ${audio_file} ${audio_file}_0 fi done ## ## Handle the crt files. ## if [[ "$ARCH" = "700" ]] ; then if [[ -c /dev/crt ]] ; then rm -f /dev/crt0 ln /dev/crt /dev/crt0 fi if [[ -c /dev/ocrt ]] ; then rm -f /dev/ocrt0 ln /dev/ocrt /dev/ocrt0 fi fi ## ## Handle the hil files. ## if [[ "$ARCH" = "700" ]] ; then for i in 1 2 3 4 5 6 7 ; do if [[ -c /dev/hil${i} ]] ; then rm -f /dev/hil_0.${i} ln /dev/hil${i} /dev/hil_0.${i} fi done if [[ -c /dev/hilkbd ]] ; then rm -f /dev/hilkbd_0 ln /dev/hilkbd /dev/hilkbd_0 fi if [[ -c /dev/rhil ]] ; then rm -f /dev/rhil_0 ln /dev/rhil /dev/rhil_0 fi fi } # end of fix_dev_file_links() ############################################################################### # # Function: add_devfile # # Purpose: Construct a device file. Often used when a configure script # builds a device file. Since devfiles are normally not in the # archive, they must be built here. If the file already exists, # we do not re-create it. # # Parms: # $1 the devfile name, e.g. /dev/netman # $2 the type of devfile ("c" or "b") # $3 the major number # $4 the minor number # $5 the chmod value # $6 the owner id # $7 the group id # add_devfile() { if [[ ! -c $1 ]]; then mknod $1 $2 $3 $4 fi chmod $5 $1 chown $6:$7 $1 } # end of add_devfile() ############################################################################### # # Function: set_up_Xservers # # Purpose: This routine fixes the Xservers file(s) based on the hardware. # It is necessary because the archive is created on one # particular machine and the configure script sets up this # file with that machine's hardware in mind. To load the archive # onto a different machine with a different graphics top, # we need to do some cleanup here. # # Example Xserver entry (the leading # comments it out): # * Local local@console /usr/bin/X11/X :0 # set_up_Xservers() { VUECONFIG=/etc/vue/config XSERVERTMP=/tmp/Xservers.tmp if [[ -f $VUECONFIG/Xservers ]]; then if [[ -z $(ioscan -kC graphics) ]]; then sed 's/\(^[ ]*\*[ ]*Local\)/#\1/' $VUECONFIG/Xservers \ > $XSERVERTMP else sed 's/^[ ]*#\([ ]*\*[ ]*Local.*$\)/\1/' $VUECONFIG/Xservers \ > $XSERVERTMP fi cp $XSERVERTMP $VUECONFIG/Xservers rm -f $XSERVERTMP fi XSERVERS=/usr/dt/config/Xservers if [[ -f $XSERVERS ]]; then if [[ -z $(ioscan -kC graphics) ]]; then sed 's/\(^[ ]*\*[ ]*Local\)/#\1/' $XSERVERS \ > $XSERVERTMP else sed 's/^[ ]*#\([ ]*\*[ ]*Local.*$\)/\1/' $XSERVERS \ > $XSERVERTMP fi cp $XSERVERTMP $XSERVERS rm -f $XSERVERTMP fi } # end of set_up_Xservers() ############################################################################### # # Function: set_vue_inittab # # Purpose: Edit inittab to start vuerc (and then vuelogin) if vuerc # is present. Vuelogin does not need a local X server, # it supports XDMCP for remote X. # # If this is a CDE system, /usr/dt/bin/dtlogin will be present, # and no manipulations are required. # set_vue_inittab() { DTLOGIN=/usr/dt/bin/dtlogin VUERC=/usr/vue/bin/vuerc INITTABTMP=/tmp/inittab.tmp if [ ! -x $DTLOGIN -a -x $VUERC ] ; then sed 's/^init:[^:]*:initdefault:/init:4:initdefault:/' /etc/inittab \ > $INITTABTMP cp $INITTABTMP /etc/inittab rm -f $INITTABTMP fi } # end of set_vue_inittab() ############################################################################### # # Function: fix_diags # # Purpose: Make sure 10.01 series 700 diagnostics don't send out # nasty mail erroneously. The SUPPORT-INFO fileset configure # script already copied the newconfig version of # /etc/rc.config.d/supprtinfo down when the archive was made; # this has the SUPPORTINFO var set to zero which will cause # the mail to be queued up when the system boots thru the rc # process. Change this var like the configure script would. # fix_diags() { if [[ "$ARCH" = "700" && "$release" = "B.10.01" ]] ; then if [[ -f /usr/sbin/diag/DIAGINIT ]] ; then /usr/sbin/ch_rc -a -p SUPPORTINFO=1 fi fi } # end of fix_diags() ############################################################################### # # Function: set_up_audio # # Purpose: The AudioSubsystem.AUDIO-SRV configure script sets up the # /etc/rc.config.d/audio file according to what audio hardware is # available on the system where the archive was created. Since the # target machine may differ from the archive source machine, we # need to set this up again here. # # This routine does not need to be run if all target machines # have the same audio capabilities as the machine where the # archive was created. # set_up_audio() { if [[ -f /etc/rc.config.d/audio ]]; then if [[ -c /dev/audio ]]; then ch_rc -a -p AUDIO_SERVER=1 /etc/rc.config.d/audio else ch_rc -a -p AUDIO_SERVER=0 /etc/rc.config.d/audio fi fi } # end of set_up_audio() ############################################################################### # # Function: wtmp_btmp_setup # # Purpose: The OS-Core.UX-CORE configure script sets up the # /var/adm/wtmp and /var/adm/btmp files to track login activity. # Since these files contain system specific information they # are not put in the archive, but they need to be in place for # commands like last, and who to work correctly. # wtmp_btmp_setup() { [ ! -f /var/adm/wtmp ] && > /var/adm/wtmp chmog 664 adm adm /var/adm/wtmp [ ! -f /var/adm/btmp ] && > /var/adm/btmp chmog 600 root other /var/adm/btmp } # end of wtmp_btmp_setup() ############################################################################### # # Function: add_ups_line # # # Purpose: Fix a hole for UPS. If a Core archive install (vs.a # Core depot install) is done, the OS-Core.UPS-TOOLS # configure script (along with all other Core SD control # scripts, of course) is not run. This configure script # adds a commented-out ups line that the user might later # need. The following code duplicates that action, but # only if there is no commented-out or active ups line # present. # add_ups_line() { if [[ $ARCH = 800 && -r /etc/inittab ]]; then grep -q -e '^ *#* *ups::respawn' /etc/inittab || echo '#ups::respawn:rtprio 0 /usr/lbin/ups_mond -f /etc/ups_conf' \ >> /etc/inittab fi } # end of add_ups_line() ############################################################################### # # MAIN # # Manipulate which of the actions take place by commenting or uncommenting # the various routines below. # # # Grab the release and architecture since some of the actions # are only necessary in certain circumstances. # arch_type=$(uname -m | cut -f2 -d"/") case $arch_type in 7*) ARCH=700 ;; 8*) ARCH=800 ;; esac release=$(uname -r) # # Source the install.vars file so we know if this is recovery mode or not. # if [[ -f $INSTALL_VARS_FILE ]]; then . $INSTALL_VARS_FILE else echo "Could not source $INSTALL_VARS_FILE: will assume recovery_mode is false" fi # # Handle the recovery mode case. Note that recovery_mode is FALSE by default. # if [[ "$RECOVERY_MODE" = "TRUE" ]]; then echo "Running in recovery mode." # fix_dev_file_links # add_devfile /dev/nettrace c 46 0x000000 0644 2 2 # add_devfile /dev/netlog c 46 0x000001 0644 2 2 # add_devfile /dev/netman c 60 0x000000 0666 0 1 # add_devfile /dev/ni c 56 0x000000 0666 0 1 # add_devfile /dev/inet_cots c 72 0x00007a 0666 0 1 # add_devfile /dev/inet_clts c 72 0x00007e 0666 0 1 # set_up_Xservers # set_vue_inittab # fix_diags # set_up_audio restore_files rm -rf $ARCHIVE_SAVE_DIR return 0 fi # # Clean up device file links if the archive has this problem. # - commented out because most archives do not contain these devfiles # #fix_dev_file_links # # Add some networking device files. Not needed if they are included in the # archive. # add_devfile /dev/nettrace c 46 0x000000 0644 2 2 add_devfile /dev/netlog c 46 0x000001 0644 2 2 add_devfile /dev/netman c 60 0x000000 0666 0 1 add_devfile /dev/ni c 56 0x000000 0666 0 1 add_devfile /dev/inet_cots c 72 0x00007a 0666 0 1 add_devfile /dev/inet_clts c 72 0x00007e 0666 0 1 # # Set up the Xservers files for this hardware. # set_up_Xservers # # Set up the inittab for VUE on 10.01 series 700 machines. # set_vue_inittab # # Fix a bug in 10.01 series 700 diagnostics if appropriate. # fix_diags # # Make sure the audio server is set up right for this hardware. # set_up_audio # # Touch and set permissions on wtmp and btmp so that login activity is # tracked. In an SD load this would be done by a CORE configure script. # wtmp_btmp_setup # # Fix a minor UPS hole for 800 hardware. Again, normally done by a Core # configure script. # add_ups_line # Restore any files saved in os_arch_post_l. # restore_files # # Remove the temporary save dir. # rm -rf $ARCHIVE_SAVE_DIR # # Exit cleanly. # return 0