ok

Mini Shell

Direktori : /opt/cpanel/ea-tomcat85/
Upload File :
Current File : //opt/cpanel/ea-tomcat85/sample.ea-tomcat85.initd

#!/bin/sh
# cpanel - ea-tomcat85                               Copyright 2018 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
#

# Checkconfig Stanzas:
# -----------------------------------------------------------------------------------
# chkconfig: 2345 98 15
# description: Apache Tomcat 8.5 is an open source web server and servlet container.
# processname: /usr/bin/java

# source function library
. /etc/rc.d/init.d/functions

export CATALINA_HOME=/opt/cpanel/ea-tomcat85
export CATALINA_BASE=/opt/cpanel/ea-tomcat85
. /opt/cpanel/ea-tomcat85/bin/setenv.sh

tomcat_pid() {
  if [ -n "$CATALINA_PID" ] && [ -e $CATALINA_PID ]; then
      cat $CATALINA_PID
  fi
}


case $1 in
    start)
        pid=$(tomcat_pid)
        file=/opt/cpanel/ea-tomcat85/bin/startup.sh
        # no way to start tomcat
        if [ ! -x $file ]; then
            echo -e "\e[00m;31mMissing $file\e[00m"
            ERROR=1
        else
            # tomcat disabled by whm
            if [ -e /etc/tomcatdisable ]; then
                echo -e "\e[00;31mTomcat is disabled by cPanel/WHM\e[00m"
                ERROR=0
            else
                ERROR=0

                if [ -n "$pid" ]; then
                    echo -e "\e[00;33mTomcat is already running (pid: $pid)\e[00m"

                else
                # start tomcat, not running
                    su -s $file tomcat &>/dev/null
                    echo -e "\e[00;33mGiving Tomcat time to start up ......\e[00m"
                    sleep 1 # just to make sure
                    pid=$(tomcat_pid)
                    if [ -n "$pid" ]; then
                        ERROR=0
                    echo -e "\e[00;32mTomcat has started!\e[00m"
                    else
                        echo -e "\e[00;31mFailed to start Tomcat\e[00m"
                        ERROR=1
                    fi
                fi
            fi
        fi
        ;;
    stop)
        pid=$(tomcat_pid)
        file=/opt/cpanel/ea-tomcat85/bin/shutdown.sh
        if [ ! -n "$pid" ]; then
            echo -e "\e[00;31mTomcat is already shutdown\e[00m"
            ERROR=1
        else
            if [ ! -x $file ]; then
                echo -e "\e[00;31mMissing $file\e[00m"
                ERROR=1
            else
            su -s $file tomcat
            echo -e "\e[00;32mTomcat has shutdown.\e[00m"
            ERROR=0
            fi
        fi
        ;;
    restart)
        file=/usr/local/cpanel/scripts/restartsrv_ea_tomcat85
        if [ ! -x $file ]; then
            echo "Missing $file"
            ERROR=1
        else
            $file # must be run as root, it is ok though because it comes back in here for start/stop
        fi
        ;;
    status|fullstatus)
        pid=$(tomcat_pid)
        if [ -n "$pid" ]; then
            echo -e "\e[00;32mTomcat is running!\e[00m"
        else
            echo -e "\e[00;31mTomcat is currently not running.\e[00m"
        fi
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|status|fullstatus}"
        ERROR=2
esac

exit $ERROR

Zerion Mini Shell 1.0