Enabling more services on your Raspberry PI
Now that your home network has access to a central file repository, we should go further and see what else can our home server provide. We saw that an off the shelf NAS provides everything the corporate cloud has and more, could we replicate at least a fraction of that on our Raspberry PI?
Calendars and contacts
Sure! Calendars and contacts are easy. If you followed along, we created a user folder on our external drive connected to the Raspberry PI. In my case, the folder was called radu
. Since the calendars and the contacts are mine, I stored them in this folder. If you make a home-wide calendar and contact system you can store them in shared
. But for now, let’s:
#mkdir /mnt/storage/radu/personal
#mkdir /mnt/storage/radu/personal/user
We will reuse the personal
folder for more services in a moment, but for now we should be ok. Next, we need to install the calendars and contacts server. For every service you add to your setup, you have to configure a server for it. The server is just an application that runs in the background on your Raspberry PI that provides a specific service. For calendars and contacts I chose Xandikos:
#sudo python3 -m ensurepip
#sudo python3 -m pip install --upgrade xandikos
The above commands will install pip
and xandikos
, pip
being a package manager for python
. After that, we configure Xandikos to autostart by creating a service for it:
#sudo nano /etc/systemd/system/xandikos.service
Next copy the following listing in the editor (available on github):
[Unit]
Description=xandikos dav server
After=network.target
RequiresMountsFor=/mnt/storage/radu/personal[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/usr/local/bin/xandikos -d /mnt/storage/radu/personal -p 8081 -l 0.0.0.0[Install]
WantedBy=multi-user.target
A few things about the above: replace radu
with your user folder you created on your external drive. The port 8081
is the port Xandikos will listen on, meaning when you configure your calendar client (Outlook, Thunderbird or whatever) you will have to specify this port. The bit with -l 0.0.0.0
means Xandikos server will listen to requests from all IPs in your network, which is what you want to achieve. You can limit access here to only a few devices in your network but this is for another time.
Now that the service is configured, we need to start it and make sure it starts on every boot:
#sudo systemctl enable xandikos
#sudo systemctl start xandikos
Done. Our Raspberry PI has just become a calendar and contacts server. I wrote a small article covering how to sync your mobile phone with it.
Email archive
Next we would like to install an email server to archive our important emails. Just like with calendars and contacts, this requires an email server app and I chose Dovecot. Let’s install it:
#sudo dnf install dovecot
Done. Now we need to configure it, just like Xandikos. For Dovecot though, we just need to edit a configuration file and tell it where we want to save our email archive. Remember the personal
folder we created? Let’s put the email there:
#mkdir /mnt/storage/radu/personal/mail-archive
#sudo nano /etc/dovecot/conf.d/10-mail.conf
In the editor, we will look for mail location =
and we will add the newly created folder, so that it becomes:
mail_location = maildir:/mnt/storage/radu/personal/mail-archive
Done, the email server is up and running. If you want to archive your email here, in your email client add the Raspberry PI as an https email server (no port needed). The email client will recognize it and you can simply drag and drop your important email from your other places (Outlook, Gmail for example) in your own email server. Note that Dovecot is just a server used for mail storage, you won’t be able to send and receive emails with it. This is just for archiving your important email.
Media server
Can we do more? Yes, our Raspberry PI can act like a fully compliant DLNA media server, visible from all the media devices in your home. Smart TV for example. For this, we need to install a media server: I chose minidlna.
But first, where to store our media? Well we do have the /mnt/storage/media
folder we created earlier. Let’s set it up:
#mkdir /mnt/storage/media/videos
#mkdir /mnt/storage/media/photos
#mkdir /mnt/storage/media/music
Now to install minidlna, we need first to add a repository to our Fedora Server because minidlna is not in the default one:
#sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
#sudo dnf install minidlna
After installation, just like before we need to configure it by editing a configuration file:
#sudo nano /etc/minidlna.conf
In the configuration file we need to edit a few lines. I will just put them all in the listing below but you will have to match them to what you have already (also available on github):
user=some-user
network_interface=eth0
media_dir=A,/mnt/storage/media/music
media_dir=P,/mnt/storage/media/photos
media_dir=V,/mnt/storage/media/videos
friendly_name=Network media
Ok, user
has to be the user you created on your Raspberry PI. The network_interface
has to be eth0
if you connected the Raspberry PI to the network using a network cable. This is the connection type I recommend. If you connected the Raspberry PI to the home network using WiFi, instead of eth0
it will probably be wan0
or something similar. Note the media_dir
entries. A is for audio, P is for photos, V is for videos. Each of them having their respective folder. Next, we need to do a bit of plumbing:
sudo chown some-user:some-user /var/run/minidlna/minidlna.pid
sudo nano /usr/lib/systemd/system/minidlna.service
Replace some-user
with the user you created for your Raspberry PI. In the editor, set User=
and Group=
to your Raspberry PI user:
User=some-user
Group=some-user
Now we can start the media server:
#sudo systemctl enable minidlna
#sudo systemctl start minidlna
We are done. These are just some essential services you might want your Raspberry PI server to provide for your home network. These are a bit more advanced and you have to go through several configuration steps. If you find you cannot proceed with any of the above, the comment section is your friend. At least it gives me an indication of where the article lacks in detail and allows me to improve it and make it more useful. See you next time!