aboutsummaryrefslogtreecommitdiffstats
path: root/testing/hosts/default
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2017-05-26 16:24:35 +0200
committerTobias Brunner <tobias@strongswan.org>2017-05-26 16:28:16 +0200
commit71d59af58aea080c8fe93630612e3a73067b506e (patch)
tree5e843aee6636cd0afe58bb113802b4b23535d9a9 /testing/hosts/default
parentb2473e94a21598eb818daee696e9fb0c7e87530d (diff)
downloadstrongswan-71d59af58aea080c8fe93630612e3a73067b506e.tar.bz2
strongswan-71d59af58aea080c8fe93630612e3a73067b506e.tar.xz
testing: Add wrapper around service command
When charon is started via service command LEAK_DETECTIVE_LOG is not set because the command strips the environment. Since we only want the variable to be set during the automated test runs we can't just set it in /etc/default/charon. Instead, we do so in this wrapper when charon is started and remove the variable again when it is stopped.
Diffstat (limited to 'testing/hosts/default')
-rwxr-xr-xtesting/hosts/default/usr/local/bin/service22
1 files changed, 22 insertions, 0 deletions
diff --git a/testing/hosts/default/usr/local/bin/service b/testing/hosts/default/usr/local/bin/service
new file mode 100755
index 000000000..c5db4f61b
--- /dev/null
+++ b/testing/hosts/default/usr/local/bin/service
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# LEAK_DETECTIVE_LOG is set for automated runs, however, `service` strips
+# the environment. This wrapper is used to set the variable for the charon
+# init script.
+
+ORIG=/usr/sbin/service
+CONF=/etc/default/charon
+
+if [[ "$1" != "charon" ]]; then
+ $ORIG "$@"
+fi
+
+if [[ "$2" == "start" && -n $LEAK_DETECTIVE_LOG ]]; then
+ echo "export LEAK_DETECTIVE_LOG=$LEAK_DETECTIVE_LOG" >> $CONF
+fi
+
+$ORIG "$@"
+
+if [[ "$2" == "stop" ]]; then
+ sed -i '/LEAK_DETECTIVE_LOG/d' $CONF 2>/dev/null
+fi