3 # Copyright (C) 2013-2014 W. Trevor King <wking@tremily.us>
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
8 # * Redistributions of source code must retain the above copyright notice, this
9 # list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright notice,
12 # this list of conditions and the following disclaimer in the documentation
13 # and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
27 # usage: DESCRIPTION="My IRC server" LOCATION="My attic" \
28 # EMAIL="admin@example.net" INFO="testing, testing" \
29 # setup-ngircd-config-from-environment
39 if [ -n "${GLOBAL_PASSWORD}" ]
41 ENVSUBST="${ENVSUBST} \${GLOBAL_PASSWORD}"
42 # In lines matching '# Global password' or the two succeeding lines,
43 # replace ';Password = .*' with 'Password = ${GLOBAL_PASSWORD}'
44 sed -i '/# Global password/,+2 s/;Password = .*/Password = ${GLOBAL_PASSWORD}/' /etc/ngircd/ngircd.conf
47 HOSTNAME=$(hostname -f) \
48 envsubst "${ENVSUBST}" < /etc/ngircd/ngircd.conf > /tmp/ngircd.conf &&
49 mv /tmp/ngircd.conf /etc/ngircd/ngircd.conf
51 if [ "${SSL}" = 'yes' ] || [ "${SSL}" = 'optional' ]
53 if [ "${SSL}" = 'optional' ]
55 sed -i 's/;Ports = 6667.*/Ports = 6667/' /etc/ngircd/ngircd.conf
58 -e 's/;\[SSL\]/[SSL]/' \
59 -e 's/;Ports = 6697, 9999/Ports = 6697/' \
60 /etc/ngircd/ngircd.conf
61 if [ -f '/etc/ngircd/ssl/server-cert.pem' ]
63 sed -i 's/;CertFile/CertFile/' /etc/ngircd/ngircd.conf
65 if [ -f '/etc/ngircd/ssl/server-key.pem' ]
67 sed -i 's/;KeyFile/KeyFile/' /etc/ngircd/ngircd.conf
69 if [ -f '/etc/ngircd/ssl/dhparams.pem' ]
71 sed -i 's/;DHFile/DHFile/' /etc/ngircd/ngircd.conf