~marcoceppi/charms/precise/wesnoth/tests

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
#!/bin/sh
set -eux # -x for verbose logging to juju debug-log

juju-log "Configuring Wesnoth"

DEFAULT_CONF_FILE="/etc/default/wesnoth-1.10-server"
ETC_WESNOTHD="/etc/wesnothd-1.10.cfg"

MOTD=`config-get motd`
PASSWD=`config-get passwd`
CONNECTIONS_PER_IP=`config-get connections_per_ip`
PORT=`config-get port`

[ -z "$MOTD" ]               || (sed -i -e "/motd/ s:=.*:= \"${MOTD}\":" $ETC_WESNOTHD)
[ -z "$PASSWD" ]             || (sed -i -e "/passwd/ s:=.*:= \"${PASSWD}\":" $ETC_WESNOTHD)
[ -z "$CONNECTIONS_PER_IP" ] || (sed -i -e "/connections_allowed/ s:=.*:= ${CONNECTIONS_PER_IP}:" $ETC_WESNOTHD)

[ -z "$PORT" ] || (open-port $PORT/tcp; sed -i -e "/DAEMON/ s:-p.*:-p ${PORT}\":" $DEFAULT_CONF_FILE)

if service wesnoth-1.10-server status | grep -i "is running" ; then
    ./hooks/stop
    sleep 2s
fi

./hooks/start