Simple Start Scripts

Version 3

    These are very simple start scripts for Openfire. They match the Linux Installation Guide but you may need to adjust some settings according to your needs.

     

    Installation script install.sh

    ## adjust these variables to your need
    export MY_USER=jiveWF
    export RCD_PATH=/etc/rc.d
    export INITD_PATH=/etc/rc.d/init.d
    
    ## create user jiveWF (or simply jive), options: create a lv (logical volume)
    adduser ${MY_USER}
    passwd ${MY_USER}
    
    ## make sure that only ${MY_USER}  can access /home/jiveWF/WF/conf/*.xml and /home/jiveWF/WF/embedded-db/*
    chmod 700 /home/${MY_USER}
    
    ## uninstall old rc scripts
    rm -f ${INITD_PATH}/openfired ${INITD_PATH}/wildfired
    for i in 0 1 2 3 4 5 6
    do
    cd ${RCD_PATH}/rc${i}.d && rm -f ???wildfired
    cd ${RCD_PATH}/rc${i}.d && rm -f ???openfired
    done
    
    ## install new rc scripts
    ## adjust S20openfired and K80openfired to your needs. if you run another database
    ## and want to use it with Wildfire then make sure that the database is started
    ## before Openfire and shutdown after it.
    ## With S20 Openfire is started very early, it's fine for the embedded database.
    for i in 0 1 6
    do
    cd ${RCD_PATH}/rc${i}.d && ln -s ${INITD_PATH}/openfired K80openfired
    done
    for i in 2 3 4 5
    do
    cd ${RCD_PATH}/rc${i}.d && ln -s ${INITD_PATH}/openfired S20openfired
    done
    

     

    /etc/rc.d/init.d/openfired

    #!/bin/bash
     
    COMMAND=$0
    OPTION=$1
    SCRIPTNAME=$(basename ${COMMAND})
     
    RETVAL=0
    /usr/sbin/setenforce 0
    su - jiveWF -c "/home/jiveWF/OF/bin/openfire ${OPTION}"
    /usr/sbin/setenforce 1
    RETVAL=$?
    case ${OPTION} in
      start)
        touch /var/lock/subsys/${SCRIPTNAME}
        echo $RETVAL >/var/lock/subsys/${SCRIPTNAME}
        ;;
      stop|kill)
        rm -f /var/lock/subsys/${SCRIPTNAME}
        ;;
    esac
    exit
    

     

     

     

     

    /home/jiveWF/OF/bin/openfired

    #!/bin/bash
     
    COMMAND=$0
    OPTION=$1
    SCRIPTNAME=$(basename ${COMMAND})
    DIRNAME=$(dirname ${COMMAND})
    BASE_DIR=$(cd $DIRNAME/.. && pwd)
    GREP_OPTS="-DProgram=${SCRIPTNAME}"
     
    JVM_FILE=${COMMAND}.jvm
    JVM_OPTFILE=${COMMAND}.vmoptions
     
    if [ -f ${JVM_FILE} ]
    then
      JVM=$(cat ${JVM_FILE})
    else
      echo "Error: Create ${JVM_FILE}" 1>&2
      exit 1
    fi
     
    if [ -f ${JVM_OPTFILE} ]
    then
      JAVA_OPTS=$(cat ${JVM_OPTFILE}|tr '\n' ' ')
    else
      echo "Error: Create ${JVM_OPTFILE}." 1>&2
      exit 1
    fi
     
    JAVA_OPTS="${GREP_OPTS} ${JAVA_OPTS}"
    PID=`ps -fu ${USER}|grep -v "grep"|grep -e "${GREP_OPTS} "|tr '\t' ' '|tr -s ' '|cut -d' ' -f2`
     
    cd ${BASE_DIR}/bin
     
    case "${OPTION}" in
      start)
        echo "Starting ${SCRIPTNAME}"
        if [ ${PID} ]
        then
          echo "cannot start ${SCRIPTNAME}: ${SCRIPTNAME} is already running"
          exit 1
        else
          nohup ${JVM} ${JAVA_OPTS} -server -jar ../lib/startup.jar >../logs/SDTOUT.log 2>../logs/SDTERR.log &
        fi
        ;;
      status)
        if [ ${PID} ]
        then
          echo "${SCRIPTNAME} (pid ${PID}) is running..."
        else
          echo "${SCRIPTNAME} is stopped"
          exit 3
        fi
        ;;
      stop)
        echo "Shutting down ${SCRIPTNAME}"
        if [ ${PID} ]
        then
          kill -15 ${PID}
        else
          echo "${SCRIPTNAME} is not running"
        fi
        ;;
      kill)
        echo "Killing $SCRIPTNAME}"
        if [ ${PID} ]
        then
          kill -9 ${PID}
        else
          echo "${SCRIPTNAME} is not running"
        fi
        ;;
      *)
        echo "Usage: ${SCRIPTNAME} {start|stop|status|kill}"
        exit 1
        ;;
    esac
    

     

     

     

     

    /home/jiveWF/OF/bin/openfired.jvm

    The content of this file should point to the Java version you want to use.

    /opt/java/Openfire/bin/java
    

     

     

     

     

    /home/jiveWF/OF/bin/openfired.vmoptions

    Put in this file all the parameters you want to use.

    -Xms64m
    -Xmx128m
    -Xss128k
    -XX:ThreadStackSize=128
    -XX:PermSize=32m
    -XX:MaxPermSize=64m
    -XX:+PrintGCDetails
    -Xloggc:/home/jiveWF/WF/logs/gc.log
    -Djava.net.preferIPv4Stack=true
    -server