OK, so admittedly this is a bit of an experiment. The problem is that I have multiple machines in the house and want to back them up automatically (Mac, Windows and KDE neon walk into a bar…) and be able to access the files. Plus, I wouldn’t mind being able to play music through the server (eg, it is connected to the stereo) and it should have a public folder for file sharing.
This has now taken quite a few installs, including Openmediavault, Amahi Home Server, KDE neon and Ubuntu Server 19.04 (Updated samba for Time Machine) and 18.04. And during this process I have setup samba, Time Machine, Plex Media Server and god knows how many other programs trying to get what I wanted.
In the end I settled on,
- Ubuntu Server 18.04 as the base
- Nextcloud to receive backups and view files
Rclone to sync files with Nextcloud via WebDav
- Nextcloud-client to sync files
- Samba to share files between computers
- Mpd to play music on the server
1) The Base – Ubuntu server 18.04
I am not going to go into the installation of Ubuntu 18.04 to much as there are a lot of examples out there. The only important changes I made to the installation were,
- Setting a static IP
- Installing the SSH server
- Installing Nextcloud using the snap option
The ssh server installation is fairly standard but, for those in the know, I am not a fond lover of snaps so why did I use that option? Because it was easy. It stopped me having to install Apache, etc… Also, this is a bit of a test. If it works out I will probably put together a computer with raid and no fans but at the moment this is all running on an laptop so easy is good.
Speaking of which, in order to stop the laptop going into suspend each time I shut the lid I edited logind.conf with,
sudo nano /etc/systemd/logind.conf
I then changed one of the lines from,
Saved it with ctl+x and enter (if you don’t use nano then there are basic instructions here) and restarted logind.
sudo service systemd-logind restart
So that gave me the base to work from and a working instance of Nextcloud as well. Time to close the lid, ssh in
sudo apt update && sudo apt upgrade
After waiting a while to make sure it had restarted I went to the static IP Address I set up in step one in a browser. This took me to the Nextcloud instance where I was asked to enter a username and password for the Nextcloud admin.
I did, and hit enter but it took a long time to do anything after that. Maybe ten minutes or swirling circle? It’s hard to say as I thought I had done something wrong so I refreshed the page which broke everything and then reinstalled it, tried again, tried with a different browser, went and had a coffee while I thought about it, and returned to find it had finished whatever it was doing.
After that it has had a few slow patches but it seems to be working those out as time goes on. The major things I have done in Nextcloud are,
- Create some users
- Change the login screen (see top of post)
- Enable plugin for external drives (to be used later)
3) Nextcloud client
The Nextcloud Client is the program installed on my computer that allows me to sync a folder and Nextcloud.
To install the Nextcloud desktop client on KDE neon I opened Konsole and typed,
sudo add-apt-repository ppa:nextcloud-devs/client sudo apt update sudo apt install nextcloud-client
This installed the repository for the client, updated all my repositories and then installed the client.
On starting the client for the first time I was asked to login.
I selected login and was taken to the next screen where I entered my server address. In my case it was http://192.168.0.1
After filling in the address, I selected next and then logged into my Nextcloud server.
There are also various other options, for instance I could have logged into the Nextcloud server and then made an app only password under Settings/Personal/Security.
After setting up the client to login I was presented with another option screen where I could change the name and place of my sync folder. The default is a folder named Nextcloud in my home directory. I choose my entire home directory instead and then stopped the syncing of hidden files.
The samba setup is extremely easy. I only have one user, there is only going to be one folder shared so that people can easily move things around, especially if they are visiting and the instructions for this are virtually identical to setting up samba in KDE neon. So I ssh’d into the server and created the public folder with,
sudo apt install samba
This will install the server. The next step is to add yourself as a samba user. You have to be a user already to be a samba user so use your existing username or it won’t work.
sudo smbpasswd -a <insert username>
It will then ask you to enter your password and then confirm it. You don’t have to use your account password, in fact it is more secure to use a different one for networking as you tend to have to give it out so other can access it.
The next step is to backup the configuration file and then edit it. You can backup the file by typing,
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
Then edit it using nano.
sudo nano /etc/samba/smb.conf
At the very bottom of the file I am going to at the share definitions for a folder called Public in my home directory. This will probably already exist but if it doesn’t then create it. Change the <partstochange> to suit yourself.
[<share name>] path = /home/<username>/Public/ available = yes valid users = <username> read only = no browseable = yes public = yes writable = yes
So if my user name was squalidh then the share would look like,
[Squalidh Share] path = /home/squalidh/Public/ available = yes valid users = squalidh read only = no browseable = yes public = yes writable = yes
After finishing save the file and restart the samba server with,
sudo systemctl restart smbd
Then as a test I went to the Public folder with KDE neon, entered my username and password, created a folder called Music and copied some of my Music there. This will give me a place to point the music player daemon when I install it.
5) MDP – Music Player Daemon
The first thing to do is to make sure your system is capable of playing music from the command line. To do this I used mpg123 to play an mp3 file but that was at the end of a long period of trying to get sound working. So long I have forgotten most of what I actually did although thinking back it may be as simple (after all the installs, configs, and uninstalls) as installing alsa, setting up alsamixer, saving the settings and adding my user to the audio group. Anyway, what I am trying to say is make sure your sound is working before installing sound servers.
Eventually, I did get the sound working with alsa and installed mpd with,
sudo apt install mpd
and edited the config file which I am not going to post as it is too long so if it is handy you can download it below.
After that, it was just a matter of installing cantata on another computer, pointing it at the servers ip address and port 6600 and waiting for it to update.
It sort of fell over for me at the end, I prefer to be a little more sure of what I am doing but as a proof of concept the entire effort has been largely a success and justifies me doing it properly with a couple of drives in a RAID array, a silent motherboard, and a hell of a lot more security. But that is part two…
One month later…
It is all working quite well. I dropped rclone for the Nextcloud-client which is a little bit resource intensive for me on my computer but runs perfectly on the Mac.
I control MPD from my computer with Cantata which works well. There is definitely a lot more music in the house now. Everything is being backed up as well so it all appears to be a bit of a success and works much better that the QNAP setup I had. The next thing is to make up its own box and set it up permanently.