Raspberry Pi setup as seedbox, IRC bouncer and ddns

I use Raspberry Pi B+ as IRC bouncer and seedbox-torrent server. I used Arch Linux because it provides me with the latest rolling versions of the software I need. This is a tutorial how to full set it up, mostly for me, just in case I want to make the same settings again.

This tutorial has the following sections:

  1. Create the SD card using Arch Linux
  2. Setup static ip
  3. Install some extra software
  4. Setup no-ip or inadyn client
  5. Install and setup ZNC (IRC Bouncer)
  6. Install Transmission (seedbox)

1. Create the SD card

Follow the official tutorial

Replace sdX in the following instructions with the device name for the SD card as it appears on your computer.

You can find the dev name using the command:

cat /proc/partitions

Unmount the SD card and start fdisk to partition the SD card:

sudo fdisk /dev/sdX

At the fdisk prompt, delete old partitions and create a new one:

Create and mount the FAT filesystem:

sudo mkfs.vfat /dev/sdX1
mkdir boot
sudo mount /dev/sdX1 boot

Create and mount the ext4 filesystem:

sudo mkfs.ext4 /dev/sdX2
mkdir root
sudo mount /dev/sdX2 root

Download and extract the root filesystem (as root, not via sudo):

wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
sudo bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
sudo sync
wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
sudo tar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
sudo sync

Move boot files to the first partition:

sudo mv root/boot/* boot

Unmount the two partitions:

sudo umount boot root

Insert the SD card into the Raspberry Pi, connect ethernet, and apply 5V power. Use the serial console or SSH to the IP address given to the board by your router. Login as the default user alarm with the password alarm. The default root password is root.

You can change the default passwrds using the command passwd.


2. Setup static ip

Edit the file eth0.network. Systemd-networkd uses *.network files.

nano /etc/systemd/network/eth0.network

paste the following (for static IP 192.168.1.100)

[Match]
Name=eth0

[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4

You will then need to disable netcl. To find out what is enabled that is netctl related, run this:

sudo systemctl list-unit-files

Once you identify all netctl related stuff. Go through and disable all netctl related stuff. You may have more to disable than just the below:

sudo systemctl disable netctl@eth0.service

You will then need systemd-networkd enabled:

sudo systemctl enable systemd-networkd

Login with

ssh alarm@192.168.1.100

3. Install some extra software (AUR and more)

The system is fully usable but I prefer to add some extra programs-tools (some might be already installed)

sudo pacman -S mc make wget fakeroot sudo packer htop ntfs-3g pkg-config

AUR

After some changes on pacman, there are some workarounds on how to install AUR.

Add users to a group with the gpasswd command as root:

sudo gpasswd -a alarm wheel

Go to sudoers

sudo nano /etc/sudoers

and change the wheel line

## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL

Reboot the system and give the follwing commands as user

wget https://aur.archlinux.org/cgit/aur.git/snapshot/package-query.tar.gz
tar -xvzf package-query.tar.gz
cd package-query
makepkg -si

You can do the same with yaourt

wget https://aur.archlinux.org/cgit/aur.git/snapshot/yaourt.tar.gz
tar -xvzf yaourt.tar.gz
cd yaourt
makepkg -si

ALTERNATIVE yaourt installation:

Open the file

sudo nano /etc/pacman.conf

And add

[archlinuxfr]
SigLevel = Optional TrustAll
Server = http://repo.archlinux.fr/arm/

Then install yaourt (as root):

sudo pacman -Sy yaourt

Then delete the archlinuxfr repo.

To delete the user from wheel group, first execute the command as root:

sudo gpasswd -d alarm wheel

and then go to sudoers

sudo nano /etc/sudoers

and change the wheel line (add #)

## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL

4. Setup no-ip or inadyn client

no-ip is the service I use for DDNS. It can be installed from AUR (yaourt -S noip). There were some changes on how to install AUR and that’s why I did it manually.

Most of the routers support it no-ip. You can use your router’s service. But what if you want 2 different host names on the same IP? Let’s say you have different ARM boards on the same router or you have a server etc.

First of all, install the needed programs to build the service (same as I did with ZNC)

sudo pacman -S gcc git make

Then

mkdir noip
cd noip

Download the program

wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz

and decompress it

tar vzxf noip-duc-linux.tar.gz

Go to the directory

cd noip-2.1.9-1

Compile and install

make
make install

While it installs the software you will prompted to enter the username & password. Once that is done it will ask you teh refresh interval … leave it.. to have the default value. You are required to answer some more questions … just answer NO and you should be good to go.

Start the client

/usr/local/bin/noip2

To check if the service is running, use the command:

/usr/local/bin/noip2 -S

and the results should be like

1 noip2 process active.

Process 1516, started as noip2, (version 2.1.9)
Using configuration from /usr/local/etc/no-ip2.conf
Last IP Address set EXTERNAL IP
Account USERNAME
configured for:
host HOSTNAME
Updating every 30 minutes via /dev/eth0 with NAT enabled.

Auto start the client on reboot

But what if you reboot? You want to start the client everytime you reboot. This can be done with systemd.

Create the service file.

sudo nano /usr/lib/systemd/system/noip.service

Add the following content.

[Unit]
Description=No-IP Dynamic DNS Update Client
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/bin/noip2

[Install]
WantedBy=multi-user.target

Start the service

sudo systemctl start noip.service

and enable the service

sudo systemctl enable noip.service

ALTERNATIVE

If you installed AUR, here is how you can setup no-ip service.

Install No-IP Client with yaourt.

yaourt -S noip

Configure No-IP Back-end

Create the configuration file.

noip2 -C

Enter the relevant details when prompted. All settings can be modified individually later.

Modify the update interval.

noip2 -U 30

Interval that the IP will be updated is set with -U option in minutes. Default is 30 minutes.

Modify No-IP username.

noip2 -u username

Modify No-IP password.

noip2 -p password

Start noip service.

sudo systemctl start noip2

Enable noip serive.

sudo systemctl enable noip2

5. Install and setup ZNC (IRC Bouncer)

ZNC is the software I use as IRC bouncer. I’m 24/7 online, keep logs of the channels I’m in. Raspberry Pi is the perfect solution for that since I don’t need CPU or GUI. Arch has the latest version that supports more than one server for a single user. Here is how to install-setup.

Install with the command:

sudo pacman -S znc

As user (alarm), run the command

znc --makeconf

and follow step by step the qustions to setup username-pass, port, channels, servers etc.

ZNC will run. If you want to start automatic, you have to add it as systemd service. I prefer to run it manually (znc) everytime I boot my Raspberry Pi. It’s easier to understand if the system was down or not.

When you run the IRC program, you have to add the username and server. The password shoud be like

username/freenode:password

You can also open your browser and go to http://IPSERVER:PORT to edit your settings.


6. Install Transmission (seedbox)

My SD card is 16GB. The total space to download files is about 14GB. It’s enough for everyday use.

I choose Transmission for this, because it is simple, fast and stable. Transmission has a good webinterface, plus it allows access from remote clients with the transmission-remote gui packages.

First install it with pacman:

sudo pacman -Syu transmission-cli

Enable the service at startup:

sudo systemctl enable transmission

Start the service:

sudo systemctl start transmission

Now create a folder where your user and the transmission group (where the transmission user belongs to) can read and write:

mkdir -p /mnt/torrents/{incomplete,complete,torrentfiles}
sudo chown -R alarm:transmission /mnt/torrents
sudo chmod -R 775 /mnt/torrents

In my example the folder /mnt/torrents is a folder. You can mount an external USB harddrive which can be mounted via /etc/fstab at boot. Remember to change alarm to your Pi username (if it’s different).

Stop the daemon to make sure the config file edits stick:

sudo systemctl stop transmission

Edit the default config file to allow remote access to the daemon (or do not do that and use an ssh tunnel every time) and update the downloads path:

sudo nano /var/lib/transmission/.config/transmission-daemon/settings.json

Change the following parameters:

    # From
    "download-dir": "/var/lib/transmission/Downloads",
    # To
    "download-dir": "/mnt/torrents/complete",

    # From:
    "incomplete-dir": "/var/lib/transmission/Downloads",
    # To
    "incomplete-dir": "/mnt/torrents/incomplete",

    # From
    "incomplete-dir-enabled": false,
    # To
    "incomplete-dir-enabled": true,

    # From
    "rpc-whitelist": "127.0.0.1",
    # To
    "rpc-whitelist": "*.*.*.*",

This sets the correct download folders and allows access from everywhere to the transmission webinterface. You can also list a range there (192.168.1.0/24) or just one IP address.

If you do not udate the ACL you get a nice error message when connecting:

403: Forbidden

Unauthorized IP Address.

Either disable the IP address whitelist or add your address to it.

If you're editing settings.json, see the 'rpc-whitelist' and 'rpc-whitelist-enabled' entries.

If you're still using ACLs, use a whitelist instead. See the transmission-daemon manpage for details.

If all went well you should be able to connect to http://YOUR-PI-IP:9091 and see the nice transmission webinterface.

If you want more info on Transmission on Arch Linux, read up on the arch wiki.


External links: