Skip to main content

Raymii.org Logo (IEC resistor symbol)logo

Quis custodiet ipsos custodes?
Home | About | All pages | RSS Feed | Gopher

Install the latest ZNC from source on Ubuntu

Published: 25-10-2013 | Author: Remy van Elst | Text only version of this article


Table of Contents


This tutorial will show you how to install the latest (1.0) version of ZNC (anadvanced IRC bouncer) on Ubuntu from source. Why from source? The package in therepositories is quite old and missing features like multiple IRC networks. Italso includes an upstart script, and an example config for ZNC. ZNC is anadvanced IRC bouncer that is left connected so an IRC client candisconnect/reconnect without losing the chat session.

If you like this article, consider sponsoring me by trying out a Digital OceanVPS. With this link you'll get $100 credit for 60 days). (referral link)

This is tested on Ubuntu 12.04 and 13.10. It will probably work on debian, onlyyou will have to use an init script instead of an upstart script.

Note about checkinstall and packages

We are using checkinstall here to create a debian package of the source wecompile. I do this because it gives more flexibility in managing the softwareafterwards. Upgrading or uninstalling the packages is easier than removing allthe things make install placed. Furthermore, it makes it more clear for otheradministrators which software is installed.

If you for example want to upgrade znc when it was installed via this tutorialwith checkinstall, repeat the tutorial with only the version number changed.

Install required packages

We first need to make sure we have all the packages required to build ZNC.Install them via apt:

sudo apt-get install build-essential libssl-dev libperl-dev pkg-config checkinstall

Compile ZNC

Now we are going to get and compile ZNC itself. First download the source code:

cd /usr/local/srcsudo wget http://znc.in/releases/znc-latest.tar.gz

Extract it and move into the folder:

sudo tar -xzvf znc-latest.tar.gzcd znc*

Start the actual compilation:

./configuremakecheckinstall

For checkinstall, the default answers to the questions are good.

ZNC User

Create a separate ZNC user so that ZNC does not need to run as root:

sudo groupadd zncsudo adduser --system --home /var/lib/znc --group znc

Configuring ZNC

You can use the interactive wizard to configure ZNC. I advise you to do this, ithelps a lot when creating the initial configuration file:

sudo -u znc /usr/local/bin/znc --datadir=/var/lib/znc --makeconf

You can find my example config at the bottom of the tutorial.

Upstart script

Place the following script in /etc/init/znc.conf to be able to start and stopznc as a system service:

# zncdescription "IRC Bouncer"start on runlevel [2345]stop on runlevel [016]respawnrespawn limit 10 5setuid zncscript  exec /usr/local/bin/znc --datadir=/var/lib/znc -fend script

Save it, then you can start and stop znc like so:

sudo start zncsudo stop znc

Example ZNC configuration

This is an example ZNC configuration file. You can place this in/var/lib/znc/configs/znc.conf. Make sure to stop ZNC first:

// WARNING//// Do NOT edit this file while ZNC is running!// Use webadmin or *controlpanel instead.//// Buf if you feel risky, you might want to read help on /znc saveconfig and /znc rehash.// Also check http://en.znc.in/wiki/ConfigurationAnonIPLimit = 10ConnectDelay = 5LoadModule = partylineMaxBufferSize = 500ProtectWebSessions = trueSSLCertFile = /var/lib/znc/znc.pemServerThrottle = 30Version = 1.0<Listener listener0>  AllowIRC = true  AllowWeb = false  IPv4 = true  IPv6 = true  Port = 6667  SSL = true</Listener><User Example>  Admin = true  AltNick = Example_  AppendTimestamp = false  AutoClearChanBuffer = false  Buffer = 500  ChanModes = +stn  DenyLoadMod = false  DenySetBindHost = false  Ident = Example  JoinTries = 10  LoadModule = chansaver  LoadModule = controlpanel  LoadModule = perform  MaxNetworks = 3  MultiClients = true  Nick = Example  PrependTimestamp = true  QuitMsg = So long and thanks for all the fish!  RealName = Example  StatusPrefix = *  TimestampFormat = [%H:%M:%S]  <Network freenode>    FloodBurst = 4    FloodRate = 1.00    IRCConnectEnabled = true    LoadModule = chansaver    LoadModule = keepnick    LoadModule = kickrejoin    LoadModule = nickserv    LoadModule = perform    Server = irc.freenode.net 6667    <Chan #ansible>    </Chan>    <Chan #digitalocean>    </Chan>    <Chan #logstash>    </Chan>    <Chan #lowendbox>    </Chan>    <Chan #raspberrypi>    </Chan>    <Chan #reddit-sysadmin>    </Chan>    <Chan #sixgun>    </Chan>    <Chan #ubuntu>    </Chan>    <Chan #vpsboard>    </Chan>    <Chan #wordpress>    </Chan>    <Chan #znc>    </Chan>  </Network></User>

With this config file set up, you can point your IRC client to the ZNC server'sIP and port (6667) and automatically be connected to Freenode and a fewchannels.

Troubleshooting

If stuff doesn't work, try running ZNC like this:

sudo -u znc /usr/local/bin/znc --datadir=/var/lib/znc -f

It will give very clear and verbose errors about what is going wrong.

Tags: freenode, irc, irc-bouncer, source, tutorials, ubuntu, znc