Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

How to install ZNC(IRC Bouncer) from ports

Joined
Mar 25, 2012
Messages
19,154
Thanks
1,850
#1
I'm going to assume you have a pool and jail folder already setup. I like to have each "service" run in its own ports jail. Some people do everything in one. It's totally personal preference how you want to do it. In my case I do a virgin jail so I'm going to use a virgin jail. If you want to do your own configuration you are welcome to. Just don't be shocked if you are a noob to this stuff and can't figure it out. If you are a noob to this stuff I recommend you use either a VM or a separate jail for every program. At least if you hose a program(or jail) badly you only lose that one program.

So here's how I did my jail:

1. Create a ports jail.

From the WebGUI click on the jails button at the top. Click the "Add Jails" button.


Enter your jail name(I used "znc"). Make sure the jail type is set to portjail and appropriate info for ipv4 and/or ipv6. I'm setting ipv4 to 192.168.2.210 and leaving everything else blank. I don't have ipv6 support from my ISP sadly. :(

Down at the bottom I make sure Autostart is checked and nothing else. Click "OK" so that the jail is created. Shouldn't take more than 2-4 minutes unless your CPU or internet is very slow or your internet speed is pathetically slow. Just wait it out.

2. Update the ports tree.

You will need to log into your jail as root. I won't discuss how since this is covered in the FreeNAS manual thorougly. Execute the following commands as root in your jail:

# portsnap fetch (This downloads the most recent snapshot from the Ports collection)

You will need to either install the ports collection or update it. Run one of the following. If you don't know which one to run, run the portsnap update. If that's not what you should do it'll give an error and tell you to do portsnap extract instead. It appears that while the portsnap tree files are in the default FreeNAS portsjail its not acknowledged. So first time in the jail you will be forced to do portsnap extract.

# portsnap update
-OR-
# portsnap extract

3. Now to update the ports you have. We will compile portmaster and use that to update the ports installed applications you already have.

# /usr/ports/ports-mgmt/portmaster
# make -DBATCH install clean

Then update the ports applications with:

# portmaster -a

If you get any errors you can add -f to rebuild and update all ports. WARNING: Doing -f could take a while if you have a lot of ports packages installed already so use with care!

Note: If you use PuTTY the window's title bar will show you how far along it is.

4. Now it's time to compile ZNC.

In the jail and as root user execute the following commands:

# cd /usr/ports/irc/znc
# make -DBATCH install clean (this compiles ZNC and its dependencies with default settings since I don't want to click "OK" as each package comes up with its options and I use the defaults anyway.)

This part took about 5 minutes in my virtual machine on my laptop. ZNC is now installed. If it takes longer just wait it out.

5. Create a user in the jail.

You'll pretty much never need to use this username again unless you do work in the jail regularly. So 'znc-admin' is probably just fine for you. The password for this user needs not be particularly secure unless you are SSHing directly into the jail's SSH service. In my case, I'm doing randomized password because I'll never be logging in as the user again. I'll always log in as root and then 'su znc-admin' to the user if I need to.

We need to create a user since you shouldn't be running znc as root. You can choose to force znc to run as the root user. I won't do it for security reasons and I won't explain how to do it with this guide either. As you can see I left most of the options at defaults.

# adduser

Username: znc-admin
Full name: ZNC Admin
Uid (Leave empty for default):
Login group [znc-admin]:
Login group is znc-admin. Invite znc-admin into other groups? []:
Login class [default]:
Shell (sh csh tcsh nologin) [sh]:
Home directory [/home/znc-admin]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]: yes
Lock out the account after creation? [no]:
Username : znc-admin
Password : <random>
Full Name : ZNC Admin
Uid : 1001 (Your number may not match this and is normal)
Class :
Groups : znc-admin
Home : /home/znc-admin
Home Mode :
Shell : /bin/sh
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (znc-admin) to the user database.
adduser: INFO: Password for (znc-admin) is XXXXXXXXX
Add another user? (yes/no): no
Goodbye!

6. Now we will switch to our newly created user and create our config file.

# su znc-admin
# cd /usr/ports/irc/znc
# znc --makeconf

ZNC is going to ask us a bunch of questions. Basically at this point I'm going to show you how to log into freenode and the freenas channel. I have chosen to use SSL because some people care about security and I figured "why not?" You are on your own for any other customized changes. If you ask about any customized settings I will delete your questions. This forum is not about ZNC support!

I chose to enable some modules. You can always enable/disable them in the admin WebGUI later too!

None of this stuff is RAM intensive or CPU intensive, so I'm not too worried about overextending my setup.

# znc --makeconf
[ ok ] Checking for list of available modules...
[ ** ] Building new config
[ ** ]
[ ** ] First let's start with some global settings...
[ ** ]
[ ?? ] What port would you like ZNC to listen on? (1025 to 65535): 5000
[ ?? ] Would you like ZNC to listen using SSL? (yes/no) [no]: yes
[ ** ] Unable to locate pem file: [/home/znc-admin/.znc/znc.pem]
[ ?? ] Would you like to create a new pem file now? (yes/no) [yes]: (hit enter)
[ ok ] Writing Pem file [/home/znc-admin/.znc/znc.pem]...
[ ?? ] Would you like ZNC to listen using ipv6? (yes/no) [yes]: no
[ ?? ] Listen Host (Blank for all ips):
[ ok ] Verifying the listener...
[ ** ]
[ ** ] -- Global Modules --
[ ** ]
[ ** ] +-----------+----------------------------------------------------------+
[ ** ] | Name | Description |
[ ** ] +-----------+----------------------------------------------------------+
[ ** ] | partyline | Internal channels and queries for users connected to znc |
[ ** ] | webadmin | Web based administration module |
[ ** ] +-----------+----------------------------------------------------------+
[ ** ] And 10 other (uncommon) modules. You can enable those later.
[ ** ]
[ ?? ] Load global module <partyline>? (yes/no) [no]: yes
[ ?? ] Load global module <webadmin>? (yes/no) [no]: yes
[ ** ]
[ ** ] Now we need to set up a user...
[ ** ]
[ ?? ] Username (AlphaNumeric): cyberjock (This is the username you want to use for the "admin" account, not for IRC. I choose to use the same name for both though!)
[ ?? ] Enter Password: (This is the password for the "admin" account for ZNC)
[ ?? ] Confirm Password: (Type the same password you typed above)
[ ?? ] Would you like this user to be an admin? (yes/no) [yes]: (hit enter)
[ ?? ] Nick [cyberjock]: cyberjock
[ ?? ] Alt Nick [cyberjock_]: (hit enter)
[ ?? ] Ident [cyberjock]: (hit enter)
[ ?? ] Real Name [Got ZNC?]: (Don't put your real name here unless you want the world to know your real name!)
[ ?? ] Bind Host (optional): (hit enter)
[ ?? ] Number of lines to buffer per channel [50]: 5000 (I like to go overboard)
[ ?? ] Would you like to clear channel buffers after replay? (yes/no) [yes]: no (Personal choice)
[ ?? ] Default channel modes [+stn]:
[ ** ]
[ ** ] -- User Modules --
[ ** ]
[ ** ] +--------------+------------------------------------------------------------------------------------------+
[ ** ] | Name | Description |
[ ** ] +--------------+------------------------------------------------------------------------------------------+
[ ** ] | chansaver | Keep config up-to-date when user joins/parts |
[ ** ] | controlpanel | Dynamic configuration through IRC. Allows editing only yourself if you're not ZNC admin. |
[ ** ] | perform | Keeps a list of commands to be executed when ZNC connects to IRC. |
[ ** ] +--------------+------------------------------------------------------------------------------------------+
[ ** ] And 22 other (uncommon) modules. You can enable those later.
[ ** ]
[ ?? ] Load module <chansaver>? (yes/no) [no]: (hit enter)
[ ?? ] Load module <controlpanel>? (yes/no) [no]: (hit enter)
[ ?? ] Load module <perform>? (yes/no) [no]: (hit enter)
[ ** ]
[ ?? ] Would you like to set up a network? (yes/no) [no]: yes
[ ?? ] Network (e.g. `freenode' or `efnet'): freenode
[ ** ]
[ ** ] -- Network Modules --
[ ** ]
[ ** ] +-------------+-------------------------------------------------------------------------------------------------+
[ ** ] | Name | Description |
[ ** ] +-------------+-------------------------------------------------------------------------------------------------+
[ ** ] | chansaver | Keep config up-to-date when user joins/parts |
[ ** ] | keepnick | Keep trying for your primary nick |
[ ** ] | kickrejoin | Autorejoin on kick |
[ ** ] | nickserv | Auths you with NickServ |
[ ** ] | perform | Keeps a list of commands to be executed when ZNC connects to IRC. |
[ ** ] | simple_away | This module will automatically set you away on IRC while you are disconnected from the bouncer. |
[ ** ] +-------------+-------------------------------------------------------------------------------------------------+
[ ** ] And 16 other (uncommon) modules. You can enable those later.
[ ** ]
[ ?? ] Load module <chansaver>? (yes/no) [no]: (hit enter)
[ ?? ] Load module <keepnick>? (yes/no) [no]: yes
[ ?? ] Load module <kickrejoin>? (yes/no) [no]: (hit enter)
[ ?? ] Load module <nickserv>? (yes/no) [no]: yes
[ ?? ] Load module <perform>? (yes/no) [no]: (hit enter)
[ ?? ] Load module <simple_away>? (yes/no) [no]: (hit enter)
[ ** ]
[ ** ] -- IRC Servers --
[ ** ] Only add servers from the same IRC network.
[ ** ] If a server from the list can't be reached, another server will be used.
[ ** ]
[ ?? ] IRC server (host only): irc.freenode.net
[ ?? ] [irc.freenode.net] Port (1 to 65535) [6667]: 7000
[ ?? ] [irc.freenode.net] Password (probably empty): (hit enter)
[ ?? ] Does this server use SSL? (yes/no) [no]: yes
[ ** ]
[ ?? ] Would you like to add another server for this IRC network? (yes/no) [no]: (hit enter)
[ ** ]
[ ** ] -- Channels --
[ ** ]
[ ?? ] Would you like to add a channel for ZNC to automatically join? (yes/no) [yes]: (hit enter)
[ ?? ] Channel name: #freenas
[ ?? ] Would you like to add another channel? (yes/no) [no]: (hit enter)
[ ?? ] Would you like to set up another network? (yes/no) [no]: (hit enter)
[ ** ]
[ ?? ] Would you like to set up another user? (yes/no) [no]: (hit enter)
[ ok ] Writing config [/home/znc-admin/.znc/configs/znc.conf]...
[ ** ]
[ ** ] To connect to this ZNC you need to connect to it as your IRC server
[ ** ] using the port that you supplied. You have to supply your login info
[ ** ] as the IRC server password like this: user/network:pass.
[ ** ]
[ ** ] Try something like this in your IRC client...
[ ** ] /server <znc_server_ip> +5000 cyberjock:<pass>
[ ** ] And this in your browser...
[ ** ] https://<znc_server_ip>:5000/
[ ** ]
[ ?? ] Launch ZNC now? (yes/no) [yes]: no

Now to go back to the root user.

# exit

7. Now to setup znc to run on jail startup.

This sets up the environment for ZNC and makes it load on jail startup.

sysrc znc_user=znc-admin
sysrc znc_enable=yes
sysrc znc_conf_dir=/usr/home/znc-admin/.znc

8. Now to log out of the jail and see if this works.

# exit

In the FreeNAS WebGUI turn the jail off. Wait about 5 seconds, then turn the jail back on.

If you are logged in on another IRC client and in the FreeNAS IRC channel you should see your username show up in the channel within about 20 seconds. It's not instant since the jail has to "boot up".

If you did everything correctly you are now ready to go to the webgui and/or use the IRC client.

Try something like this in your IRC client...
/server <znc_server_ip> +5000 <username>:<pass>
And this in your browser...
https://<znc_server_ip>:5000/

First you'll want to setup your IRC server or at least look around at the WebGUI. Go to: https://<znc_server_ip>:5000/ and login with the username and password you provided to the ZNC configurator. You can look around and make settings changes here. Keep in mind that modules have to be "reloaded" when you change settings. See the ZFS guides for how to do that or setup all the settings you want, then cycle the jail off and on. I setup everything how I wanted it, then cycled it off and on.

There are many IRC clients out there. Here's how to do it with HexChat...

1. Install HexChat from hexchat.github.io.com . Keep in mind you may have to install the Visual Studio 2012 Redistributable.
2. Open HexChat. For Nick Name Put your nickname that you gave ZNC. I put 'cyberjock'.
3. Click the Add button to add a network. Put in a name for your server. I named it the same as the IP because I'm so original! I put 192.168.2.210.
4. Click on the newly added server and click "Edit".
5. Check out the below settings and make sure the settings match mine. You don't have to choose "Connect to selected server only" or "Connect to this network automatically" but connecting automatically is probably a smart idea.
Untitled.jpg

6. Click "Close".
7. If you did everything correctly you should be able to click "Connect" and connect to your bouncer, which is connected to the #FreeNAS IRC! Say hello to everyone! I might be there to say hello back!

Congrats! You should be up and running if you did everything correctly. If you have problems with ZNC itself you should go to the ZNC documentation, ZNC IRC channel, or ZNC forum. Support for ZNC is not intended to be provided here in the FreeNAS forums. However, if you have information that may be useful for other users, feel free to post it. I will delete threads/posts asking for support with ZNC itself.

NOTE1: You may want to consider doing a second connection for IRC on port 6667 to support some crappy IRC clients. I use Chatzilla(Firefox addon) and it did not like providing a port number. So using the ZNC WebGUI and setting up port 6667 to listen to fixed some problems.

NOTE2: You may also have to disable SSL support on the IRC port your bouncer is listening from as some IRC clients don't do SSL support at all, and some others don't let you do self-signed certificates.
 
Joined
Mar 25, 2012
Messages
19,154
Thanks
1,850
#2
Reserved.
 
Joined
Mar 25, 2012
Messages
19,154
Thanks
1,850
#4
Good tutorial, thanks! Can also be used as a "how to install anything in a jail" tutorial :D

- Sent from mobile.
That was supposed to be the "hidden" truth. ;)
 

Dusan

FreeNAS Guru
Joined
Jan 29, 2013
Messages
1,165
Thanks
297
#5
What is the reason for using ports instead of pkg? You can replace steps 2, 3 and 4 by "pkg install znc". It's just one simple command (run it and answer yes twice to upgrade pkg and perl) and it's done in less then 1 minute. You con continue directly to creating the user and running znc --makeconf.
 
Joined
Mar 25, 2012
Messages
19,154
Thanks
1,850
#6
Because of what I said just above your post.. it was meant as a hidden guide to learning how to use ports for those that want to learn ports. :p

When it comes to doing guides, presentations, etc I rarely have a single agenda. If I can accomplish hidden goals at the same time I go for it. Especially when it deals with imparting knowledge and experience.
 
Joined
Oct 28, 2012
Messages
17
Thanks
1
#7
thx cyberjock, this write up made it a peace of cake to get this done!
one little comment: after folowing useradd, no group is created for this user in the jail.
When running the config, this gives an error, so you'l have to do this manualy (adding the required directory and setting it as the user's home folder)
 
Joined
Jan 28, 2014
Messages
56
Thanks
7
#8
Not sure what's going on for me. Tried installing from ports and pkg, both yield the same result.
Code:
$ znc
/usr/lib/libstdc++.so.6: version GLIBCXX_3.4.11 required by /usr/local/bin/znc not found


I can overcome this temporarily by setting my LD_LIBRARY_PATH to /usr/local/lib/gcc48, then I can get it to launch. However, once the jail is restarted, I run into the same error until I set LD_LIBRARY_PATH.

I've tried to overcome it by adding the ldconfig_paths to /etc/rc.conf:
Code:
ldconfig_paths="/usr/local/lib/gcc48"
znc_user="znc"
znc_enable="yes"
znc_conf_dir="/home/znc/.znc"


No dice. Any ideas?
 
Joined
Jan 28, 2014
Messages
56
Thanks
7
#9
Not sure what's going on for me. Tried installing from ports and pkg, both yield the same result.
Code:
$ znc
/usr/lib/libstdc++.so.6: version GLIBCXX_3.4.11 required by /usr/local/bin/znc not found


I can overcome this temporarily by setting my LD_LIBRARY_PATH to /usr/local/lib/gcc48, then I can get it to launch. However, once the jail is restarted, I run into the same error until I set LD_LIBRARY_PATH.

I've tried to overcome it by adding the ldconfig_paths to /etc/rc.conf:
Code:
ldconfig_paths="/usr/local/lib/gcc48"
znc_user="znc"
znc_enable="yes"
znc_conf_dir="/home/znc/.znc"


No dice. Any ideas?
I've actually found a solution. This is pretty much a work around until the package maintainer actually fixes the read issue. Using 'patchelf', I actually got it to use the correct gblic library.

Code:
pkg install patchelf

After installing, I ran patchelf, pointing it to gcc48.
Code:
patchelf --set-rpath /usr/local/lib/gcc48 /usr/local/bin/znc

It works!
Code:
$ znc --version
ZNC - 1.6.0 - http://znc.in
IPv6: yes, SSL: yes, DNS: threads, charset: no
 

paradoxiom

FreeNAS Experienced
Joined
Jun 16, 2015
Messages
139
Thanks
4
#10
Hey guys,

I installed ZNC in a jail used pkg, and when I go to

Code:
/mnt/OrbitalHub/Jails/ZNC


and do:

Code:
--znc makeconf


I get:

Code:
[znc-admin@OrbitalHub] /mnt/OrbitalHub/Jails/ZNC% znc --makeconf y

CORRECT>nc --makeconf y (y|n|e|a)? yes
nc: unrecognized option `--makeconf'
usage: nc [-46DdEFhklNnrStUuvz] [-e policy] [-I length] [-i interval] [-O length]
          [-P proxy_username] [-p source_port] [-s source] [-T ToS]
          [-V rtable] [-w timeout] [-X proxy_protocol]
          [-x proxy_address[:port]] [destination] [port]


Where am I going wrong?

Thanks,
para
 
Joined
Jan 28, 2014
Messages
56
Thanks
7
#11
That's because you have to execute it inside a jail. Not directly on the host.

Switch to the jail but running (must be root on FreeNAS)

Code:
jexec <jailname> /bin/csh
 

paradoxiom

FreeNAS Experienced
Joined
Jun 16, 2015
Messages
139
Thanks
4
#12
Code:
[root@OrbitalHub] ~# jexec ZNC /bin/csh
root@ZNC:/ # --znc makeconf
--znc: Command not found.
root@ZNC:/ # cd /mnt/OrbitalHub/Jails/ZNC
/mnt/OrbitalHub/Jails/ZNC: No such file or directory.
root@ZNC:/ # su znc-master
su: unknown login: znc-master
root@ZNC:/ # su znc-admin
su: unknown login: znc-admin
root@ZNC:/ # znc --makeconf
znc: Command not found.
root@ZNC:/ #


must be going wrong somewhere here. thanks .
 

paradoxiom

FreeNAS Experienced
Joined
Jun 16, 2015
Messages
139
Thanks
4
#13
I am trying to execute znc --makeconf in the ZNC jail shell, but all I'm getting in return is 'znc: Command not found. '

I'm supposed to even be using "znc-admin" account for this, too, right?

But if I login with SSH using that account, and I try to jexec into the ZNC jail, it tells me:
Code:
[znc-admin@OrbitalHub] /% jexec ZNC tsch
jexec: jail_attach(13): Operation not permitted
[znc-admin@OrbitalHub] /%


I tried giving the znc-admin account sudo, wheel group as secondary / root as primary, something just ain't working for me.
 

paradoxiom

FreeNAS Experienced
Joined
Jun 16, 2015
Messages
139
Thanks
4
#14
all right, I've created the user within the jail,

# su znc-admin
# cd /usr/ports/irc/znc
# znc --makeconf

I can now su znc-admin, but because I used the pkg install method, going to /usr/ports/irc/znc and doing znc --makeconf results in :

Code:
root@ZNC:/ # su znc-admin                                                      
$ cd /usr/ports/irc/znc                                                        
$ znc --makeconf                                                               
znc: not found                                                                 
$      
 
Joined
Jan 28, 2014
Messages
56
Thanks
7
#15
I suggest you re-read the the first post again carefully.
 
Joined
Aug 27, 2018
Messages
18
Thanks
6
#17
Thank you!

I did need to add the following line inside the jail before the installation from ports:

Code:
 nano /etc/make.conf
ALLOW_UNSUPPORTED_SYSTEM=yes
 

paradoxiom

FreeNAS Experienced
Joined
Jun 16, 2015
Messages
139
Thanks
4
#18
I'm trying this again with FreeNAS-11.2-U3

Stumbling here:
root@ZNC:/ # /usr/ports/ports-mgmt/portmaster
/usr/ports/ports-mgmt/portmaster: Permission denied.
root@ZNC:/ #
 
Top