Skip to content

Instantly share code, notes, and snippets.

@kkarthee
Created September 30, 2024 01:36
Show Gist options
  • Save kkarthee/973b898c0f14b54fbd7262d69e7ccb1e to your computer and use it in GitHub Desktop.
Save kkarthee/973b898c0f14b54fbd7262d69e7ccb1e to your computer and use it in GitHub Desktop.

Revisions

  1. kkarthee created this gist Sep 30, 2024.
    99 changes: 99 additions & 0 deletions v-1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,99 @@
    #!/bin/sh
    #
    # nodemgr Oracle Weblogic NodeManager service
    #
    # chkconfig: 345 85 15
    # description: Oracle Weblogic NodeManager service
    # The script needs to be saved as /etc/init.d/nodemgr and then issue chkconfig –add nodemgr as root

    ### BEGIN INIT INFO
    # Provides: nodemgr
    # Required-Start: $network $local_fs
    # Required-Stop:
    # Should-Start:
    # Should-Stop:
    # Default-Start: 3 4 5
    # Default-Stop: 0 1 2 6
    # Short-Description: Oracle Weblogic NodeManager service.
    # Description: Starts and stops Oracle Weblogic NodeManager.
    ### END INIT INFO

    . /etc/rc.d/init.d/functions

    export MW_HOME=”/w01/oracle/bea”
    export JAVA_HOME=”/w01/jrrt-3.1.2-1.6.0″
    DAEMON_USER=”oracle”
    PROCESS_STRING=”^./w01/oracle/bea/.*weblogic.NodeManager.”

    source $MW_HOME/wlserver_10.3/server/bin/setWLSEnv.sh > /dev/null
    export NodeManagerHome=”$WL_HOME/common/nodemanager”
    NodeManagerLockFile=”$NodeManagerHome/nodemanager.log.lck”

    PROGRAM=”$MW_HOME/wlserver_10.3/server/bin/startNodeManager.sh”
    SERVICE_NAME=/bin/basename $0
    LOCKFILE=”/var/lock/subsys/$SERVICE_NAME

    RETVAL=0

    start() {
    OLDPID=/usr/bin/pgrep -f $PROCESS_STRING
    if [ ! -z$OLDPID” ]; then
    echo$SERVICE_NAME is already running (pid $OLDPID) !
    exit
    fi

    echo -n $”Starting $SERVICE_NAME: “
    /bin/su $DAEMON_USER -c “$PROGRAM &

    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $LOCKFILE
    }

    stop() {
    echo -n $”Stopping $SERVICE_NAME: “
    OLDPID=/usr/bin/pgrep -f $PROCESS_STRING
    if [ “$OLDPID!= “” ]; then
    /bin/kill -TERM $OLDPID
    else
    /bin/echo “$SERVICE_NAME is stopped”
    fi
    echo
    /bin/rm -f $NodeManagerLockFile
    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE

    }

    restart() {
    stop
    sleep 10
    start
    }

    case$1in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart|force-reload|reload)
    restart
    ;;
    condrestart|try-restart)
    [ -f $LOCKFILE ] && restart
    ;;
    status)
    OLDPID=/usr/bin/pgrep -f $PROCESS_STRING
    if [ “$OLDPID!= “” ]; then
    /bin/echo “$SERVICE_NAME is running (pid: $OLDPID)”
    else
    /bin/echo “$SERVICE_NAME is stopped”
    fi
    RETVAL=$?
    ;;
    *)
    echo $”Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}”
    exit 1
    esac
    exit $RETVAL