03-19-2009 10:40 AM
03-19-2009 07:02 PM
#!/bin/bash
#
# alfresco This shell script takes care of starting and stopping alfresco
#
# author: Jared Ottley
# email: jared dot ottley at alfresco dot com
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: alfresco
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start:
# Default-Stop:
# Description: Alfresco Enterprise Content Management 2.1.1
# Short-Description: start and stop alfresco
### END INIT INFO
#
NAME="$(basename $0)"
unset ISBOOT
if [ "${NAME:0:1}" = "S" -o "${NAME:0:1}" = "K" ]; then
NAME="${NAME:3}"
ISBOOT="1"
fi
# Path to alfresco root dir
_ALFRESCO="/opt/alfresco"
# Path to the alfresco launch script
_SCRIPT="${_ALFRESCO}/alfresco.sh"
# Alfresco program name
_PROG="$NAME"
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
SHUTDOWN_WAIT=30
RETVAL="0"
function checkpid() {
local i
for i in $* ; do
if [ -d "/proc/${i}" ]; then
return 0
fi
done
return 1
}
function echo_failure() {
echo -en "\\033[60G"
echo -n "[ "
echo -n $"FAILED"
echo -n " ]"
echo -ne "\r"
return 1
}
function echo_success() {
echo -en "\\033[60G"
echo -n "[ "
echo -n $"OK"
echo -n " ]"
echo -ne "\r"
return 0
}
function getIP() {
ipaddr=""
inet=$(ip addr show dev eth0 | grep "inet")
if [ "$inet" != "" ]; then
set – $inet
shift
echo ${1%%/*} | grep -E \([0-9]\{1,3\}.\{3\}\)[0-9]\{1,3\} > /dev/null
if [ $? -ne 1 ]; then
ipaddr=$(echo ${1%%/*} | sed -e s/[.]/-/g)
fi
fi
if [ $ipaddr = "" ]; then
return -1
fi
}
function updateVirtDomain() {
virt_server=${_ALFRESCO}/virtual-tomcat/conf/alfresco-virtserver.properties
virt_server_property=alfresco.virtserver.domain
if [ -e $virt_server ]; then
grep -E ^alfresco\.virtserver\.domain=\([0-9]\{1,3\}-\)\{3\}[0-9]\{1,3\} $virt_server
if [ $? -eq 0 ]; then
sed -i -r -e s/^${virt_server_property}=\([0-9]\{1,3\}-\)\{3\}[0-9]\{1,3\}/${virt_server_property}=${ipaddr}/ \
$virt_server
else
sed -i -r -e s/^${virt_server_property}=/${virt_server_property}=${ipaddr}/ \
$virt_server
fi
fi
}
# See how we were called.
function start() {
echo -n "Starting ${_PROG}: "
if [ -f "/var/run/${NAME}.pid" ]; then
read kpid < /var/run/${NAME}.pid
if checkpid $kpid 2>&1; then
echo "$NAME process already running"
return -1
else
echo "lock file found but no process running for"
echo "pid $kpid, continuing"
fi
fi
###Insert start script here###
getIP
if [ $? -ne -1 ]; then
updateVirtDomain
else
echo_failure
exit
fi
$_SCRIPT start
RETVAL="$?"
if [ "$RETVAL" -eq 0 ]; then
sleep 3
pidof -s java > /var/run/${NAME}.pid
echo_success
else
echo_failure
fi
echo
return $RETVAL
}
function status() {
RETVAL="1"
if [ -f "/var/run/${NAME}.pid" ]; then
read kpid < /var/run/${NAME}.pid
if checkpid $kpid 2>&1; then
echo "$0 is already running (${kpid})"
RETVAL="0"
else
echo "lock file found but no process running for pid $kpid"
fi
else
pid="$(pgrep -u root java)"
if [ -n "$pid" ]; then
echo "$0 running (${pid}) but no PID file exists"
RETVAL="0"
else
echo "$0 is stopped"
fi
fi
return $RETVAL
}
function stop() {
local STOP_VERBOSE="false"
echo -n "Stopping $_PROG: "
###Insert Stop script here###
$_SCRIPT stop
RETVAL="$?"
if [ "$RETVAL" -eq "0" ]; then
count="0"
if [ -f "/var/run/${NAME}.pid" ]; then
read kpid < /var/run/${NAME}.pid
until [ "$(ps –pid $kpid | grep -c $kpid)" -eq "0" ] || \
[ "$count" -gt "$SHUTDOWN_WAIT" ]; do
if [ "$STOP_VERBOSE" = "true" ]; then
echo -n -e "\nwaiting for processes $kpid to exit"
fi
sleep 1
let count="${count}+1"
done
if [ "$count" -gt "$SHUTDOWN_WAIT" ]; then
if [ "$STOP_VERBOSE" = "true" ]; then
echo -n -e "\nkilling processes which didn't stop"
echo -n -e "after "
echo -n "$SHUTDOWN_WAIT seconds"
fi
kill -9 $kpid
fi
echo_success
if [ "$count" -gt "0" ]; then
echo -n -e "\n"
fi
fi
rm -f /var/run/${NAME}.pid
else
echo_failure
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
status)
status
;;
*)
echo "Usage: $_PROG {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
04-07-2009 02:00 PM
#!/bin/sh
#
# Alfresco startup script
#
tomcatPID=`ps -ef|grep "/opt/Alfresco/tomcat"|grep java| awk '{print $2}'`
virtualTomcatPID=`ps -ef|grep "/opt/Alfresco/virtual-tomcat"|grep java| awk '{print $2}'`
ip=`/sbin/ifconfig eth0|grep "inet addr"|awk '{print $2}'|sed "s/addr://"`
case "$1" in
start)
echo "Today's IP address is $ip"
/opt/Alfresco/virtual_alf.sh start $ip
/opt/Alfresco/alfresco.sh start
;;
stop)
/opt/Alfresco/alfresco.sh stop
if ! test -z $tomcatPID
then
echo "Killing Tomcat process $tomcatPID"
kill -9 $tomcatPID
fi
/opt/Alfresco/virtual_alf.sh stop
if ! test -z $virtualTomcatPID
then
echo "Killing Virtual Tomcat process $virtualTomcatPID"
kill -9 $virtualTomcatPID
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
JAVA_OPTS="$JAVA_OPTS "-Djava.rmi.server.hostname=$2
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.