#!/bin/bash #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # Copyright 2008 by Sun Microsystems, Inc. # # You can redistribute and/or modify this script under the terms of the # GNU Lesser General Public License version 3 only, as published by # the Free Software Foundation. # # This script is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License version 3 for more details # # A copy of the GNU Lesser General Public License version 3 is available # from http://www.gnu.org/licenses/lgpl.html #************************************************************************* # script defined global variables. ws7_statefile="/tmp/ws7-ini.$$" user="`whoami`" hostname="`hostname`" domainname="`domainname`" host="" if [ -z "$hostname" ]; then echo "hostname command failed to return a valid hostname." exit 1; fi if [ -z "$domainname" ]; then host=$hostname else host="${hostname}.${domainname}" fi # user defined global variables # Feel free to customize these values to change the install location # server runtime user ws7_installroot="" # Administration Server hostname, SSL port, user name, runtime user # default password. Feel free to change it you as you see fit. ws7_adminhost="$host" ws7_adminport="8989" ws7_adminuser="admin" ws7_adminpwd="adminadmin" ws7_nodehost="$hostname" ws7_nodeport="8989" # If you would like to install the server as node (in cluster mode), # then you will need to change the below value to 'node'. ws7_admintype="server" # If you are installing the server as 'root', then you can automatically # configure web server to start on boot as well as create SMF (Solaris) # If you run this script as 'root', then this script will assume that # you would like to install as non root user (webservd) , create SMF(solaris) # as well as start on boot. # If don't want to run it as root, then you will need to change # the below values appropriately. if [ "$user" = "root" ]; then ws7_uid="webservd" ws7_adminuid="root" ws7_startOnBoot="True" ws7_createService="True" else ws7_uid="$user" ws7_adminuid="$user" ws7_startOnBoot="False" ws7_createService="False" fi # Customize if you want to use a different JDK ws7_use_customjdk="False" # Set this to true if you would like to use a say JDK 6 ws7_customjdk="" # Provide the location of a different JDK available on system. # On OpenSolaris, we will always use custom JDK available under /usr/jdk/latest if [ "`uname -s`" = "SunOS" ] && [ "`uname -r`" = "5.11" ] then ws7_use_customjdk="True" ws7_customjdk="/use/jdk/latest" fi # Making this below variable to false will simply install web server 7 binaries. # Users will need to now manually configure the instances by appropriately filling the # configureServer.properties file found under $ws7_installroot/setup directory. ws7_configureLater="True" # this script will assume that all the necessary templates and scripts # reside in the same directory. function usage { echo "This program will non interactively layout Web Server 7 binaries" echo "Usage: $0 [location of ws7 'setup' script] [ ws7 installation location ] (installation mode (server|node))" echo "" echo "Example: To install Web Server 7 on current machine as admin server" echo "$0 /sun/webserver7" echo "" echo "Example: To install Web Server 7 on current machine as admin node" echo "$0 /sun/webserver7 node" echo "" exit 1 } # Validate input arguments. # Specify the unpacked location of downloaded web server 7 tar ball. ws7_scriptroot="$1" if [ -z "$ws7_scriptroot" ] then usage fi # Specify the location to install ws7 binaries. ws7_installroot="$2" if [ -z "$ws7_installroot" ] then usage fi # See if user wanted to customize the admin mode installation. if [ -n "$3" ] then if [ "$3" = "server" ] || [ "$3" = "node" ]; then ws7_admintype="$3" fi fi if [ ! -d "${ws7_scriptroot}" ] then echo "Unable to find Web Server 7 'setup' script under $ws7_scriptroot" echo "" usage exit 1 fi if [ ! -f "${ws7_scriptroot}/setup" ] then echo "Unable to find Web Server 7 'setup' script under $ws7_scriptroot" echo "" usage exit 1 fi if [ -d "$ws7_installroot" ] then if [ ! -x "$ws7_installroot/lib/webservd" ] then echo "Error:Directory: '$ws7_installroot' does not seems to be valid Web Server 7 location" echo " Need to provide a non existent directory for a fresh Web Server 7 installation" echo " or a valid Web Server 7 installation location to upgrade." exit 1 fi fi if [ "$ws7_admintype" = "server" ] then IS_ADMIN_NODE="False" else IS_ADMIN_NODE="True" fi # get the current working directory. if echo $0 | grep -v '^/' > /dev/null 2>&1; then cwd=`pwd` else cwd="`echo $0 | sed 's,/[^/]*$,,'`" fi cwd=`pwd` err_log="$cwd/ws7-error.log" # now, let us get the id for this machine. setup_id="`${ws7_scriptroot}/setup --id`" echo " [STATE_BEGIN Sun Java System Web Server $setup_id] SELECTED_COMPONENTS = svrcore,svrcore64,admincli,devsupport,admincli_l10n,svrcore_l10n defaultInstallDirectory = $ws7_installroot currentInstallDirectory = $ws7_installroot USE_BUNDLED_JDK = $ws7_use_customjdk JDK_LOCATION = $ws7_customjdk IS_ADMIN_NODE = $IS_ADMIN_NODE STARTUP_ONBOOT = $ws7_startOnBoot CREATE_SERVICE = $ws7_createService ADMIN_HOST = $ws7_adminhost ADMIN_SSL_PORT = $ws7_adminport ADMIN_PORT = ADMIN_UID = $ws7_adminuid ADMIN_NAME = $ws7_adminuser ADMIN_PASSWD = $ws7_adminpwd NODE_HOST = $ws7_nodehost NODE_SSL_PORT = $ws7_nodeport REGISTER_NODE = False WEB_SERVERNAME = WEB_PORT = WEB_UID = $ws7_uid WEB_DOCROOT = SIXTYFOURBIT_INSTALL = True SKIP_INSTANCE_CREATION = True CONFIG_NAME = $host CONFIGURE_LATER = $ws7_configureLater [STATE_DONE Sun Java System Web Server $setup_id] " >| $ws7_statefile echo "Starting installation of Web Server 7 binaries, please wait..." # now invoke the installer ${ws7_scriptroot}/setup --silent $ws7_statefile >> $err_log 2>&1 status=$? if [ $status -ne 0 ] then echo "Warning: Installation failed to complete successfully." echo "Please look at '$err_log' for the error and try to rectify the error." exit 1 else echo "Installation completed successfully." fi if [ "$ws7_configureLater" = "False" ] then if [ -d "$ws7_installroot/admin-server" ]; then echo "Stating the administration server cum nodes..." "$ws7_installroot"/admin-server/bin/startserv status=$? if [ $status -ne 0 ] then echo "Unable to successfully start the administration server / nodes." exit 1 else echo "Successfully started the administration server and nodes." fi fi else echo "Web Server 7 has successfully completed laying out binaries under '$ws7_installroot' directory." echo "" echo "If you would like to non interactively complete Web Server 7 configuration, you will need to " echo "manually edit 'configureServer.properties' found under '$ws7_installroot/setup/' directory and " echo "provide a administration password and then run 'configureServer script found under " echo "'$ws7_installroot/lib' directory. " echo "" echo "If administration password is not provided within 'configureServer.properties' file,then 'configureServer' " echo "script will prompt for administration password " echo "" echo "To successfully complete configuring Web Server 7 administration and server instance, run the following" echo "command :" echo "$ws7_installroot/lib/configureServer -inputfile $ws7_installroot/setup/configureServer.properties -verbose -logfile $ws7_installroot/setup/config.log " echo "" fi # now if the user is running as root and OS is Solaris 10, # we could configure the admin user id and web server user id # to run as non root. OS="`uname -s`" OS_VER="`uname -r`" if [ "$ws7_uid" != "root" ] && [ "$OS" = "Solaris" ] then if [ `echo $OS_VER | sed s/\\\.//` -ge 510 ] then echo "Enabling the $ws7_uid to run and bind at port 80 as 'non root' " /usr/sbin/usermod -K defaultpriv=basic,net_privaddr $ws7_uid fi fi