From 4fc162b07b2e9d8489e16ed647e5d96f5c66e10a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 20 Jan 2014 14:24:27 +0000 Subject: Add new Lorry Controller --- yarns.webapp/yarn.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 yarns.webapp/yarn.sh (limited to 'yarns.webapp/yarn.sh') 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 +} -- cgit v1.2.1