问题描述
我将openfire源码编译后把它注册成linux系统服务,脚本如下:#!/bin/sh##openfirectlStopsandstartstheOpenfireXMPPservice.##chkconfig:-6436#description:OpenfireisanXMPPserver,whichisaserverthatfacilitates#XMLbasedcommunication,suchaschat.#config:/opt/openfire/conf/openfire.xml#config:/etc/sysconfig/openfire#pidfile:/var/run/openfire.pid##Thisscriptmanagestheopenfiredaemonprocess.Thisscriptshould#onlyberunasrootandmaydoubleasaninitscriptifdesired.You#cansymlinkitintoyourrcdirectoriesmanually,orifyouhave#chkconfigavailable,youcancopy/symlinkitintoyourinit.ddirectory#andchkconfig--addit.It'srecommendedtonameitopenfireinsteadof#openfirectlintheinit.ddirectory.
解决方案二:
解决方案三:
#Beginsetupwork
解决方案四:
解决方案五:
InitializationCMD=$1PATH="/sbin:/bin:/usr/bin:/usr/sbin"RETVAL=0#Makesurewearerunningasrootset`/usr/bin/id`if[$1!="uid=0(root)"];thenecho"$0:mustberunasroot"exit1fi#Getconfigfromsysconfigifonasystemthatsupportsit.[-f"/etc/sysconfig/openfire"]&&./etc/sysconfig/openfire#Ifopenfireuserisnotsetelsewhere,settodaemon.[-z"$OPENFIRE_USER"]&&OPENFIRE_USER="daemon"#Ifpidfilepathisnotsetelsewhere,setto/var/run/openfire.pid.[-z"$OPENFIRE_PIDFILE"]&&OPENFIRE_PIDFILE="/var/run/openfire.pid"#-----------------------------------------------------------------#Ifaopenfirehomevariablehasnotbeenspecified,trytodetermineit.if[-z"$OPENFIRE_HOME"-o!-d"$OPENFIRE_HOME"];thenif[-d"/usr/share/openfire"];thenOPENFIRE_HOME="/usr/share/openfire"elif[-d"/usr/local/openfire"];thenOPENFIRE_HOME="/usr/local/openfire"elif[-d"/opt/openfire"];thenOPENFIRE_HOME="/opt/openfire"elseecho"CouldnotfindOpenfireinstallationunder/opt,/usr/share,or/usr/local."if[-f"/etc/sysconfig"];thenecho"PleasespecifytheOpenfireinstallationlocationasvariableOPENFIRE_HOME"echo"in/etc/sysconfig/openfire."fiexit1fifi#Iflogpathisnotsetalready,setto$OPENFIRE_HOME/logs.[-z"$OPENFIRE_LOGDIR"]&&OPENFIRE_LOGDIR="${OPENFIRE_HOME}/logs"#Attempttolocatejavainstallation.if[-z"$JAVA_HOME"];thenif[-d"${OPENFIRE_HOME}/jre"];thenJAVA_HOME="${OPENFIRE_HOME}/jre"elif[-d"/etc/alternatives/jre"];thenJAVA_HOME="/etc/alternatives/jre"elsejdks=`ls-r1d/usr/java/j*`forjdkin$jdks;doif[-f"${jdk}/bin/java"];thenJAVA_HOME="$jdk"breakfidoneif[-z"$JAVA_HOME"];thenif[-d"/usr/java/jdk1.6.0_45"-a-d"/usr/java/jdk1.6.0_45/bin"];thenJAVA_HOME="/usr/java/jdk1.6.0_45"fifififiJAVACMD="${JAVA_HOME}/bin/java"if[!-d"$JAVA_HOME"-o!-x"$JAVACMD"];thenecho"Error:JAVA_HOMEisnotdefinedcorrectly."echo"Cannotsureexecute$JAVACMD."exit1fi#PreparelocationofopenfirelibrariesOPENFIRE_LIB="${OPENFIRE_HOME}/lib"#PrepareopenfirecommandlineOPENFIRE_OPTS="${OPENFIRE_OPTS}-DopenfireHome=${OPENFIRE_HOME}-Dopenfire.lib.dir=${OPENFIRE_LIB}"#Preparelocaljavaclasspathif[-z"$LOCALCLASSPATH"];thenLOCALCLASSPATH="${OPENFIRE_LIB}/startup.jar"elseLOCALCLASSPATH="${OPENFIRE_LIB}/startup.jar:${LOCALCLASSPATH}"fi#ExportanynecessaryvariablesexportJAVA_HOMEJAVACMD#Lastly,preparethefullcommandthatwearegoingtorun.OPENFIRE_RUN_CMD="${JAVACMD}-server${OPENFIRE_OPTS}-classpath"${LOCALCLASSPATH}"-jar"${OPENFIRE_LIB}/startup.jar""
解决方案六:
解决方案七:
Endsetupwork
解决方案八:
##start(){OLD_PWD=`pwd`cd$OPENFIRE_LOGDIR#Startdaemons.echo"Startingopenfire:c"PID=`su-$OPENFIRE_USER-c"nohup$OPENFIRE_RUN_CMD>$OPENFIRE_LOGDIR/nohup.out2>&1&"`RETVAL=$?if[$RETVAL-eq0-a!-z"$OPENFIRE_PIDFILE"];thenecho$PID>$OPENFIRE_PIDFILEfiecho[$RETVAL-eq0-a-d/var/lock/subsys]&&touch/var/lock/subsys/openfiresleep1#allowsprompttoreturnecho"StartingopenfireOK!"cd$OLD_PWD}stop(){#Stopdaemons.echo"Shuttingdownopenfire:c"[-f"$OPENFIRE_PIDFILE"]&&kill`cat$OPENFIRE_PIDFILE`RETVAL=$?echo[$RETVAL-eq0-a-f"$OPENFIRE_PIDFILE"]&&rm-f$OPENFIRE_PIDFILE[$RETVAL-eq0-a-f"/var/lock/subsys/openfire"]&&rm-f/var/lock/subsys/openfire}restart(){stopsleep10#giveitafewmomentstoshutdownstart}condrestart(){[-e"/var/lock/subsys/openfire"]&&restartreturn0}status(){pid=`cat$OPENFIRE_PIDFILE2>&1`if["$?"="1"];thenecho"openfireisnotrunning"RETVAL=3elseps-p$pid>/dev/null2>&1if["$?"="0"];thenecho"openfireisrunning"RETVAL=0elseecho"openfireisnotrunning"RETVAL=1fifi}#Handlehowwewerecalled.case"$CMD"instart)start;;stop)stop;;restart)restart;;condrestart)condrestart;;reload)restart;;status)status;;*)echo"Usage$0{start|stop|restart|status|condrestart|reload}"RETVAL=1esacexit$RETVAL然后注册成服务可以运行正常,但是访问程序(即访问openfire)的时候,说无法连接到服务器请各位linux大神帮帮忙,看看是什么情况