1
# This file contains common functions for the tomcat hooks.ec
3
REMOTE_SERVICE=${JUJU_REMOTE_UNIT%/*}
4
# $JUJU_REMOTE_UNIT variable holds the name of the unit which reported to have
5
# -joined, -changed, or -departed
6
SERVICE=${JUJU_UNIT_NAME%/*}
7
# $JUJU_UNIT_NAME variable holds the name of the unit.
12
if [ -e "${file}" ]; then
13
egrep -v "^$1"$'(\t|$)' "${file}" > "${file}.new" || true
14
mv "${file}.new" "${file}"
17
echo_delimited $'\t' "$@" >> "${file}"
21
# Check the md5sum of file $1 and compare it against $2 exit on mismatch.
22
if [ `md5sum "$1" | cut -d " " -f 1` != $2 ]; then
23
juju-log --log-level CRITICAL "Checksum of $1 failed"
29
juju-log "Closing port $1 for ${VERSION}"
30
# Ask juju to close the port number.
34
create_relation_id () {
35
# Create a file for each relation in /etc/tomcatX/<relation_name>.relation
36
echo "${REMOTE_SERVICE}" > /etc/${VERSION}/${JUJU_RELATION_ID}.relation
37
# $JUJU_RELATION_ID variable holds the opaque relation identifier used to
38
# distingush between multiple relations with the same name.
47
printf %s%s "${d}" "${arg}"
53
# Replace % $ and / characters in the name and print the new name.
54
local name=${1//%/%25}
65
juju-log "Opening port $1 for ${VERSION}"
66
# Ask Juju to open the port for this unit.
71
# Get the path of the .d directory where the $1 file is built.
72
if dotdee -d "$1" 2> /dev/null; then
74
rm -rf "/etc/dotdee$1" "/etc/dotdee$1.d"
80
if egrep -v "^$2"$'(\t|$)' "$1" > "$1.new"; then
89
# Set the REMOTE_SERVICE variable to the name of the relation in the file.
90
REMOTE_SERVICE=`< /etc/${VERSION}/${JUJU_RELATION_ID}.relation`
b'\\ No newline at end of file'