dev/provisioning/modules/puppi/files/scripts/service.sh
author ymh <ymh.work@gmail.com>
Tue, 19 Jan 2016 19:18:34 +0100
changeset 109 d22ed5792f8e
parent 28 b0b56e0f8c7f
permissions -rwxr-xr-x
Correct transaction management. cf. bug https://openrdf.atlassian.net/browse/SES-2295 and tomcat default management of PUT request with form data (application/x-www-form-urlencoded encoded)

#!/bin/bash
# service.sh - Made for Puppi

# Sources common header for Puppi scripts
. $(dirname $0)/header || exit 10

# Show help
showhelp () {
    echo "This script is used to manage one or more services"
    echo "It requires AT LEAST 2 arguments:"
    echo "First argument (\$1 - required) is the script command (stop|start|restart|reload)"
    echo "Second argument and following (\$2 - required) is the space separated list of sevices to manage"
    echo
    echo "Examples:"
    echo "service.sh stop monit puppet"
}

# Check arguments
if [ $1 ] ; then
    servicecommand=$1
else
    showhelp
    exit 2
fi


if [ $# -ge 2 ] ; then
    shift
    services=$@
else
    showhelp
    exit 2
fi

# Manage service
service () {
    for serv in $services ; do
        /etc/init.d/$serv $servicecommand
    done
}

service