#!/bin/ksh93 # Start the NetBackup-Java user or admin console. INSTALL_DIR=$( cd ${ dirname $0; } ; print "${PWD}" ; ) typeset -r FPROG=${.sh.file} typeset -r PROG=${FPROG##*/} [[ -z ${INSTALL_PATH} ]] && typeset INSTALL_PATH="${INSTALL_DIR}" [[ -z ${DOTNBJ_CONF} ]] && typeset DOTNBJ_CONF="${INSTALL_PATH}/.nbjConf" [[ ! -r ${DOTNBJ_CONF} ]] && DOTNBJ_CONF='/etc/netbackup/.nbjConf' [[ -z ${NBJ_CONF} ]] && NBJ_CONF="${INSTALL_PATH}/nbj.conf" [[ ! -r ${NBJ_CONF} ]] && NBJ_CONF="/etc/netbackup/nbj.conf" function readConf { typeset -n P=$1 typeset CONF="$2" [[ -r ${CONF} ]] || { (( ! UPDATE )) && print -u2 "WARN: Unable to read ${CONF}"; return 1; } while read LINE ; do [[ -z ${LINE} || ${LINE:0:1} == '#' ]] && continue VAL="${LINE#*=}" KEY="${.sh.match%=}" [[ -n ${KEY} ]] && P["${KEY}"]="${VAL}" done < "${CONF}" return 0 } function checkAndSetProps { typeset -n P=$1 typeset X Y Z if [[ -n ${P[RELEASE]} ]]; then if [[ ${P[RELEASE]} != '7.6' ]]; then print -u2 'The installed package supports NetBackup release 7.6,' \ 'only.' return 1 fi else P[RELEASE]='7.6' fi # Check java executable X="${P[JAVA_PATH]}" [[ -n $X && ! -x $X ]] && print -u2 "$X is not executable." && X='' if [[ -z $X ]]; then X=${ whence java ; } [[ -z $X && -x /usr/bin/java ]] && X='/usr/bin/java' [[ -n $X ]] && print -u2 "Using $X ..." fi [[ -z $X ]] && return 3 || P[JAVA_PATH]="$X" # Check running version on remote host if [[ -n ${P[HOST]} && ${P[HOST]} != 'localhost' ]]; then if [[ -x ${P[NB_BASE]}/netbackup/bin/bpclntcmd ]]; then X="${ ${P[NB_BASE]}/bin/netbackup/bpclntcmd \ -get_remote_host_version \ ${P[HOST]} ; }" if (( $? )); then print -u2 'Unable to determine the NetBackup release running' \ "on ${P[HOST]} - assuming 7.6!" elif [[ $X != '7.6' ]]; then print -u2 "${P[HOST]} has NetBackup '$X' running." \ 'This version is not supported.' return 2 fi #P[RELEASE]=$X else print -u2 "${P[NB_BASE]}/netbackup/bin/bpclntcmd not found." \ "Assuming ${P[HOST]} has NetBackup 7.6 running!" fi fi if [[ ${PROG} == 'jnbSA' ]]; then IS_NB=1 Z="${JNB_LOG}" Y='jnb' else Z="${JBP_LOG}" Y='jbp' fi # Check logfile X="${P[NBJAVA_LOGS_PATH]}" [[ -d $X && -w $X ]] || P[NBJAVA_LOGS_PATH]='/tmp' X="${P[LOG_FILE]}" if [[ -z $X ]]; then if [[ -n $Z ]]; then X="$Z" else X="${P[NBJAVA_LOGS_PATH]}/${Y}.${ id -un ; }.${PROG}.$$.log" fi P[LOG_FILE]="$X" fi [[ -h ${P[LOG_FILE]} ]] && rm -f "${P[LOG_FILE]}" [[ -z ${P[LOG_CMD]} ]] && P[LOG_CMD]='false' # setting LD_LIBRARY_PATH* should not be needed, since the binaries have # the RUNPATH already copiled in [[ -z ${P[VRTS_LIBRARY_PATH]} || ! -d ${P[VRTS_LIBRARY_PATH]} ]] && \ P[VRTS_LIBRARY_PATH]="${P[NB_BASE]}/lib" #unset LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 #export LD_LIBRARY_PATH="${P[VRTS_LIBRARY_PATH]}" [[ -z ${P[NB_EAT_HOME_DIR]} && ! -d ${P[NB_EAT_HOME_DIR]} ]] && \ P[NB_EAT_HOME_DIR]="${P[NB_BASE]}/netbackup/sec/at" [[ -z ${P[EAT_HOME_DIR]} || ! -d ${P[EAT_HOME_DIR]} ]] && \ P[EAT_HOME_DIR]="${P[NB_EAT_HOME_DIR]}" [[ -z ${P[EAT_DATA_DIR]} || ! -d ${P[EAT_DATA_DIR]} ]] && \ P[EAT_DATA_DIR]="${P[NB_BASE]}/var/vxss/at" [[ ! -d ${P[EAT_DATA_DIR]} ]] && \ P[EAT_DATA_DIR]='/var/netbackup/vxss/at' for X in ${!P[@]} ; do [[ ${X: -3:3} != 'JAR' ]] && continue Z='' for Y in ${P[$X]//:/ } ; do [[ -e $Y ]] && Z+=":$Y" || Z+=":${INSTALL_PATH}/${Y##*/}" done P[$X]="${Z:1}" done locale | while read X ; do [[ ${X:0:9} == 'LC_CTYPE=' ]] && P[LC_CTYPE]=${X:9} && break done } function setupClasspath { typeset -n P=$1 typeset -a KEYS=( PJAR COMMONJAR DBEXTJAR JBPJAR NBJAR PV_JAR KL_JAR JDOM_JAR HELPVIEWER_JAR VXSSIOP_JAR ATWRAPPER_JAR CRIMSON_JAR ) (( IS_NB )) && KEYS+=( CHART_JAR FSAJAR HSMJAR SCHED_JAR CORBA_JAR EMM_JAR JACORB_JAR JACORB_PBX_JAR JACORB_LOG_JAR JACORB_AV_JAR JACORB_CON_JAR JACORB_ANT_JAR VXREP_JAR MCHARTS_JAR JACKSON_JAR ) typeset X Z='' for X in ${KEYS[@]} ; do [[ -n ${P[${X}]} ]] && Z+=":${P[${X}]}" done CLASSPATH="${Z:1}:.:${INSTALL_PATH}" } function updateJavaConfig { typeset -a FILES=( nbj.conf Debug.properties ) typeset X TMPL if [[ ! -d /etc/netbackup ]]; then ${PRINT} mkdir /etc/netbackup || \ { print -u2 '# Unable to create local config directory' \ '/etc/netbackup/ !' ; return 1 ; } fi for X in ${FILES[@]} ; do TMPL="${INSTALL_PATH}/${X}.tmpl" [[ -r ${TMPL} ]] || \ { print -u2 "# ${TMPL} not found." ; return 1 ; } ${PRINT} cp -p ${TMPL} /etc/netbackup/$X || \ { print -u2 "# Update of /etc/netbackup/$X failed." ; return 2 ; } done return 0 } function printUsage { getopts -a "${PROG}" "${ print ${USAGE}; }" OPT --man } USAGE='[-?$Id: jbpSA 627 2014-07-10 19:43:56Z elkner $ ] [-copyright?Copyright (c) 2014 Jens Elkner. All rights reserved.] [-license?CDDL 1.0] [+NAME?'"${PROG}"' - start the NetBackup Java Client] [+DESCRIPTION?Starts the NetBackup Java Client using the appropriate properties defined in the \b$INSTALL_PATH/.nbjConf\b and \b$INSTALL_PATH/nbj.conf\b.] [h:help?Print this help and exit.] [F:functions?Print a list of all functions available.] [T:trace]:[functionList?A comma separated list of functions of this script to trace (convinience for troubleshooting).] [+?] [C:config?Just create the local configuration directory \b/etc/netbackup/\b and copy the *.tmpl files from \b$INSTALL_PATH\b to this location without the .tmpl extension, so that jbpSA finds all it needs to work.] [c:cmd?Log cmdlines used by the application to the log file.] [D:Debug]:[file?Use the given debug properties \afile\a instead of \b$INSTALL_PATH/Debug.properties\b.] [d:display]:[name?The name of the display to use (e.g. "eagle:0.0"). Just sets the DISPLAY environent variable to the given \aname\a.] [H:Host]:[hostname:The name or IP address of the host to connect to.] [l:log]:[file?The name of the log \afile\a to use (full path). Per default the value of \bNBJAVA_LOGS_PATH\b property in \b$INSTALL_PATH/.nbjConf\b file will be used.] [o:openv]:[path?The NetBackup client install directory. Default: /usr/openv] [r:release]:[version?NetBackup \aversion\a running on the targeting host. Used only, if the \aversion\a of the corresponding host cannot be determined automatically. The installed package supports "7.6", only.] [s:ms]:[size?The initial Java heap size to use (see java -X).] [x:mx]:[size?The maximum Java heap size to use (see java -X).] ' [[ ${PATH:0:9} == '/usr/bin:' || ${PATH} == '/usr/bin' ]] || \ PATH="/usr/bin:${PATH}" integer UPDATE=0 NEED_UPDATE=0 NEED_JARS=0 typeset -A PROPS # Read the default configuration. readConf PROPS "${DOTNBJ_CONF}" || NEED_JARS=1 # java startup options readConf PROPS "${NBJ_CONF}" || NEED_UPDATE=1 # App runtime params # Add some essential defaults, if n/a [[ -z ${PROPS[INITIAL_MEMORY]} ]] && PROPS[INITIAL_MEMORY]='36m' [[ -z ${PROPS[MAX_MEMORY]} ]] && PROPS[MAX_MEMORY]='256m' PROPS[FACTORY]='-Djava.util.prefs.PreferencesFactory=vrts.common.launch.PropertiesPreferencesFactory' [[ -z ${PROPS[DEBUG]} ]] && PROPS[DEBUG]="${INSTALL_PATH}/Debug.properties" [[ -z ${PROPS[NB_BASE]} ]] && PROPS[NB_HOME]='/usr/openv' # supplement settings while getopts -a "${PROG}" "${ print ${USAGE}; }" OPT ; do case "${OPT}" in h) printUsage ; exit 0 ;; T) typeset -ft ${OPTARG//,/ } ;; F) typeset +f && exit 0 ;; d) DISPLAY="${OPTARG}" ;; D) PROPS[DEBUG]="${OPTARG}" ;; H) PROPS[HOST]="${OPTARG}" ;; l) PROPS[LOG_FILE]="${OPTARG}" ;; c) PROPS[LOG_CMD]='true' ;; s) [[ -n ${OPTARG} ]] && PROPS[INITIAL_MEMORY]="${OPTARG}" ;; x) [[ -n ${OPTARG} ]] && PROPS[MAXMEM]="${OPTARG}" ;; r) [[ -n ${OPTARG} ]] && PROPS[RELEASE]="${OPTARG}" ;; o) [[ -n ${OPTARG} ]] && PROPS[NB_BASE]="${OPTARG}" ;; C) UPDATE=1 ;; esac done integer IDX=$((OPTIND-1)) IS_NB shift $IDX if (( UPDATE )); then updateJavaConfig exit $? fi if (( NEED_JARS || NEED_UPDATE )); then print -u2 ' The mentioned configuration file(s) are required for the Java console application. Did you already ran "'"${PROG}"' -C" to make a copy of the configuration templates and putting them into the right place? ' exit 1 fi checkAndSetProps PROPS || exit $? # The following is needed to prevent Java from exceeding the default open # file limit because it does not close image files fast enough. ulimit -n 1024 export CLASSPATH setupClasspath PROPS export XENVIRONMENT="${INSTALL_PATH}/Xenv" (( IS_NB )) && X='Admin' || X='User' print "\n\tStarting $X Console version ${PROPS[RELEASE]}." if [[ -n ${PROPS[LOG_FILE]} ]]; then print ' Starting '"$X"' console version '"${PROPS[RELEASE]}."'\n DISPLAY environment variable is set to:\n\t'"${DISPLAY}"'\n Console was started on:\n\t'"${ uname -a ; }"'\n Command line options were:\n\t'"$0 ${@}"' ' >"${PROPS[LOG_FILE]}" print "\tLogfile: ${PROPS[LOG_FILE]}\n" fi # The ordering of parameters here is important. In particular, the # -Dvrts.NBJAVA_CONF parameter must be first. bpps and bp.kill_all are # using this to distinguish NBJava processes from NBAR and VSM java processes. ${PROPS[JAVA_PATH]} -Dvrts.NBJAVA_CONF="${NBJ_CONF}" -showversion -d64 \ -Dvrts.common.server.LCCTYPE=${PROPS[LC_CTYPE]} \ -Dvrts.common.server.LOG_CMDLINES=${PROPS[LOG_CMD]} \ -Djava.library.path=${INSTALL_PATH}/lib/amd64 \ -Dvrtsat.datadir="${PROPS[EAT_DATA_DIR]}" \ -Dvrtsat.home="${PROPS[NB_EAT_HOME_DIR]}" \ -Dvrts.common.utilities.DEBUG_PROPERTIES="${PROPS[DEBUG]}" \ -Dvrts.nbe.HOSTNAME="${PROPS[HOST]}" \ -Dvrts.nbe.INST_REL="${PROPS[INSTALLED_RELEASE]}" \ -Dvrts.nbe.BUILDNO="${PROPS[BUILDNUMBER]}" ${PROPS[FACTORY]} \ -Xms${PROPS[INITIAL_MEMORY]} -Xmx${PROPS[MAX_MEMORY]} \ vrts.nbe.${X}Console 2>&1 | tee -a ${PROPS[LOG_FILE]} # vim: ts=4 sw=4 filetype=sh