#!/usr/bin/ksh # # Copyright(c) 1998, by Sun Microsystems, Inc. # All rights reserved. # # SunLink Server install script # # submitted 10/27/98 # # # Save arg 0 to determine Install script directory later on # Arg0=$0 # # Remove all (unwanted) aliases # unalias -a # # Set PATH for sanity (Sun utilities may behave different from xpg4). # PATH=/sbin:/usr/sbin:/usr/bin # # Prevent the callers umask from altering file mode # umask 0 # # Debug control # debug() { if [ "$DEBUG" ]; then echo "DEBUG: ${*} \n"; fi } alias debugon='DEBUG="ON"' alias debugoff='unset DEBUG' if [ "$exit" ]; then alias exit='echo Would have exited with'; fi PS4='[$LINENO]-> ' # VERBOSE=-v # Trace all of the scripts that get executed by pkgadd # typeset -ft # Function tracing # set -o noexec # Checks syntax but no execution # set -o xtrace # Equiv to doing "set -x" # # For test simulation only. XXX # if [ "${NOEXEC}" ]; then ECHO=echo; else ECHO="" ;fi Arg1="$1" # # Commonly used function for script message localization # pgettext() { # Run gettext with TEXTDOMAINDIR set. gttext=gettext # Trick to fool shxgettext TEXTDOMAINDIR=${Install_Script_Dir}/locale ${gttext} ${textdomain} "$1" } ### textdomain -> Domain that gettext uses to derive the message object name. textdomain=`basename $0` # # Cd to specified directory. An error is fatal. # Chdir() { dir="${1:?}" cd $dir 2>/dev/null; chdir_rval=$? if [ $chdir_rval -ne 0 ] then eval echo "\"`pgettext 'ERROR: Unable to chdir to ${dir}.\n'`\"" eval echo "\"`pgettext ' Current working directory is ${PWD}.\n'`\"" Cleanup \exit $chdir_rval fi } ####### Variable declaration and initialization. ### Locale WOS (wad of stuff) to determine L10N support of JDK and SLS English="en" Japanese="ja" Korean="ko" Simplified_Chinese="zh" Traditional_Chinese="zh_TW" French="fr" Spanish="es" Swedish="sv" German="de" Italian="it" # This value ordering was chosen so the Supported_L10N_Locales[] array # can be used by both Sls and JDK functions which need to know which # locales are supported on the system. typeset -i en=0 typeset -i ja=1 typeset -i ko=2 typeset -i zh=3 typeset -i zh_TW=4 typeset -i fr=5 typeset -i es=6 typeset -i sv=7 typeset -i de=8 typeset -i it=9 typeset Supported_L10N_Locales[10] ### Supported locales on this system. ### Sls Package(s) # # SUNWlznb - netbios driver # # SUNWlzs - Base server package which contains lmx binaries. # # SUNWlzst - server tools # # SUNWlzcl - client # # SUNWlzm - man pages # # SUNWlzac - admin common # # SUNWlzas - admin server # # SUNWlzag - admin gui # # Sls_pkglist - Populated with Sls packages when user selects from Sls menu # ### Sls_NETBIOS_PKG=SUNWlznb Sls_SERVERBASE_PKG=SUNWlzs Sls_SERVERTOOLS_PKG=SUNWlzst Sls_CLIENTTOOLS_PKG=SUNWlzcl Sls_MANPAGES_PKG=SUNWlzm Sls_ADMGUIDE_PKG=SUNWlzd Sls_ADMCOMMON_PKG=SUNWlzac Sls_ADMSERVER_PKG=SUNWlzas Sls_ADMGUI_PKG=SUNWlzag Sls_pkglist=NULL Sls_Packages_To_Remove=NULL Packages_To_Remove=false Sls_JDK_Prereq="" ADMIN_FILE="/tmp/sls.admin.file" Sls_Did_Install=false ### All Sls Packages including those for L10N typeset All_Sls_Packages[] typeset SRV_Sls_Packages[] typeset GUI_Sls_Packages[] All_Sls_Packages[English ]="$Sls_NETBIOS_PKG $Sls_SERVERBASE_PKG $Sls_SERVERTOOLS_PKG $Sls_CLIENTTOOLS_PKG $Sls_MANPAGES_PKG $Sls_ADMGUIDE_PKG $Sls_ADMCOMMON_PKG $Sls_ADMSERVER_PKG $Sls_ADMGUI_PKG" SRV_Sls_Packages[English ]="$Sls_NETBIOS_PKG $Sls_SERVERBASE_PKG $Sls_SERVERTOOLS_PKG $Sls_CLIENTTOOLS_PKG $Sls_MANPAGES_PKG $Sls_ADMGUIDE_PKG $Sls_ADMCOMMON_PKG $Sls_ADMSERVER_PKG" GUI_Sls_Packages[English ]="$Sls_ADMCOMMON_PKG $Sls_ADMGUI_PKG" #All_Sls_Packages[Future Langs ]="SUNWjarsc SUNWjrscj" ### All JDK Packages including those for L10N typeset All_JDK_Packages[10] All_JDK_Packages[English ]="SUNWjvdev SUNWjvrt SUNWjvdem SUNWjvjit SUNWjvman" All_JDK_Packages[Japanese ]="SUNWjjvdv SUNWjjvrt" All_JDK_Packages[Korean ]="SUNWkjvdv SUNWkjvrt" All_JDK_Packages[Simplified_Chinese ]="SUNWcjvdv SUNWcjvrt" All_JDK_Packages[Traditional_Chinese]="SUNWhjvdv SUNWhjvrt" All_JDK_Packages[French ]="SUNWfjvdv SUNWfjvrt" All_JDK_Packages[Spanish ]="SUNWejvdv SUNWejvrt" All_JDK_Packages[Swedish ]="SUNWsjvdv SUNWsjvrt" All_JDK_Packages[German ]="SUNWdjvdv SUNWdjvrt" All_JDK_Packages[Italian ]="SUNWijvdv SUNWijvrt" ### Contains a table of JDK packages to be replaced or installed. typeset JDK_Packages[10] ### Solaris 2.5.1 JDK Patches # # 103566-25 SunOS 5.5.1: X11/OpenWindows patch # 103640-17 SunOS 5.5.1: Kernel patch Solaris_251_OS_Patches="103566-25 103640-17" ### Will be populated with any uninstalled 2.6 Patches from above Unistalled_Solaris_251_OS_Patches="" ### Solaris 2.6 JDK Patches # # 105490-04 SunOS 5.6: Motif runtime library patch # 105284-05 SunOS 5.6: dynamic linker patch Solaris_26_OS_Patches="105490-04 105284-15" ### Will be populated with any uninstalled 2.6 Patches from above Uninstalled_Solaris_26_OS_Patches="" ### Install_Scripts_Dir -> Full path to directory where Install script resides. Install_Script_Dir=`dirname $Arg0 2>/dev/null`; rval=$? if [ $rval -ne 0 -o ! "Install_Script_Dir" ] then pgettext "ERROR: Unable to determine Install scripts directory.\n" exit $rval fi if [[ $Install_Script_Dir = .* ]] then Install_Script_Dir=$PWD elif [[ $Install_Script_Dir != /* ]] then Install_Script_Dir=`dirname $PWD/$Arg0 2>/dev/null`; rval=$? if [ $rval -ne 0 -o ! "Install_Script_Dir" ]; then pgettext "ERROR: Unable to determine Install scripts directory.\n" exit $rval fi fi # Expect it to be a full path if [[ $Install_Script_Dir != /* ]] then pgettext "ERROR: Unable to determine Install scripts directory.\n" exit 10 fi debug "Install_Script_Dir = $Install_Script_Dir" Chdir $Install_Script_Dir # Final paranoid sanity check we're in the Install scripts directory if [ ! -x install_sls ] then eval echo "\"`pgettext '\nERROR: Unable to find install_sls script in ${Install_Script_Dir} directory.\n'`\"" exit 4 fi ### Supported_JDK_version -> Minimum supported version of JDK if [ ! "$Supported_JDK_version" ]; then Supported_JDK_version=116; fi debug "Supported_JDK_version = $Supported_JDK_version" ### Java_Version -> Version of JDK that is installed on this system. Java_Version="" # Initialized in function Is_JDK_Version_Supported(). ### Platform -> Hardware implementation this is executing on. Platform=`uname -i 2>/dev/null`; rval=$? if [ $rval -ne 0 -o ! "$Platform" ] then pgettext "ERROR: Unable to determine platform.\n" exit $rval fi debug "Platform = $Platform" ### Booted_OS -> The operating system (name,release) that is currently booted. OSname=`uname -s 2>/dev/null`; rval=$? if [ $rval -ne 0 -o ! "$OSname" ] then pgettext "ERROR: Unable to determine booted OS name.\n" exit fi # Expect SunOS! if [ $OSname != "SunOS" ] then pgettext "ERROR: Unknown OS name." exit fi if [ "$Booted_OS" ] then OSrelease=${Booted_OS##"${OSname} "} else OSrelease=`uname -r 2>/dev/null`; rval=$? if [ $rval -ne 0 -o ! "$OSrelease" ] then pgettext "ERROR: Unable to determine booted OS release." exit fi Booted_OS="${OSname} ${OSrelease}" fi export OSrelease debug "Booted_OS = $Booted_OS" ### Your_Locale -> The users locale setting # According to setlocale(3C) the order in which the env vars are # checked for the LC_MESSAGES category is first LC_ALL, followed # by LC_MESSAGES and then last by LANG. if [ "$LC_ALL" ] then Your_Locale=$LC_ALL debug "Got your locale $Your_Locale from LC_ALL" elif [ "$LC_MESSAGES" ] then Your_Locale=$LC_MESSAGES debug "Got your locale $Your_Locale from LC_MESSAGES" elif [ "$LANG" ] then Your_Locale=$LANG debug "Got your locale $Your_Locale from LANG" else debug "Unable to determine locale, so set it to C." LC_ALL=C; Your_Locale=$LC_ALL; export LC_ALL LC_MESSAGES=C; Your_Locale=$LC_MESSAGES; export LC_MESSAGES LANG=C; Your_Locale=$LANG; export LANG fi ### Hostname Hostname=`hostname 2>/dev/null`; rval=$? if [ $rval -ne 0 -o ! "$Hostname" ] then Hostname="your system" fi ### ARRAY_SIZE -> Common array size determined from maximum menu items. typeset -i ARRAY_SIZE=6 ### Menu_Item_* -> Menu items are 2-tuple of string and action index # which are populated by Insert_Menu_Item() typeset Menu_Item_Strings[ARRAY_SIZE] typeset Menu_Item_Actions_Index[ARRAY_SIZE] ### Num_Menu_Items -> Current number of menu items. typeset -i Num_Menu_Items=0 ### Indices for Item_Strings[] and Item_Actions[] arrays. #typeset -i JDK_INSTALL=0 typeset -i Sls=0 typeset -i GUI=1 typeset -i BOTH=2 typeset -i EXIT=3 ### Item_Strings -> All possible menu strings typeset Item_Strings[ARRAY_SIZE] #Item_Strings[JDK_INSTALL]="`pgettext 'Install JDK1.1.6 & associated patches (required)'`" Item_Strings[Sls]="`pgettext 'Install server software'`" Item_Strings[GUI]="`pgettext 'Install administration tool'`" #Item_Strings[ALL]="`pgettext 'Install JDK, Sls Server, & Admin GUI'`" Item_Strings[BOTH]="`pgettext 'Install both server software and administration tool'`" Item_Strings[EXIT]="`pgettext 'Exit'`" ### Item_Actions -> All possible menu actions which map 1 to 1 with Item_Strings typeset Item_Actions[ARRAY_SIZE] #Item_Actions[JDK_INSTALL]=JDK_Install Item_Actions[Sls]=Sls_Install Item_Actions[GUI]=Sls_Install #Item_Actions[ALL]=Sls_Install Item_Actions[BOTH]=Sls_Install Item_Actions[EXIT]=Exit_Action ### Action -> Array of actions to be performed typeset Action[ARRAY_SIZE] ### Special reboot action not part of the menu Reboot_Action=NULL ### Did_Install -> Items that were installed Did_Install="" ### Reboot_Required_For_Solaris_Items -> True if reboot is required for OS # patches/updates to take effect. Reboot_Required_For_Solaris_Items=false ### Tested in Sls_Install to determine if jdk prereq needed Installing_Java_Dependent_Package=false # # Alias and Function definitions # alias yes='while : ; do echo yes; sleep 2; done' # Where's the yes command? false_by_default=false alias Success=true alias Failure=false alias Satisfied='echo true; true' # If prerequisite has been satisfied. alias NotSatisfied='echo false; false' if [ "$DEBUG" -o "$SHOWCLEAR" ]; then alias Clear_Screen='echo \\n---------------------- Would have cleared screen here ----------------------\\n' else alias Clear_Screen='clear' fi # # Simple func to determine if an item is in a list # Is_Item_In_List() { Item=$1; shift typeset List[$#] set -A List "$@" typeset -i i=0 while ((i < $#)) do if [ "${List[i]}" = $Item ] then true; return fi ((i+=1)) done false } # # Simple yes or no prompter # Is_Answer_Yes() { while : do read answer ignore_extra_words case "$answer" in ''|y|Y|yes|YES|Yes) true; return ;; n|N|no|NO|No) false; return ;; *) pgettext "Please answer Yes or No: " ;; esac done } # # Corollary of above # Is_Answer_No() { ! Is_Answer_Yes } # # Wait here until the user says their ready to continue # with the rest of the installation. # Prompt_To_Continue() { pgettext "\n\n\nPress RETURN to continue: " read anything } # # Warn the user if a change of language is about to take place. # # Return true if a language change will take place. # Lang_Change_Heads_Up() { if Is_Locale_One_Of "$@" then false; return # No language change will take place. fi pgettext "\n\nWARNING:\n\n" eval echo "\"`pgettext ' Please note that the ${Calling_Procedure} is not localized.\n'`\"" pgettext " Messages will appear in English only.\n" true # A language change will take place } # # Solaris 2.6 prereq for Sls # # Return true if Sls prereq for Solaris 2.6 Patches has been satisfied # Sls_JDK_Prereq_Func() { debug "Sls_Solaris_26_Prereq_Func" Clear_Screen if ( Is_JDK_Needed ) then eval echo "\"`pgettext '\n The installation has determined that ${Hostname} does not have the\n supported Solaris Java Development Environment (JDK 1.1.6).\n'`\"" pgettext "\n"\ " Before you can install SunLink Server administration tool you must\n"\ " upgrade your system to include a supported version of the JDK.\n" pgettext "\n\n\n"\ "Would you like to install JDK1.1.6 and patches now? (y|n) [y]: " if Is_Answer_Yes; then JDK_Install true; return else # Here if the user decided not to install the patches pgettext "\n\n"\ "WARNING: You have chosen not to install the Java Development Environment.\n\n"\ "Installation of SunLink Server cannot proceed until this has been installed.\n" Prompt_To_Continue false; return fi fi } # # Populate a table with the L10N locales that are supported by this system. # Populate_Supported_L10N_Locales() { if [ "$Supported_L10N_Locales" ]; then return fi debug "Populating Supported_L10N_Locales" Supported_L10N_Locales[English]=$English ### Always for locale in $French $Spanish $Swedish $German \ $Italian $Japanese $Korean $Traditional_Chinese do if locale -a | grep "^${locale}" >/dev/null 2>&1 then Supported_L10N_Locales[$locale]=$locale fi done # Need to handle Simplified_Chinese "zh" special so there is no # accidental match with Traditional_Chinese "zh_TW" if locale -a | grep -v "^$Traditional_Chinese" | grep "^$Simplified_Chinese" >/dev/null 2>&1 then Supported_L10N_Locales[Simplified_Chinese]=$Simplified_Chinese fi } # # Determine which JDK packages should be install based on supported locales. # This is called only when the JDK did not exist on the system. # Determine_Which_JDK_Packages_To_Install() { debug "Determining which JDK packages should be installed" if [ "$JDK_Packages" ]; then # Been here already - should not happen return fi for locale in English French Spanish Swedish Simplified_Chinese \ German Italian Japanese Korean Traditional_Chinese do if [ "${Supported_L10N_Locales[$locale]}" ] then JDK_Packages[$locale]=${All_JDK_Packages[$locale]} fi done # debugon #XXX if [ "$DEBUG" ]; then debug "The JDK packages that will be installed are:" for locale in English French Spanish Swedish Simplified_Chinese \ German Italian Japanese Korean Traditional_Chinese do debug "JDK_Packages[$locale] = ${JDK_Packages[$locale]}" done Prompt_To_Continue fi # debugoff #XXX } # # Determine which JDK packages should be replaced. # This is called only when the system has an unsupported # version of the JDK. We replace only what is installed. # Determine_Which_JDK_Packages_To_Replace() { debug "Determining which JDK packages should be replaced" if [ "$JDK_Packages" ]; then # Been here already - should not happen return fi # Iterate through All_JDK_Packages for locale in English French Spanish Swedish Simplified_Chinese \ German Italian Japanese Korean Traditional_Chinese do pkglist="" for pkg in ${All_JDK_Packages[$locale]} do if pkginfo ${pkg} >/dev/null 2>&1 then if [ "${pkglist}" ] then pkglist="${pkglist} ${pkg}" else pkglist=${pkg} fi fi done JDK_Packages[$locale]="${pkglist}" done # debugon #XXX if [ "$DEBUG" ]; then debug "The JDK packages that will be replaced are:" for locale in English French Spanish Swedish Simplified_Chinese \ German Italian Japanese Korean Traditional_Chinese do debug "JDK_Packages[$locale] = ${JDK_Packages[$locale]}" done Prompt_To_Continue fi # debugoff #XXX } Sls_Installation_Msg() { Clear_Screen pgettext "\n\n"\ "SunLink Server 1.0 Installation ... \n\n\n" } # # Action to perform an Sls install # Sls_Install() { debug "In Sls_Install_Action" specifiedInstall="${1}" Sls_pkglist="" Clear_Screen Sls_Dependency_Test $specifiedInstall # # JDK is a pre-req for admin tool # if $Installing_Java_Dependent_Package then if( ! Sls_JDK_Prereq_Func ) then return fi fi # # Determines any Sls packages requiring removal (if any) # if( Is_Sls_Installed ) then Determine_Which_Sls_Packages_To_Replace Sls_Remove fi Sls_Installation_Msg # # The Sls will use this array which contains # the locales that are supported on this system. # Populate_Supported_L10N_Locales # # Populates Sls_pkglist # Populate_Sls_pkglist $specifiedInstall debug "Sls_Install: Sls_pkglist = $Sls_pkglist" Create_AdminFile Chdir ./SLS/sparc typeset -i num_installed=0 typeset did_install[3] for locale in English #French Spanish Swedish Simplified_Chinese \ #German Italian Japanese Korean Traditional_Chinese do for pkg in ${Sls_pkglist[$locale]} do pkgname=${pkg} eval echo "\"`pgettext '\n\tAdding SunLink Server package ${pkgname} ...\n'`\"" if [ "${NOEXEC}" ]; then # XXX rval=0 # XXX else # XXX #output=`yes | pkgadd ${VERBOSE} -d . $pkg 2>&1`; rval=$? pkgadd -a ${ADMIN_FILE} -d . $pkg 2>&1 fi # XXX if [ $rval -eq 0 ] then eval echo "\"`pgettext '\tPackage ${pkgname} has been added.\n'`\"" did_install[num_installed]=${pkgname} ((num_installed+=1)) continue fi eval echo "\"`pgettext '\tERROR: Unable to install the SunLink Server package $pkg.\n'`\"" eval echo "\"`pgettext '\t The pkgadd command exited with ${rval}.\n'`\"" eval echo "\"`pgettext '\nHere is the output from pkgadd:\n${output}\n'`\"" Cleanup exit $rval done done Chdir $Install_Script_Dir # Just prompt and return if nothing was installed. if (( num_installed == 0 )) then Prompt_To_Continue return fi Sls_Did_Install=true #Clear_Screen echo echo echo echo "Successfully installed SunLink Server software.\n" echo echo echo if( Is_Sls_ADMGUI_Installed ) then echo "To further configure the SunLink Server use the slsmgr in\n/opt/lanman/sbin." fi Prompt_To_Continue } # Sls_Install Sls_Dependency_Test() { specifiedInstall="${1}" case "${specifiedInstall:?}" in ${Sls} ) Installing_Java_Dependent_Package=true; false; return ;; ${GUI} ) Installing_Java_Dependent_Package=true; true; return ;; ${BOTH} ) Installing_Java_Dependent_Package=true; true; return ;; *) # specifiedInstall was not one of server, gui, or both debug "Specified install not recognized option." false; return ;; esac } # # Populates a list of Sls packages to install (Sls_pkglist) according to the # supported locales and a single parameter indicating client, server or both. # Populate_Sls_pkglist() { specifiedInstall="${1}" # English must be first since its the base package and for # package dependency checking. for locale in English #French Spanish Swedish Simplified_Chinese \ #German Italian Japanese Korean Traditional_Chinese do if [ "${Supported_L10N_Locales[$locale]}" ] then case "${specifiedInstall:?}" in ${Sls} ) Sls_pkglist[$locale]=${SRV_Sls_Packages[$locale]} true; return ;; ${GUI} ) Sls_pkglist[$locale]=${GUI_Sls_Packages[$locale]} true; return ;; ${BOTH} ) echo "Adding ALL Sls packages to list." Sls_pkglist[$locale]=${All_Sls_Packages[$locale]} true; return ;; *) # specifiedInstall was not one of server, gui, or both debug "Specified install not recognized option." false; return ;; esac fi done # debugon #XXX if [ "$DEBUG" ]; then debug "The Sls packages that will be installed are:" for locale in English French Spanish Swedish Simplified_Chinese \ German Italian Japanese Korean Traditional_Chinese do debug "Sls_pkglist." done Prompt_To_Continue fi # debugoff #XXX } # Populate_Sls_pkglist # # Determine which SLS packages should be replaced. # This is called only when the system has an unsupported # version of the SLS. We replace only what is installed. # Determine_Which_Sls_Packages_To_Replace() { debug "Determining which SLS packages should be replaced" # Iterate through All_Sls_Packages for locale in English French Spanish Swedish Simplified_Chinese \ German Italian Japanese Korean Traditional_Chinese do pkglist="" for pkg in ${All_Sls_Packages[$locale]} do if pkginfo ${pkg} >/dev/null 2>&1 then if [ "${pkglist}" ] then pkglist="${pkglist} ${pkg}" else pkglist=${pkg} fi fi done Sls_Packages_To_Remove[$locale]=${pkglist[$locale]} done } Sls_Remove() { Clear_Screen echo echo echo echo "Removing previously installed SunLink Server Packages...\n" for locale in English# French Spanish Swedish Simplified_Chinese \ #German Italian Japanese Korean Traditional_Chinese do if [ ! "${Sls_Packages_To_Remove[$locale]}" ] then continue # with next locale fi for pkg in ${Sls_Packages_To_Remove[$locale]} do eval echo "\"`pgettext '\n\tRemoving SunLink Server package $pkg ...\n'`\"" if [ "${NOEXEC}" ]; then # XXX rval=0 # XXX else # XXX output=`yes | pkgrm $pkg 2>&1`; rval=$? fi # XXX if [ $rval -eq 0 ]; then eval echo "\"`pgettext '\tPackage $pkg was removed.\n'`\"" continue # with next pkg fi eval echo "\"`pgettext '\tERROR: Unable to remove package $pkg.\n'`\"" eval echo "\"`pgettext '\t The pkgrm command exited with ${rval}.\n'`\"" eval echo "\"`pgettext '\nHere is the output from pkgrm:\n${output}\n'`\"" Chdir $Install_Script_Dir Failure; return done done pgettext "\n\n"\ "Successfully removed the previously installed SunLink Server packages.\n" Prompt_To_Continue Success } ## # create_adminfile() - the file that creates non-interactive install checks ## Create_AdminFile() { /usr/bin/rm -f ${ADMIN_FILE} cat >${ADMIN_FILE} <${PKGRM_ADMIN} <&1`; rval=$? if [ $rval -eq 0 ] then eval echo "\"`pgettext '\tPatch $patch has been added.\n'`\"" continue fi eval echo "\"`pgettext '\tERROR: Could not apply patch $patch.\n'`\"" eval echo "\"`pgettext '\t The installpatch script exited with ${rval}.\n'`\"" eval echo "\"`pgettext '\nHere is the output from installpatch:\n${output}\n'`\"" Cleanup exit $rval done fi pgettext "\n\n"\ "Successfully applied the Solaris 2.5.1 JDK Patches.\n" fi Chdir $Install_Script_Dir if [ "${Uninstalled_Solaris_251_OS_Patches}" ] then pgettext "\n\n"\ "Please note that the Solaris 2.5.1 Patches will not take effect\n"\ "until the next system reboot.\n" Prompt_To_Continue fi } # Sol_251_Patches_Install # # Actions to perform when the 'Solaris 2.6 Patches' menu item is selected. # Sol_26_Patches_Install() { debug "In Sol_26_Patches_Install" Clear_Screen pgettext "\n\nApplying required Solaris 2.6 Patches for JDK 1.1.6\nthis will take a few minutes...\n\n" Chdir ./Patches/JDK_Patches/sparc/2.6 # # Install any OS patches # Are_Solaris_26_Patches_Needed if( Are_Solaris_26_Patches_Needed ) then if [ "${Uninstalled_Solaris_26_OS_Patches}" ] then for patch in ${Uninstalled_Solaris_26_OS_Patches} do eval echo "\"`pgettext '\n\tInstalling patch $patch ...\n'`\"" output=`${ECHO} $patch/installpatch $patch 2>&1`; rval=$? if [ $rval -eq 0 ] then eval echo "\"`pgettext '\tPatch $patch has been added.\n'`\"" continue fi eval echo "\"`pgettext '\tERROR: Could not apply patch $patch.\n'`\"" eval echo "\"`pgettext '\t The installpatch script exited with ${rval}.\n'`\"" eval echo "\"`pgettext '\nHere is the output from installpatch:\n${output}\n'`\"" Cleanup exit $rval done fi pgettext "\n\n"\ "Successfully applied the Solaris 2.6 JDK Patches.\n" fi Chdir $Install_Script_Dir if [ "${Uninstalled_Solaris_26_OS_Patches}" ] then pgettext "\n\n"\ "Please note that the Solaris 2.6 Patches will not take effect\n"\ "until the next system reboot.\n" Prompt_To_Continue fi } # Sol_26_Patches_Install # # Reboot for Solaris 2.6 Patches to take effect # Reboot_After_Install() { pgettext "\n"\ "In order for the previously installed software to take affect ${Hostname} must"\ "\nbe rebooted.\n\n" pgettext "\n\n"\ "Would you like to reboot the system at this time? (y|n) [y]: " if Is_Answer_Yes; then echo "Initiating reboot in 5 seconds to activate the software\n"\ "installed from SunLink Server 1.0 CD ...\n\n\n\n" sleep 5 # Give some time to stop reboot reboot pgettext "\nERROR: reboot failed!!\n" Cleanup \exit 1 else pgettext "WARNING: You have chosen not to reboot the system at this time. Please be\n"\ "aware that the SunLink Server software will not take effect until the system is\n"\ "rebooted.\n" Cleanup \exit 1 fi } # Reboot_After_Install # # Actions to perform when the 'Exit' menu item is selected # or at the end of main. # Exit_Action() { debug "In Exit_Action" # Congratulate if they installed something. if ( $Sls_Did_Install ) then Clear_Screen pgettext "\n\n\n"\ "\t\t\t *** CONGRATULATIONS *** \n\n"\ "\n"\ " You have successfully installed the selected items from the\n"\ " SunLink Server 1.0 CD!\n\n\n" if ( Is_Booted_OS "Solaris 2.5.1" ) then Reboot_Required_For_Solaris_Items=Are_Solaris_251_Patches_Needed fi if ( Is_Booted_OS "Solaris 2.6" ) then Reboot_Required_For_Solaris_Items=Are_Solaris_251_Patches_Needed fi if ( $Reboot_Required_For_Solaris_Items ) then Reboot_After_Install fi else # Nothing was installed if [ "$Reboot_Action" != "NULL" ] then eval echo "\"`pgettext 'ERROR: Nothing was installed yet reboot action is set to ${Reboot_Action}!!\n'`\"" exit 1 fi pgettext "\n\n\n"\ "You have not installed any items from the SunLink Server 1.0 software.\n" fi pgettext "\n\n"\ "Exiting SunLink Server 1.0 installation.\n\n" \exit 0 } # Exit_Action # # Determine if the installed JDK is a supported version. # # Returns true if it is supported (version is >= Supported_JDK_version). # # Is_JDK_Version_Supported() { OIFS="$IFS" IFS="\.\"" && set `/usr/bin/java -version 2>&1` IFS="$OIFS" typeset -i major=$2 typeset -i minor=$3 typeset -i point=$4 Java_Version="$2.$3.$4" # Version that's installed on this system if ((100*major + 10*minor + point < Supported_JDK_version)) then debug "JDK version unsupported ($major.$minor.$point)" false; return else debug "JDK version okay ($major.$minor.$point)" true; return fi } Is_JDK_Needed() { # Check if the JDK is installed and is a supported version. # Solaris 2.6 systems may have an old version. if [ -x /usr/bin/java ]; then if ( Is_JDK_Version_Supported ); then false; return # JDK prereq is satisfied else true; fi else true; return fi } # # Remove old unsupported version of JDK # JDK_Remove() { debug "In JDK_Remove" Clear_Screen eval echo "\"`pgettext '\n\nRemoving unsupported Solaris Java Development environment (JDK ${Java_Version}) ...\n\n\n'`\"" for locale in English French Spanish Swedish Simplified_Chinese \ German Italian Japanese Korean Traditional_Chinese do if [ ! "${JDK_Packages[$locale]}" ] then continue # with next locale fi for pkg in ${JDK_Packages[$locale]} do eval echo "\"`pgettext '\n\tRemoving JDK package $pkg ...\n'`\"" if [ "${NOEXEC}" ]; then # XXX rval=0 # XXX else # XXX output=`yes | pkgrm $pkg 2>&1`; rval=$? fi # XXX if [ $rval -eq 0 ]; then eval echo "\"`pgettext '\tPackage $pkg was removed.\n'`\"" continue # with next pkg fi eval echo "\"`pgettext '\tERROR: Unable to remove package $pkg.\n'`\"" eval echo "\"`pgettext '\t The pkgrm command exited with ${rval}.\n'`\"" eval echo "\"`pgettext '\nHere is the output from pkgrm:\n${output}\n'`\"" Chdir $Install_Script_Dir Failure; return done done pgettext "\n\n"\ "Successfully removed the unsupported Java Development environment.\n" Prompt_To_Continue Success } # JDK_Remove # # Install supported version of JDK using package names # in the JDK_Packages array. # JDK_Install() { debug "In JDK_Install" Clear_Screen # # Test here to prevent repeat installs # if( Is_JDK_Needed ) then # Install required OS patches for JDK 1.1.6 depending upon # whether OS is 2.5.1 or 2.6 if ( Is_Booted_OS "Solaris 2.5.1" ) then if( Are_Solaris_251_Patches_Needed ) then Reboot_Required_For_Solaris_Items=true; Sol_251_Patches_Install fi elif( Is_Booted_OS "Solaris 2.6" ) then if( Are_Solaris_26_Patches_Needed ) then Sol_26_Patches_Install Reboot_Required_For_Solaris_Items=true; fi fi Populate_Supported_L10N_Locales JDK_Packages="" # Test to see if java exists, if it does we already know it is pre 1.1.6 # Calls to Determine_Which... populates pkg_list depending upon # whether or not java was installed previously. # remove old packages. if [ -x /usr/bin/java ]; then Determine_Which_JDK_Packages_To_Replace JDK_Remove else Determine_Which_JDK_Packages_To_Install fi Clear_Screen pgettext "\n\n"\ "Installing supported Solaris Java Development environment (JDK 1.1.6) ...\n\n" Chdir ./JDK_1.1.6/sparc for locale in English #French Spanish Swedish Simplified_Chinese \ #German Italian Japanese Korean Traditional_Chinese do for pkg in ${JDK_Packages[$locale]} do eval echo "\"`pgettext '\n\tAdding JDK package $pkg ...\n'`\"" if [ "${NOEXEC}" ]; then # XXX rval=0 # XXX else # XXX output=`yes | pkgadd ${VERBOSE} -d . $pkg 2>&1`; rval=$? fi # XXX if [ $rval -eq 0 ] then eval echo "\"`pgettext '\tPackage $pkg has been added.\n'`\"" continue # with next pkg fi eval echo "\"`pgettext '\tERROR: Unable to install the JDK package $pkg.\n'`\"" eval echo "\"`pgettext '\t The pkgadd command exited with ${rval}.\n'`\"" eval echo "\"`pgettext '\nHere is the output from pkgadd:\n${output}\n'`\"" Chdir $Install_Script_Dir Failure; return Chdir .. # done done Chdir $Install_Script_Dir echo echo echo echo "Successfully installed the Solaris Java Development Environment (version 1.1.6).\n" Prompt_To_Continue Success fi } # JDK_Install # # Returns true if the Sls admin gui package has been installed # Is_Sls_ADMGUI_Installed(){ if pkginfo ${Sls_ADMGUI_PKG} >/dev/null 2>&1 then debug "Is_Sls_ADMGUI_PKG_Installed : true" true; return; else debug "Is_Sls_ADMGUI_PKG_Installed : false" false; return; fi } # # Returns true if the Sls admin server package has been installed # Is_Sls_ADMSERVER_Installed(){ if pkginfo ${Sls_ADMSERVER_PKG} >/dev/null 2>&1 then debug "Is_Sls_ADMSERVER_PKG_Installed : true" true; return; else debug "Is_Sls_ADMSERVER_PKG_Installed : false" false; return; fi } # # Returns true if the Sls admin common package has been installed # Is_Sls_ADMCOMMON_Installed(){ if pkginfo ${Sls_ADMCOMMON_PKG} >/dev/null 2>&1 then debug "Is_Sls_ADMCOMMON_PKG_Installed : true" true; return; else debug "Is_Sls_ADMCOMMON_PKG_Installed : false" false; return; fi } # # Returns true if the Sls admin guide package has been installed # Is_Sls_ADMGUIDE_Installed(){ if pkginfo ${Sls_ADMGUIDE_PKG} >/dev/null 2>&1 then debug "Is_Sls_ADMGUIDE_PKG_Installed : true" true; return; else debug "Is_Sls_ADMGUIDE_PKG_Installed : false" false; return; fi } # # Returns true if the Sls man pages package has been installed # Is_Sls_MANPAGES_Installed(){ if pkginfo ${Sls_MANPAGES_PKG} >/dev/null 2>&1 then debug "Is_Sls_MANPAGES_PKG_Installed : true" true; return; else debug "Is_Sls_MANPAGES_PKG_Installed : false" false; return; fi } # # Returns true if the Sls client tools package has been installed # Is_Sls_CLIENTTOOLS_Installed(){ if pkginfo ${Sls_CLIENTTOOLS_PKG} >/dev/null 2>&1 then debug "Is_Sls_CLIENTTOOLS_PKG_Installed : true" true; return; else debug "Is_Sls_CLIENTTOOLS_PKG_Installed : false" false; return; fi } # # Returns true if Sls server tools package has been installed # Is_Sls_SERVERTOOLS_Installed(){ if pkginfo ${Sls_SERVERTOOLS_PKG} >/dev/null 2>&1 then debug "Is_Sls_SERVERTOOLS_PKG_Installed : true" true; return; else debug "Is_Sls_SERVERTOOLS_PKG_Installed : false" false; return; fi } # # Returns true if Sls server base has been installed # Is_Sls_SERVERBASE_Installed() { if pkginfo ${Sls_SERVERBASE_PKG} >/dev/null 2>&1 then debug "Is_Sls_SERVERBASE_PKG_Installed : true" true; return; else debug "Is_Sls_SERVERBASE_PKG_Installed : false" false; return; fi } # # Returns true if Sls netbios package has been installed # Is_Sls_NETBIOS_Installed() { if pkginfo ${Sls_NETBIOS_PKG} >/dev/null 2>&1 then debug "Is_Sls_NETBIOS_PKG_Installed : true" true; return; else debug "Is_Sls_NETBIOS_PKG_Installed : false" false; return; fi } # # Returns true if Sls is installed - # Is_Sls_Installed() { debug "Is_Sls_Installed" if (Is_Sls_NETBIOS_Installed || Is_Sls_SERVERBASE_Installed || Is_Sls_SERVERTOOLS_Installed || Is_Sls_CLIENTTOOLS_Installed || Is_Sls_MANPAGES_Installed || Is_Sls_ADMGUIDE_Installed || Is_Sls_ADMCOMMON_Installed || Is_Sls_ADMSERVER_Installed || Is_Sls_ADMGUI_Installed) then true; return else false; return fi } # # Returns true if Solaris 2.5.1 JDK patches have not been installed. # # If any of the following patches are not installed the # user will be allowed to choose 'Solaris 2.5.1 Patches' from the menu. # # Patch 103566-02 (X11OWPATCH) # Patch 103640-17 (KERNELPATCH) if and only if package SUNWvts is installed. # Are_Solaris_251_Patches_Needed() { if [ "$OS_OK" ]; then false; return; fi # For test only. # Check for existence of "Solaris 2.5.1 patches" for patch in $Solaris_251_OS_Patches do if ! showrev -p | grep $patch >/dev/null 2>&1 then Uninstalled_Solaris_251_OS_Patches="$patch $Uninstalled_Solaris_251_OS_Patches" else debug "Solaris 2.5.1 $patch already installed" fi done debug "Sol 2.5.1 OS patches needed: $Uninstalled_Solaris_2.5.1_OS_Patches" if [ "$Uninstalled_Solaris_251_OS_Patches" ] then # The Solaris 2.5.1 OS patches are a prerequisite to installing JDK. JDK_OS_Prereq=Sls_Solaris_26_Prereq_Func true; return fi # No 2.5.1 updates are needed since they've all been installed debug "2.5.1 updates are not necessary" false; return } # Are_Solaris_251_Updates_Needed # # Returns true if Solaris 2.6 patches have not been not installed # and populates "Uninstalled_Solaris_26_OS_Patches". # # Patch 105460-04 (dynamic linker patch) # Patch 105284-15 (motif runtime library patch) # Are_Solaris_26_Patches_Needed() { Uninstalled_Solaris_26_OS_Patches="" if [ "$OS_OK" ]; then false; return # For test only. XXX fi # Check for existence of "Solaris 2.6 patches" for patch in $Solaris_26_OS_Patches do if ! showrev -p | grep $patch >/dev/null 2>&1 then Uninstalled_Solaris_26_OS_Patches="$patch $Uninstalled_Solaris_26_OS_Patches" else debug "Solaris 2.6 $patch already installed" fi done debug "Sol 2.6 OS patches needed: $Uninstalled_Solaris_26_OS_Patches" if [ "$Uninstalled_Solaris_26_OS_Patches" ] then # The Solaris 2.6 OS patches are a prerequisite to installing JDK. JDK_OS_Prereq=Sls_Solaris_26_Prereq_Func true; return fi false; return } # Are_Solaris_26_Patches_Needed # # Is this script executing on target platform? # On_Target_Platform() { # Allow for multiple target platforms by using 'case' construct. case ${Platform:?} in $Target_Platform) debug "Is running on target platform $Target_Platform" true; return ;; *) debug "Is NOT running on target platform $Target_Platform" false; return ;; esac } # # Is this script executing on specified OS release # Is_Booted_OS() # the specified OS (arg1) { specifiedOS="${1}" case "${specifiedOS:?}" in ${Booted_OS} ) # Exact match SunOS X.Y.Z e.g. "SunOS 5.5.1" debug "Booted OS is ${specifiedOS}" true; return ;; # Allow Solaris X.Y.Z equivalent e.g. "Solaris 2.5.1" "Solaris 2"${Booted_OS#"SunOS 5"} ) debug "Booted OS is ${specifiedOS}" true; return ;; *) debug "Booted OS ${Booted_OS} is NOT ${specifiedOS}" false; return ;; esac } # # Is this script executing on OS release level >= release level of specified OS # Is_Booted_OS_Greater_Or_Equal() # the specified OS (arg1) { typeset -i specifiedRel[3] typeset -i bootedRel[3] set -A specifiedRel 0 0 0 set -A bootedRel 0 0 0 typeset -i comp=0 ## component iteration variable specifiedOS="${1}" OIFS="$IFS" IFS=\. && set -A specifiedRel ${specifiedOS#"Solaris"} IFS=\. && set -A bootedRel "2"${Booted_OS#"SunOS 5"} IFS="$OIFS" # Compare most significant component first: 'X', then 'Y', then 'Z' while ((comp < 3)) do if [ ${bootedRel[comp]=0} -lt ${specifiedRel[comp]=0} ]; then debug "Booted rel ${bootedRel[*]} < ${specifiedRel[*]}" false; return elif [ ${bootedRel[comp]=0} -gt ${specifiedRel[comp]=0} ]; then break fi ((comp+=1)) done debug "Booted rel ${bootedRel[*]} >= ${specifiedRel[*]}" true; return # Booted OS release is >= to specified OS release } # # Check if the calling user is root. # # boolean_t Is_Super_User() { if [ ! "$userId" ] then userId=`id 2>/dev/null`; rval=$? if [ $rval -ne 0 -o ! "$userId" ] then pgettext "ERROR: Unable to determine user id.\n" Cleanup exit $rval fi fi # # Using "%% *" removes the "gid=..." and "groups=..." from the output. # test ${userId%% *} = "uid=0(root)" } # # Returns true if your locale is found in the argument list # Is_Locale_One_Of() # locale1 locale2 locale3 ... { debug "In Is_Locale_One_Of: locale arg list is: \"$*\"" for supported_locale in "$@" do # Check for an exact match first: i.e. "en" = "en" if [ $Your_Locale = $supported_locale ] then debug "Exact match your locale with $supported_locale" true; return fi # Using KSH substring parameter expansion (pattern matching) # this essentially does a "string N compare" of your locale with # the supported_locale, where N is the string length of # supported_locale. # # For example, the locale "fr" will match Your_Locale "fr" or # "fr_BE" or "fr_CA", etc. # "##" says starting from the left side remove the # largest matching pattern: "fr_CA" ## "fr" => "_CA" pattern=${Your_Locale##${supported_locale}} # Getting an null pattern should be impossible, but ... if [ ! "$pattern" ]; then continue; fi if [ "${Your_Locale%%$pattern}" = $supported_locale ] then debug "Pattern match your locale with $supported_locale" true; return fi done # Get here if your locale is not in supported locale argument list debug "Your locale $Your_Locale is not one of $*" false; return } # Is_Locale_One_Of # # Insert an item into "Menus" keeping track of the number of items. # Insert_Menu_Item() { typeset -i index index="${1:?}" Menu_Item_Strings[Num_Menu_Items]=${Item_Strings[$index]} # Maintain a mapping of the menu items to indices (Sls, GUI, EXIT,...) Menu_Item_Actions_Index[Num_Menu_Items]=$index ((Num_Menu_Items+=1)) } ## Create customized install menu based on HW and SW # # First_Time_Calling_Create_Menu=true # # Create_Menu() { typeset -i dont_count=1 # Number of menu items that shouldn't be # counted as installable i.e. EXIT, ALL, BOTH. Num_Menu_Items=0 if ( Is_Booted_OS "Solaris 2.5.1" || Is_Booted_OS "Solaris 2.6" || Is_Booted_OS "Solaris 2.7" ) then Insert_Menu_Item $Sls Insert_Menu_Item $GUI Insert_Menu_Item $BOTH Insert_Menu_Item $EXIT else # Not on a system running 2.5.1, 2.6, 2.7 exit pgettext "ERROR: Unsupported OS version for SunLink Server software.\n" Cleanup exit 8 fi debug "Create_Menu: Num_Menu_Items = $Num_Menu_Items" } # Create_Menu # # Have user select a menu item from Menu_Item_Strings[] # # Make a note if select has ever been called for screen title and clear handling # First_Time_Calling_Select_Menu_Item=true # Select_Menu_Item() { typeset -i num_actions=0 # Current number of actions in the Action array typeset -i index # Array index iteration variable debug "In Select_Menu_Item" # Initialize Action array while ((index < ARRAY_SIZE)) do Action[index]=NULL ((index+=1)) done if $First_Time_Calling_Select_Menu_Item then First_Time_Calling_Select_Menu_Item=false else Clear_Screen pgettext "\n\n\t\t\tSunLink Server 1.0 Installation Utility\n\n" fi while : # Display Menu Loop N=2 do # # Display Menu # typeset -i number index=0 while ((index < Num_Menu_Items)) do number=index+1 eval echo "\"`pgettext '\n\t${number}) ${Menu_Item_Strings[$index]}'`\"" ((index+=1)) done while : # Prompt Loop N=1 do # # Get the user to enter a selection from the Menu # pgettext "\n\nPlease enter a number and press RETURN: " read answer ignore_extra_words case "$answer" in [1-$Num_Menu_Items]) ### A valid choice ((answer-=1)) index=${Menu_Item_Actions_Index[$answer]} #if (( index == ALL || index == BOTH )) #then # # Populate array of actions to be performed # # while ((num_actions < Num_Menu_Items)) # do # Retrieve index value of action (e.g. like RSC) # index=${Menu_Item_Actions_Index[num_actions]} # Save the actions to be performed. # But don't include EXIT, ALL or BOTH # if (( ! (index == EXIT || index == ALL || index == BOTH) )) # then # Action[index]=${Item_Actions[index]} # fi # ((num_actions+=1)) # done # else Action[index]=${Item_Actions[index]} debug "Action[index] = ${Item_Actions[index]}" num_actions=1 # fi ;; "") ### Eat returns continue 1 # Continue with Prompt Loop N=1 ;; *) ### Bad answer eval echo "\"`pgettext '\n${answer} is an invalid selection. Please try again.\n'`\"" continue 2 # Continue with Display Menu Loop N=2 ;; esac # of case answer # Get here only if user entered a valid answer debug "num_actions = $num_actions" break 2 # Break out of Prompt Loop and Display Menu Loop N=2 done # for Prompt Loop N=1 done # for Display Menu Loop N=2 } # Select_Menu_Item # # Execute the action(s) associated with the selected menu items # Exec_Selected_Items_Action() { typeset -i index=0 while ((index < ARRAY_SIZE)) do debug "${Action[index]} = ${Action[index]}" if [ "${Action[index]}" != "NULL" ] then ${Action[index]} $index fi ((index+=1)) done } # # Just exit if there's nothing that can be installed. # Exit_If_Nothing_To_Install() { if ((Num_Menu_Items == 0)) then # Nothing to install. pgettext "\n"\ "The installation script has determined that your system is up to date.\n"\ "\n"\ "All of the items which can be installed through the SunLink Server 1.0 CD\n"\ "installation script have already been installed.\n"\ "\n" \exit 0 fi } # # Cleanup if exiting abnormally or interrupted. # Cleanup() { if( false ) then echo "This shouldn't have been called." fi } # # Trap here on signals # Sig_Handler() { exit_code=$? Cleanup \exit ${exit_code} } # # welcome message # Welcome_Msg() { Clear_Screen pgettext "\n\n\n"\ " SunLink Server 1.0 Installation Utility\n\n" } ### XXX For test only Show_Test_Env() { echo echo "Listing of this Install script's environment variables used" echo "for test simulation:" echo echo "DEBUG=ON \\" echo " If set, debug statements are printed and screens are not cleared" echo echo "SHOWCLEAR=ON \\" echo " If set, screens are not cleared, but instead dashed lines are" echo " printed to indicate where screen breaks would've taken place" echo echo "NOEXEC=ON \\" echo " If set, some commands are echoed instead of being executed." echo " Used for preventing unwanted reboots and working around package" echo " command failures due to the simulated test environment" echo echo "OS_OK=true \\" echo " If set to true, script behaves as if OS already has patches/updates" echo echo "exit=OFF \\" echo " If set, script doesn't exit but prints what it would've exited with" echo echo "Supported_JDK_version=116 \\" echo " If set, script treats value as minimum supported version of the" echo " JDK necessary for Sls. Will force a JDK update, with this value" echo echo "Booted_OS=\"SunOS 5.6\" \\" echo " If set to this value, script behaves as if running on Solaris 2.6" echo echo "Booted_OS=\"SunOS 5.5.1\" \\" echo " If set to this value, script behaves as if running on Solaris 2.5.1" echo echo "./Install" echo " Is the normal invocation - no args" echo \exit } ### XXX For test only main() { trap Sig_Handler INT QUIT TERM if ! Is_Super_User then pgettext "\n"\ "You must be root to execute the installation script for the\n"\ "SunLink Server 1.0 install.\n" exit 5 fi Welcome_Msg ### Create menu based on SW/HW config, populates Num_Menu_Items. Create_Menu Exit_If_Nothing_To_Install # Loop as long as there are items left to be installed. while ((Num_Menu_Items > 0)) do ### Prompt installer to pick an item from the menu. Select_Menu_Item ### Execute the action associated with the selected menu item. Exec_Selected_Items_Action ### Now create a new menu with the remaining options. Create_Menu done Exit_Action } if [ "$Arg1" = "-s" ]; then Show_Test_Env; fi #XXX For test only, to be deleted. #### Call to main ##### main