Hello all,
I am trying to make my first startup script for the programm Glassfish.
At the moment you need to use this to start, stop and restart the program:
So this is like my script looks right now:Code:/opt/glassfish/bin/asadmin start-domain /opt/glassfish/bin/asadmin stop-domain /opt/glassfish/bin/asadmin restart-domain
(First he didn't created the PID file so I have to set the parameter '--make-pidfile' since the Java Glassfish didn't created it.)Code:#!/bin/sh ### BEGIN INIT INFO # # Provides: glassfish # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Glassfish scipt (Non official) # Description: Start Glassfish domain as service. # ### END INIT INFO # Using the LSB functions to perform the operations . /lib/lsb/init-functions BASE=/opt/glassfish/bin NAME=glassfish DAEMON=${BASE}/asadmin SCRIPTNAME=/etc/init.d/$NAME #PID file for the daemon PIDFILE=/var/run/glassfish.pid #If the daemon is not there, then exit [ -x "$DAEMON" ] || exit 5 do_start() { start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- start-domain } do_stop() { start-stop-daemon --stop --quiet --pidfile $PIDFILE } case $1 in start) #Check PID file if [ -e $PIDFILE ]; then status_of_proc -p $PIDFILE "$NAME process" && status="0" || status="$?" # IF SUCCESS dont start again if [ $status = "0" ]; then exit fi fi #Start the daemon log_daemon_msg "Starting the process" "$NAME" if do_start; then log_end_msg 0 else log_end_msg 1 fi ;; stop) # Stop the daemon if [ -e $PIDFILE ]; then status_of_proc -p $PIDFILE $DAEMON "Stopping the $NAME process" && status="0" || status="$?" if [ "$status" = 0]; then do_stop fi else log_daemon_msg "$NAME process is not running" log_end_msg 0 fi ;; restart) # Restart the daemon $0 stop && sleep 2 && $0 start ;; status) # Check status if [ -e $PIDFILE ]; then status_of_proc -p $PIDFILE $DAEMON "$NAME process" && exit 0 || exit $? else log_daemon_msg "$NAME Process is not running" log_end_msg 0 fi ;; *) # Show help echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2 exit 3 ;; esac
The PID gets now created but the output on status or stop is that there is no PID file existing. I try to get this working since yesterday.
Maybe someone can help me and tell me what I am doing wrong?
Bookmarks