summaryrefslogtreecommitdiff
path: root/yarns.webapp/yarn.sh
diff options
context:
space:
mode:
Diffstat (limited to 'yarns.webapp/yarn.sh')
-rw-r--r--yarns.webapp/yarn.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/yarns.webapp/yarn.sh b/yarns.webapp/yarn.sh
new file mode 100644
index 0000000..3c617e3
--- /dev/null
+++ b/yarns.webapp/yarn.sh
@@ -0,0 +1,56 @@
+# Copyright (C) 2013 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# =*= License: GPL-2 =*=
+
+# This file is a yarn shell library for testing Lorry Controller.
+
+
+# Kill a daemon given its pid file. Report whether it got killed or not.
+
+kill_daemon_using_pid_file()
+{
+ local pid=$(head -n1 "$1")
+ if kill -9 "$pid"
+ then
+ echo "Killed daemon running as $pid"
+ else
+ echo "Error killing daemon running as pid $pid"
+ fi
+}
+
+
+# Add a configuration item to a cliapp-style configuration file.
+
+add_to_config_file()
+{
+ if [ ! -e "$1" ]
+ then
+ printf '[config]\n' > "$1"
+ fi
+ printf '%s = %s\n' "$2" "$3" >> "$1"
+}
+
+
+# Ensure the standard input is empty. If not, exit with an error.
+
+stdin_is_empty()
+{
+ if grep . > /dev/null
+ then
+ echo "ERROR: stdin was NOT empty" 1>&2
+ exit 1
+ fi
+}