Always On (IRC)

This blog post is more than 5 years old, so the content may be out of date.

Addicted to IRC?
Feel like you're missing out when you're not logged in?
You're not alone. But there is an answer! (And it's not a self-help group).

ZNC is an IRC bouncer. Basically, it stays permanently connected to the IRC servers; you connect to ZNC, and it re-plays any messages that were sent whilst you were disconnected.

ZNC: A quick installation guide

  1. Find a suitable server (something like a VPS which is permanently connected to the internet)
  2. Download the ZNC source-code
  3. Compile it
  4. Create a system-account to run the ZNC daemon
  5. Launch ZNC in configuration-mode (and setting the config-files to be stored somewhere sensible)
  6. Set up an init.d script to start/stop ZNC
  7. ???
  8. Profit! or something.

1. Find a suitable server

Personally, I use a single VPS node from VPS Net (mainly because I have a spare node, and I might as well use it for something, right?!)
Essentially, you want something that:

  • is permanently connected to the internet.
  • can access the IRC servers you want to access (i.e. can connect out on the relevant port - usually 6667).
  • is accessible from your internet connection (using an arbitrary TCP port - you can configure this in the znc config).

2. Download the ZNC source

wget http://znc.in/releases/znc-0.098.tar.gz
tar -xzf znc-0.098.tar.gz

I'm assuming here that you either have wget installed, or you can work out how to install wget yourself!

3. Compile ZNC

cd znc-0.098
./configure
make
sudo make install

If it doesn't compile, check you've got g++ installed (sudo apt-get install g++).

4. Create a system-account

You would usually want ZNC to run under its own account, so it's somewhat isolated from the rest of your system.

sudo useradd -r znc

This will usually give you a line in /etc/passwd which looks something like:

znc:x:999:999::/home/znc:/bin/sh

ZNC doesn't need a bash shell, so it's better security to remove it - I usually replace /bin/sh with /bin/false.

5. Launch ZNC in configuration-mode

By default, ZNC tries to load its config from its home directory. We've created a system account, so there is no home directory...instead I create /etc/znc.d and stick the config in there.

sudo mkdir /etc/znc.d
sudo mkdir /etc/znc.d/conf
sudo chown znc:znc -R /etc/znc.d
sudo -u znc znc --makeconf --datadir=/etc/znc.d/conf

It'll ask you a bunch of questions about how you want to configure ZNC, you can probably figure out the answers.

6. Set up an init.d script

Init.d scripts make it easy to start and stop the daemon (and allow it to run in the background).

Here's my init.d script at /etc/init.d/znc:

#!/bin/bash
 
## BEGIN INIT INFO
# Provides:          znc
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start ZNC at boot time
# Description:       Enable ZNC IRC bouncer.
### END INIT INFO
 
DATADIR='/etc/znc.d/conf'
DAEMON_OPTS='--datadir='$DATADIR
 
start() {
        echo -n "Starting : "
        echo
        start-stop-daemon --chuid znc:znc --start --exec /usr/local/bin/znc -- $DAEMON_OPTS
        return
}
 
stop() {
        echo -n "Shutting down : "
        echo
        start-stop-daemon --chuid znc:znc --stop  --exec /usr/local/bin/znc -- $DAEMON_OPTS
        return
}
 
 
 
case "$1" in
    start)
        start
        ;;
 
    stop)
        stop
        ;;
 
    restart)
        stop
        start
        ;;
 
    *)
        echo "Usage:  {start|stop|restart"
        exit 1
        ;;
esac
 
exit $?

Now you can simply use sudo /etc/init.d/znc start, sudo /etc/init.d/znc stop, etc.

This will configure your server to launch ZNC on startup:

sudo update-rc.d znc defaults

??? and profit!

OK, I don't know how this will profit you either. Go forth, feed your IRC addiction! (and if you work out the profit thing, mine's 10%, k?)

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <apache>, <bash>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.