summaryrefslogtreecommitdiffstats
path: root/99-ucs-4.1/service-wrapper.sh
diff options
context:
space:
mode:
Diffstat (limited to '99-ucs-4.1/service-wrapper.sh')
-rwxr-xr-x99-ucs-4.1/service-wrapper.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/99-ucs-4.1/service-wrapper.sh b/99-ucs-4.1/service-wrapper.sh
new file mode 100755
index 0000000..64d1df5
--- /dev/null
+++ b/99-ucs-4.1/service-wrapper.sh
@@ -0,0 +1,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