#!/bin/bash
#
# glassfish:          Startup script for Glassfish Application Server.

<% glassfish_home = "#{node[:glassfish][:base_dir]}/glassfish" %>

export AS_JAVA=<%= node["java"]["java_home"] %>

start() {
        echo -n "Starting Glassfish: "
        echo "Starting Glassfish at `date`" >> <%= glassfish_home %>/domains/domain1/logs/startup.log
        su <%= node[:glassfish][:user] %> -c "<%= glassfish_home %>/bin/asadmin start-domain --domaindir <%= node[:glassfish][:domains_dir] %> domain1" >> <%= glassfish_home %>/domains/domain1/logs/startup.log
        sleep 2
        echo "done"
}

stop() {
        echo -n "Stopping Glassfish: "
        echo "Stopping Glassfish at `date`" >> <%= glassfish_home %>/domains/domain1/logs/startup.log
        su <%= node[:glassfish][:user] %> -c "<%= glassfish_home %>/bin/asadmin stop-domain --domaindir <%= node[:glassfish][:domains_dir] %> domain1" >> <%= glassfish_home %>/domains/domain1/logs/startup.log
        echo "done"
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        *)
                echo $"Usage: glassfish {start|stop|restart}"
                exit
esac

#!/bin/bash
#
# glassfish:          Startup script for Glassfish Application Server.

<% glassfish_home = "#{node[:glassfish][:base_dir]}/glassfish" %>

export AS_JAVA=<%= node["java"]["java_home"] %>

start() {
        echo -n "Starting Glassfish Domains: "
        <% domain_name = "domain1" %>
        <% log_file = "#{glassfish_home}/domains/#{domain_name}/logs/startup.log" %>
        echo -n "<%= domain_name %> "
        echo "Starting Glassfish at `date`" >> <%= log_file %>
        su <%= node[:glassfish][:user] %> -c "<%= glassfish_home %>/bin/asadmin start-domain --domaindir <%= node[:glassfish][:domains_dir] %> <%= domain_name %>" >> <%= log_file %>
        sleep 2
        echo "done"
}

stop() {
        echo -n "Stopping Glassfish Domains: "
        <% domain_name = "domain1" %>
        <% log_file = "#{glassfish_home}/domains/#{domain_name}/logs/startup.log" %>
        echo -n "<%= domain_name %> "
        echo "Stopping Glassfish at `date`" >> <%= log_file %>
        su <%= node[:glassfish][:user] %> -c "<%= glassfish_home %>/bin/asadmin stop-domain --domaindir <%= node[:glassfish][:domains_dir] %> <%= domain_name %>" >> <%= log_file %>
        echo "done"
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        *)
                echo $"Usage: glassfish {start|stop|restart}"
                exit
esac

Refactor th einit script in preparation for multiple domains
Refactor th einit script in preparation for multiple domains
