[Vtigercrm-developers] Startup Script

Per Qvindesland per at qvtech.cc
Sun Jun 3 23:49:51 PDT 2007


Hello List,

I created a shell startup script for a client, i got a bit tierd of
figuring out how to configure vtiger to start up during boot, so I
decided to do make one, if anyone feels like adding to it, using it or
improving on it then please feel free to do so, it works just fine on
Fedora Core 6 but it should also work on other distros, the only thing
the user should have to do is to edit the EXECDIR variable to his/her
vtiger path then copy it to the /etc/init.d dir as I.E vtiger umm
perhaps also chmod it to 655.

I hope it's useful for some.

Kind regards
Per Qvindesland


#!/bin/bash
#
# Description:    vtiger software startup and shutdown
# Vendor:    Per Qvindesland
# Created:    21. May 2007
# Author:    Per Qvindesland
#
# FileTarget:    /etc/init.d/vtiger
# FileOwner:    root.root
# FilePerms:    0655
#
# chkconfig:    2345 97 06
# $Id: vtiger,v 1.0 2007/05/21 05:00:28 $

# initialization
# adjust these variables to your environment
EXECDIR=/home/vtiger/vtigerCRM5


. /etc/rc.d/init.d/functions
 
RETVAL=0
VTIGERSTATUS=
MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes)

getvtigerstatus() {
    VTIGERSTATUSSTRING=$(ps ax | grep -v grep | grep $EXECDIR)
    echo $VTIGERSTATUSSTRING | grep $EXECDIR &> /dev/null
    VTIGERSTATUS=$?
}

start () {
    getvtigerstatus
    if [ $VTIGERSTATUS -eq 0 ] ; then
    echo "vtiger is already running"
    return 1
    fi
    echo -n "Starting Vtiger: "
     "$EXECDIR/bin/startvTiger.sh"
    RETVAL=$?
    if [ $RETVAL -eq 0 ] ; then
    # wait for server to be confirmed as started in logfile
    STATUSTEST=0
    ITERATIONS=0
    while [ $STATUSTEST -eq 0 ] ; do
        sleep 2
        tail -n 5 $LOGFILE | grep 'INFO.*\[Server\].*Started in' &>
/dev/null && STATUSTEST=1
        echo -n "."
        ITERATIONS=`expr $ITERATIONS + 1`
        if [ $ITERATIONS -gt $MAXITERATIONS ]
        then
            break
        fi
    done
    if [ $STATUSTEST -eq 0 ]
    then
        echo "Service hasn't started within the timeout allowed, please
review file $LOGFILE to see the status of the service"
        echo_warning
    else
        echo_success
    fi
    echo
    else
    echo_failure
    echo
    fi
    return $RETVAL
}

stop () {
    getvtigerstatus
    if [ $VTIGERSTATUS -ne 0 ] ; then
    echo "vtiger is already stopped"
    return 1
    fi
    echo -n "Stopping Vtiger: "
    export LASTLOG=`ls -t $VTIGER_HOME/logs/vtiger_.log | head -1`
    "$EXECDIR/bin/stopvTiger.sh"
    RETVAL=$?
    if [ $RETVAL -eq 0 ] ; then
    # wait for server to be confirmed as halted in logfile
    STATUSTEST=0
    ITERATIONS=0
    while [ $STATUSTEST -eq 0 ] ; do
        sleep 2
        tail -n 5 $LASTLOG | grep 'Halting VM' &> /dev/null && STATUSTEST=1
        echo -n "."
        ITERATIONS=`expr $ITERATIONS + 1`
        if [ $ITERATIONS -gt $MAXITERATIONS ]
        then
            break
        fi
    done
    if [ $STATUSTEST -eq 0 ]
    then
        echo "Service hasn't stopped within the timeout allowed, please
review file $LASTLOG to see the status of the service"
        echo_warning
    else
        echo_success
    fi
    echo
    else
    echo_failure
    echo
    fi
    return $RETVAL
}

restart () {
    stop
    start
}

condrestart () {
    getadempierestatus
    if [ $VTIGERSTATUS -eq 0 ] ; then
    restart
    fi
}

rhstatus () {
    getvtigerstatus
    if [ $VTIGERSTATUS -eq 0 ] ; then
    echo
    echo "vtiger is running:"
    ps ax | grep -v grep | grep $EXECDIR | sed
's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1
\2/'
    echo
    else
    echo "vtiger is stopped"
    fi
}

case "$1" in
    start)
    start
        ;;
    stop)
    stop
        ;;
    reload)
    restart
    ;;
    restart)
    restart
    ;;
    condrestart)
    condrestart
    ;;
    status)
    rhstatus
    ;;
    *)
        echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}"
        exit 1
esac
 
exit 0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20070604/2a820ba6/attachment-0003.bin 


More information about the vtigercrm-developers mailing list