📄 opennms.sh
字号:
$OPENNMS_HOME/bin/opennms.sh start exit 1}doStop() { doStatus if [ $? -eq 3 ]; then echo "`date`: trying to stop OpenNMS but it's already stopped." return 7 # LSB says: 7 - program is not running fi STOP_ATTEMPTS=0 while [ $STOP_ATTEMPTS -lt 5 ]; do doStatus if [ $? -eq 3 ]; then echo "" > "$OPENNMS_PIDFILE" return 0 fi if [ -z "$NOEXECUTE" ]; then APP_VM_PARMS="$CONTROLLER_OPTIONS" APP_CLASS="$CONTROLLER_CLASS" APP_PARMS_BEFORE="stop $SERVICE" $JAVA_CMD -classpath $APP_CLASSPATH $APP_VM_PARMS $APP_CLASS $APP_PARMS_BEFORE "$@" $APP_PARMS_AFTER fi sleep 5 STOP_ATTEMPTS=`expr $STOP_ATTEMPTS + 1` done return 1}doKill(){ if doStatus; then get_url "${INVOKE_URL}&operation=doSystemExit" fi pid="`test -f $OPENNMS_PIDFILE && cat $OPENNMS_PIDFILE`" if [ x"$pid" != x"" ]; then if ps -p "$pid" | grep "^root" > /dev/null; then kill -9 $pid > /dev/null 2>&1 fi fi echo "" > "$OPENNMS_PIDFILE"}doStatus(){ getStatus | determineStatus "$@"}determineStatus(){ running=0 services=0 while read line; do if [ $VERBOSE -gt 0 ]; then echo "$line" fi if echo "$line" | grep "running" > /dev/null; then running=`expr $running + 1` fi services=`expr $services + 1` done if [ $services -eq 0 ]; then return 3 # According to LSB: 3 - service not running elif [ $running -ne $services ]; then return 160 # According to LSB: reserved for application # So, I say 160 - partially running else # everything should be good and running return 0 fi}FUNCTIONS_LOADED=0if [ -f /etc/SuSE-release ]; then . /etc/rc.status rc_resetelse # Source function library. for dir in @install.init.dir@ /etc /etc/rc.d; do if [ -f "$dir/init.d/functions" -a $FUNCTIONS_LOADED -eq 0 ]; then . "$dir/init.d/functions" FUNCTIONS_LOADED=1 fi donefiif [ `echo "\000\c" | wc -c` -eq 1 ]; then opennms_echo="echo"elif [ `echo -e "\000\c" | wc -c` -eq 1 ]; then opennms_echo="echo -e"else echo "ERROR: could not get 'echo' to emit just a null character" >&2 exit 1fiulimit -s 8192 > /dev/null 2>&1ulimit -n 10240 > /dev/null 2>&1if [ x"`uname`" = x"Darwin" ]; then for flag in "-d" "-f" "-l" "-m" "-n" "-s" "-u" "-v"; do ulimit $flag unlimited >/dev/null 2>&1 donefiumask 002# XXX is this needed? maybe we should "cd $OPENNMS_HOME/logs" so hotspot# XXX error files go somewhere reasonablecd "$OPENNMS_HOME" || { echo "could not \"cd $OPENNMS_HOME\"" >&2; exit 1; }# define needed for grep to find opennms easilyJAVA_CMD="$OPENNMS_HOME/bin/runjava -r $RUNJAVA_OPTIONS --"if [ x"$ADDITIONAL_CLASSPATH" != x"" ]; then APP_CLASSPATH="$ADDITIONAL_CLASSPATH:$OPENNMS_HOME/etc"else APP_CLASSPATH="$OPENNMS_HOME/etc"fifor jar in $OPENNMS_HOME/lib/*.jar; do APP_CLASSPATH="$APP_CLASSPATH:$jar"doneMANAGER_CLASS=org.opennms.netmgt.vmmgr.ManagerMANAGER_OPTIONS="-DOPENNMSLAUNCH"MANAGER_OPTIONS="$MANAGER_OPTIONS -Dopennms.home=$OPENNMS_HOME"MANAGER_OPTIONS="$MANAGER_OPTIONS -Djcifs.properties=$OPENNMS_HOME/etc/jcifs.properties"MANAGER_OPTIONS="$MANAGER_OPTIONS -Xmx${JAVA_HEAP_SIZE}m"if [ -n "$USE_INCGC" -a "$USE_INCGC" = true ] ; then MANAGER_OPTIONS="$MANAGER_OPTIONS -Xincgc"fiif [ x"$ADDITIONAL_MANAGER_OPTIONS" != x"" ]; then MANAGER_OPTIONS="$MANAGER_OPTIONS $ADDITIONAL_MANAGER_OPTIONS"fiif [ -n "$HOTSPOT" -a "$HOTSPOT" = true ] ; then JAVA_CMD="$JAVA_CMD -server"fiCONTROLLER_CLASS=org.opennms.netmgt.vmmgr.ManagerCONTROLLER_OPTIONS="-Dopennms.home=$OPENNMS_HOME"CONTROLLER_OPTIONS="-Dlog4j.configuration=log4j.properties"TEST=0NOEXECUTE=""VERBOSE=0NAME="opennms"while getopts ntv c; do case $c in n) NOEXECUTE="foo" ;; t) TEST=1 ;; v) VERBOSE=1 VERBOSE_GC=1 ;; "?") show_help exit 1 ;; esacdoneshift `expr $OPTIND - 1`if [ $# -eq 0 ]; then show_help exit 1else COMMAND="$1"; shiftfiif [ $# -gt 0 ]; then SERVICE="$1"; shiftelse SERVICE=""fiif [ $# -gt 0 ]; then show_help exit 1fiif [ x"$SERVICE" = x"all" ]; then SERVICE=""fiif [ x"$VERBOSE_GC" != x"" ]; then MANAGER_OPTIONS="$MANAGER_OPTIONS -verbose:gc"fiif [ ! -f $OPENNMS_HOME/etc/configured ]; then echo "$0: OpenNMS not configured." >&2 echo "$OPENNMS_HOME/etc/configured does not exist." >&2 echo "You need to run the installer -- see the install guide for details." >&2 exit 6 # From LSB: 6 - program is not configuredficase "$COMMAND" in start|spawn) $opennms_echo "Starting OpenNMS: \c" if [ -f /etc/SuSE-release ]; then doStart # Remember status and be verbose rc_status -v elif [ $FUNCTIONS_LOADED -ne 0 ]; then doStart ret=$? if [ $ret -eq 0 ]; then echo_success touch /var/lock/subsys/${NAME} else echo_failure fi echo "" else doStart ret=$? if [ $ret -eq 0 ]; then echo "ok" else echo "failed" fi fi ;; stop) $opennms_echo "Stopping OpenNMS: \c" if [ -f /etc/SuSE-release ]; then doStop # Remember status and be verbose rc_status -v doKill elif [ $FUNCTIONS_LOADED -ne 0 ]; then doStop ret=$? if [ $ret -eq 0 ]; then echo_success else echo_failure fi rm -f /var/lock/subsys/${NAME} echo "" doKill else doStop ret=$? if [ $ret -eq 0 ]; then echo "stopped" else echo "failed" fi doKill fi ;; restart) ## Stop the service and regardless of whether it was ## running or not, start it again. $OPENNMS_HOME/bin/opennms.sh stop $OPENNMS_HOME/bin/opennms.sh start ret=$? if [ -f /etc/SuSE-release ]; then rc_failed $ret fi ;; status) if [ -f /etc/SuSE-release ]; then $opennms_echo "Checking for OpenNMS: \c" if [ $VERBOSE -gt 0 ]; then echo "" fi doStatus # Remember status and be verbose rc_status -v else doStatus ret=$? case $ret in 0) echo "${NAME} is running" ;; 3) echo "${NAME} is stopped" ;; 160) echo "${NAME} is partially running" ;; *) echo "Unknown return code from doStatus: $ret" >&2 esac fi ;; pause) doPause ;; check) doCheck ;; resume) doResume ;; kill) doKill ;; *) echo "" echo "ERROR: unknown command \"$COMMAND\"" show_help exit 1 ;;esacif [ -f /etc/SuSE-release ]; then rc_exitelse exit $retfi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -