Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions znc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM centos:latest
MAINTAINER http://www.centos.org

ENV ZNC_VERSION=1.6.3 \
DATADIR=/var/lib/znc-data

LABEL summary="ZNC is an IRC bouncer" \
io.k8s.description="ZNC is an IRC bouncer" \
io.k8s.display-name="ZNC 1.6.3" \
io.openshift.expose-services="6667:znc" \
io.openshift.tags="znc,ircbouncer" \
Vendor="CentOS" \
License=GPLv2 \
Version=1.6.3


EXPOSE 6667

RUN INSTALL_PKGS="rsync tar gettext hostname bind-utils policycoreutils znc znc-devel" && \
yum -y install epel-release && \
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
yum clean all && \
mkdir -p /var/lib/znc-data && chown -R znc.0 /var/lib/znc-data && \
rpm -q --qf '%{version}' znc | grep -e '1\.6\.3' && \
test "$(id znc)" = "uid=997(znc) gid=996(znc) groups=996(znc)"

ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/znc

ADD root /

VOLUME ["/var/lib/znc-data"]

USER 997
ENTRYPOINT ["container-entrypoint"]
CMD ["run-znc"]
45 changes: 45 additions & 0 deletions znc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ZNC Docker image
====================

This container image includes ZNC-1.6.3 for OpenShift and general usage.

Environment variables and volumes
----------------------------------

The following environment variable influence the ZNC configuration file (and optional)

| Variable name | Description | Default
| :-------------------- | -------------------------------- | -------------------------
| `ZNC_ADMIN_PASSWORD` | Sets password for ZNC admin User | admin

You can also set the following mount points by passing the `-v /host:/container` flag to Docker.

| Volume mount point | Description |
| :----------------------- | ------------------ |
| `/var/lib/znc-data` | ZNC data directory |

**Notice: When mouting a directory from the host into the container, ensure that the mounted
directory has the appropriate permissions and that the owner and group of the directory
matches the user UID which is running inside the container.**

Usage
---------------------------------

For this, we will assume that you are using the `znc` image.
If you don't want to store the optional variable and data directory then execute the following command:

```
$ docker run -d --name znc -p 6667:6667 znc
```

This will create a container named `znc` running znc sever with `admin` as user
and `admin` credentials. Port 6667 will be exposed and mapped
to the host. If you want your ZNC to be persistent across container executions,
also add a `-v /host/znc/data:/var/lib/znc-data` argument. This will be the ZNC
data directory.


ZNC admin user
---------------------------------
The admin user has `admin` password set by default.
You can set it by setting the `ZNC_ADMIN_PASSWORD` environment variable.
5 changes: 5 additions & 0 deletions znc/cccp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This is for the purpose of building the container through the CentOS Communnity
# # Container Pipeline. https://github.com/CentOS/container-index

job-id: znc
test-skip: true
2 changes: 2 additions & 0 deletions znc/root/usr/bin/container-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
exec "$@"
18 changes: 18 additions & 0 deletions znc/root/usr/bin/generate_znc_conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/python3

import hashlib
import string
import os
from random import SystemRandom

raw_password = os.getenv('ZNC_ADMIN_PASSWORD', 'admin')

salt_chars = string.ascii_letters + string.digits
random = SystemRandom()
salt = "".join([random.choice(salt_chars) for i in range(20)])
hash_password = "sha256#{hash}#{salt}#".format(
hash=hashlib.sha256((raw_password+salt).encode('utf-8')).hexdigest(),
salt=salt)

print("{0}={1}".format('ADMIN_PASS', hash_password))

31 changes: 31 additions & 0 deletions znc/root/usr/bin/run-znc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Build modules from source.
if [ -d "${DATADIR}/modules" ]; then
# Store current directory.
cwd="$(pwd)"

# Find module sources.
modules=$(find "${DATADIR}/modules" -name "*.cpp")

# Build modules.
for module in $modules; do
echo "Building module $module..."
cd "$(dirname "$module")"
znc-buildmod "$module"
done

# Go back to original directory.
cd "$cwd"
fi

# Create default config if it doesn't exist
if [ ! -f "${DATADIR}/configs/znc.conf" ]; then
echo "Creating a default configuration..."
genrated=$(generate_znc_conf); export $genrated
mkdir -p "${DATADIR}/configs"
envsubst < ${CONTAINER_SCRIPTS_PATH}/znc.conf.default > ${DATADIR}/configs/znc.conf
fi

# Start ZNC.
znc --foreground --datadir="$DATADIR" $@
37 changes: 37 additions & 0 deletions znc/root/usr/share/container-scripts/znc/znc.conf.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// WARNING
//
// Do NOT edit this file while ZNC is running!
// Use webadmin or *controlpanel instead.
//
// Altering this file by hand will forfeit all support.
//
// But if you feel risky, you might want to read help on /znc saveconfig and /znc rehash.
// Also check http://en.znc.in/wiki/Configuration
ProtectWebSessions = true
ServerThrottle = 30
LoadModule = webadmin
Version = 1.6.1

<Listener l>
Port = 6667
IPv4 = true
IPv6 = true
SSL = false
</Listener>

<User admin>
Pass = ${ADMIN_PASS}
Admin = true
Nick = admin
AltNick = admin_
Ident = admin
RealName = Got ZNC?
Buffer = 50
AutoClearChanBuffer = true
ChanModes = +stn

LoadModule = chansaver
LoadModule = controlpanel
LoadModule = perform
</User>