summaryrefslogtreecommitdiffstats
path: root/99-ucs-4.1/service-wrapper.sh
blob: 64d1df5a1ba2c94411c850c9586ed7a243303233 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

# Check first parameter
if [ -z $1 ]; then
    echo "Service is not set"
    exit 1
fi

# Set trap and start service
trap "{ service $1 stop; exit 0; }" EXIT
service $1 start

# Set output to log-file and grep it
if [ -z $2 ]; then
    sleep infinity
else
    if [ -z $3 ]; then
        tail -f -n1 $2
    else
        tail -f -n1 $2 | grep $3
    fi
fi