#!/bin/sh
# chkconfig: 2345 85 15
### BEGIN INIT INFO
# Provides: MSUWebService
# Required-Start: $network $syslog $MarvellRaidEventAgent
# Required-Stop: $network $syslog
# Default-Start: 1 2 3 5
# Default-Stop: 0 6
# Description: Marvell Storage Utility Web Service
### END INIT INFO

RETVAL=0

LD_LIBRARY_PATH=/opt/marvell/storage/apache2/lib:/opt/marvell/storage/expat/lib:/opt/marvell/storage/libxml2/lib:/opt/marvell/storage/openssl/lib:/opt/marvell/storage/php/lib

export LD_LIBRARY_PATH

start()
{
    iptables -I INPUT -p TCP --dport 8845 -j ACCEPT > /dev/null 2>&1
    ip6tables -I INPUT -p TCP --dport 8845 -j ACCEPT > /dev/null 2>&1
    echo -n "Starting Marvell Storage Utility Web Service."
    echo
        /opt/marvell/storage/apache2/bin/apachectl start
        RETVAL=$?
}

stop()
{
    iptables -D INPUT -p TCP --dport 8845 -j ACCEPT > /dev/null 2>&1
    ip6tables -D INPUT -p TCP --dport 8845 -j ACCEPT > /dev/null 2>&1
    echo -n "Stoping Marvell Storage Utility Web Service."
    echo
        /opt/marvell/storage/apache2/bin/apachectl stop
        RETVAL=$?
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    stop
    start
    ;;
esac

sleep 2

exit $RETVAL
