-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·67 lines (49 loc) · 1.24 KB
/
run
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
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -e
ZNC_USER=$1
ZNC_PASS=$2
# /opt/znc/state is expected to be bind-mounted into the container
ZNC_ROOT="/opt/znc/state"
# create the configs/ dir if it doesn't exist
if [ ! -d ${ZNC_ROOT}/configs ]; then
mkdir -p ${ZNC_ROOT}/configs
fi;
# create the znc.conf file if it doesn't exist
CONFIG_FILE=${ZNC_ROOT}/configs/znc.conf
if [ ! -e $CONFIG_FILE ]; then
# exit if there's no znc.conf but user and password were not provided
if [ $# -lt 2 ]; then
echo "Usage: $0 <USER> <PASSWORD>"
exit 1
fi;
ZNC_SALT="$(dd if=/dev/urandom bs=16c count=1 | md5sum | awk '{print $1}')"
ZNC_HASH="$(echo -n ${ZNC_PASS}${ZNC_SALT} | sha256sum | awk '{print $1}')"
cat<<EOF > ${CONFIG_FILE}
Version = 1.2
<Listener l>
Port = 6697
IPv4 = true
IPv6 = false
SSL = true
</Listener>
LoadModule = webadmin
<User $ZNC_USER>
Pass = $ZNC_HASH
Admin = true
Nick = $ZNC_USER
AltNick = ${ZNC_USER}_
Ident = $ZNC_USER
Buffer = 50
AutoClearChanBuffer = true
ChanModes = +stn
LoadModule = chansaver
LoadModule = webadmin
<Network freenode>
LoadModule = chansaver
LoadModule = nickserv
Server = chat.freenode.net +6667
</Network>
</User>
EOF
fi;
exec znc -r -f -d ${ZNC_ROOT}