#!/bin/ksh93 # $Id: nbclient.method 627 2014-07-10 19:43:56Z elkner $ # # Copyright 2014 Jens Elkner. All rights reserved. # License: CDDL 1.0 # # description: # Startup/shutdown script for NetBackup client daemons # # default: S/K45 0/K45 1/K45 2/S45 . /lib/svc/share/smf_include.sh NB_HOME=/'usr/openv/netbackup' # netbackup binaries are usually not relocatable SMF_FMRI_ALT='netbackup:{vxpbx|vnetd|bpcd|nbftclnt|nbdisco|auth}' INSTANCE="$2" VERSION="7.6.0" # The triple to detect, whether setup needs to be run SETUP="update_config" function checkConfig { typeset TARGET="${SMF_FMRI%:*}:vnetd" \ VAL="${ svcprop -p config/version "${TARGET}" 2>/dev/null ; }" [[ ${VAL:0:1} == "'" || ${VAL:0:1} == '"' ]] && VAL="${VAL:1:${#VAL}-2}" if [[ ${VAL} != ${VERSION} ]]; then print -u2 "'${NB_HOME}/bin/${SETUP}' needs to be run successfully once." return ${SMF_EXIT_ERR_CONFIG} fi return 0 } function startDaemon { typeset BINARY="$1" if [[ ! -x ${NB_HOME}/bin/${BINARY} ]]; then print -u2 'The NetBackup client package seems not to be available.' \ "Missing '${NB_HOME}/bin/${BINARY}'." return ${SMF_EXIT_ERR_FATAL} fi shift ${NB_HOME}/bin/${BINARY} "${@}" } integer RES=0 case "$1" in start) [[ -z ${SMF_FMRI} || -z ${INSTANCE} ]] && \ print -u2 'Use "svcadm enable [-st] '"${SMF_FMRI_ALT}" \ '" to enable the service.' && exit ${SMF_EXIT_ERR_NOSMF} checkConfig || exit $? case "${INSTANCE}" in vxpbx) startDaemon pbx_exchange || RES=$? ;; vnetd) startDaemon vnetd '-standalone' || RES=$? ;; bpcd) startDaemon bpcd '-standalone' || RES=$? ;; nbftclnt) startDaemon nbftclnt || RES=$? (( RES == 243 )) && RES=${SMF_EXIT_ERR_CONFIG} ;; # poor implementation - this stuff always starts, forks and # returns 0 immediately and later it thinks: "oh shit, I got # disabled/can't find my master so I change my mind and exit. Yeah, # I'm really dumb." - damn MS windows developers. nbdisco) startDaemon nbdisco || RES=$? ;; bmrbd) startDaemon bmrbd || RES=$? ;; # handled by inetd.restarter, if enabled #auth) startDaemon bpjava-msvc || RES=$? ;; *) print -u2 "Unsupported daemon '${INSTANCE}'" exit ${SMF_EXIT_ERR_FATAL} ;; esac ;; stop) print -u2 'Use "svcadm disable [-st] '"${SMF_FMRI:-${SMF_FMRI_ALT}}" \ '" to disable the service.' && exit ${SMF_EXIT_ERR_NOSMF} ;; *) print "Usage: $0 {start|stop}" exit ${SMF_EXIT_ERR_NOSMF} ;; esac (( RES == 110 )) && print -u2 'Perhaps the SERVER or CLIENT_NAME is not set' \ 'correctly in /etc/netbackup/bp.conf or port 1556 (outgoing) is blocked?' exit ${RES} # vim: ts=4 sw=4 filetype=sh