summaryrefslogtreecommitdiff
path: root/yarns.webapp/yarn.sh
blob: 3c617e3d0d865bde1b185fb5faa14ee91175824e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
}