Configuration

Configuration and Administration articles relating to operating systems, software and anything else tech related. 

This is a post to help me remember how to do this as I will probably forget by the time I need to do this again.

I have a NAS (Buffalo 2TB) on which I keep my music, movies and other media ripped from CD, DVD or bought online** so as to be able to access it from which ever of the 3 computers (Desktop, Laptop and Raspberry Pi) in the house I am using.

The issue I was having is that Plex doesn't work with the share on the NAS directly, on Windows it is fairly easy to fix you just map the drive to folder(s) required, for instance on my Windows install I have the movies(films) mapped to the F drive, my music (MP3) mapped to the M drive and the TV shows mapped to the T drive.

On my Linux installs which I use more than the Windows install I was having the issue that Plex would only see local files on the PC not the NAS files.

To map the drive on Linux you use the mount command to "attach" the NAS shares to a folder/location on the local PC.

First create a folder to mount the share to:

As root (or use sudo)

mkdir /mnt/nas

This creates the folder/location nas under the mnt directory

The mount command can be tested using the command line

mount -t cifs //ip-address-of-nas/share /mnt/nas -o username=nobody

This should mount the NAS share to /mnt/nas and if you go to /mnt/nas you should be able to see the folders/files there now.

Now it is a bit of a pain to remember to do this all the time so you can automate it by adding an entry to the fstab file (/etc/fstab), this file mounts all the relevant filesystems on boot.

Rather than put username and password details directly in fstab it is a good idea to put these into another file so you can change permissions to restrict who can view the details.

Create a file anywhere you like, I put it in /etc and call it what you like i.e nasdetails. To create file

touch /etc/nasdetails

Edit the file

nano /etc/nasdetails

The file should contain two lines

username=nobody

password=PASSWORD

Obviously change PASSWORD to your nas password then save file and change permissions so only root can read

chmod 400 /etc/nasdetails

now you can edit the fstab file

nano /etc/fstab

Add the following to it

//ip-of-nas/share /mnt/nas cifs uid=1000,gid=1000,credentials=/etc/nasdetails  0 0

Save file.

you can reload the fstab using

mount -a

You should now be able to browse to /mnt/nas and see the files on the nas as if they were local.

You can now add any media folders to Plex*.

* Will probably help with other programs as well.

**Don't pirate stuff folks ;)

Background info: My home desktop PC is running Slackware 14.0 with the Xfce desktop.

Issue 1

When I fired up the computer today there were no window decorations (window borders, title bars, those little buttons you use to maximise/minimise and close windows) and I could not drag or adjust windows. This has happened before and it seems to be an issue with the xfwm4 (the Xfce window manager) not starting properly. There are a couple of ways to sort this but I use the easiest way which is to fire up a terminal window and type xfwm4 and press enter and this brings back all the window decorations.

Issue 2

Unable to delete files from external harddrive using file manager. This is something that I had noticed before but it wasn't really an issue that I was bothered about since I usually delete stuff from the command line. The basic problem is that if I was trying to delete a file through Thunar (the file manager used by Xfce) either by selecting the file and pressing delete or by right clicking the file and selecting the Delete option I was presented with a dialog stating "Unable to find or create Trash directory". After searching the internet I found out that my external harddrive didn't have a Trash directory for my user. To remedy this i recreated the required trash directory and hierarchy.

mkdir /freeagent/.Trash-1000

mkdir /freeagent/.Trash-1000/files

mkdir /freeagent/.Trash-1000/info

mkdir /freeagent/.Trash-1000/expunged

After this deletion of files worked as expected.

This is a follow on post from Setting up ownCloud on Slackware 14.0 (part 1 - the server) and Setting up ownCloud on Slackware 14.0 (part 2 - the client). If you have completed these first two then you have a fully functional ownCloud install that allows you to synchronise your files across multiple devices.

In this 3rd part I am setting up SSL to allow secured connections using an HTTPS URL.

First thing to do is to get the SSL certificate for use. If you are doing this on a professional site/server you will probably need to purchase an official certificate from a CA (certificate Authority) , but as I am doing this on my own computer I am using a self signed certificate.

These instructions are taken from http://www.apache-ssl.org/#FAQ

Step one - create the key and request:

openssl req -new > new.cert.csr

Step two - remove the passphrase from the key (optional):

openssl rsa -in privkey.pem -out new.cert.key

Step three - convert request into signed cert:

openssl x509 -in new.cert.csr -out new.cert.cert -req -signkey new.cert.key -days 365

You now have three certificate files new.cert.key, new.cert.csr and new.cert.cert. These can be placed wherever is appropriate but I placed then in the /etc/httpd/ directory so the path to these is /etc/httpd/new.cert.key and so on, these paths are needed later on when they are added to the webserver configuration.

Once you have the certificates you need to make sure that your webserver can use ssl, this is done by uncommenting the mod_ssl module line in /etc/httpd/httpd.conf by removing the hash at the beginning of the line

#LoadModule ssl_module lib/httpd/modules/mod_ssl.so
to give
LoadModule ssl_module lib/httpd/modules/mod_ssl.so

The server needs to be restarted before changes will take place, I find it is usually a good idea to restart after a single change rather than do a lot of changes this way you can know which change causes errors if any. So restart apache by issuing the command

apachectl restart

If all is well the server will restart without issue, you can check the logs at /var/log/httpd/ to troubleshoot.

Now we need to tell the server where to find our SSL certificates and sedtup the correct port of 443, this is done in the /etc/httpd/extra/https-ssl.conf file.

The Apache-SSL directives that you need to use the resulting cert are SSLCertificateFile and SSLCertificateKeyFile directives. Search the httpd-ssl.conf file and edit it to add the paths to your previously made certificates. The required lines are:

SSLCertificateFile /etc/httpd/new.cert.cert and
SSLCertificateKeyFile /etc/httpd/new.cert.key

Add these details to the VirtualHost section along with the ServerName, ServerAdmin, error logs etc and turn on the ssl engine, your VirtualHost section should start similar to this (parts removed for clarity)

<VirtualHost _default_:443>

DocumentRoot "/srv/httpd/htdocs"
ServerName 127.0.0.1:443
ServerAdmin your_email_address_here
ErrorLog "/var/log/httpd/error_log"
TransferLog "/var/log/httpd/access_log"

SSLEngine on

SSLCertificateFile "/etc/httpd/new.cert.cert"
SSLCertificateKeyFile "/etc/httpd/new.cert.key"
.
.
.
.
</VirtualHost>

This part sets up the server to respond to secure (https) traffic by using the created certificates. Again once this done you need to restart the server as done previously.

If all has gone well you now need to setup the ownCloud client to connect using https. This is done through the client setup as in the previous post (Setting up ownCloud on Slackware 14.0 (part 2 - the client)). Make sure you use https:// in front of the url or you will not be able to access ownCloud (I forgot to change from http to https and it took me a while to work out why my previously working install was no longer working).

This a follow up article to Setting up ownCloud on Slackware 14.0 (part 1 - the server) and a prelude to Setting up ownCloud on Slackware 14.0 (part 3 - Encryption using SSL) although you could setup the SSL/HTTPS on the server before setting up the client.

Once the server is setup and you can login to ownCloud through the web browser the next thing to do is to install the ownCloud client application on any required user machines (there is also an ownCloud app available for use on Windows, MacOS and tablets/phones running Android and IOS). Installing the client application allows for users to sync their data/documents/media across all machines or devices they own.

The clients for Windows, Mac and Linux(CentOS/RHEL, Fedora, openSUSE, Ubuntu, Debian) and the source can be downloaded from owncloud.org/sync-clients.

Because there is not package provided for Slackware we can install the client from source. There are two packages required to build and install the client they are ocsync and mirall. If you are using Slackpkg+ (and you should be!!!) and have alienbobs repositories you can install through slackpkg using:
# slackpkg install ocsync

and
# slackpkg install mirall

These versions are out of date, ocsync-0.80 and mirall-1.3.0 whereas the latest versions are ocsync-0.90.4 and mirall-1.4.2, but these old version still work fine.

I tried to build the newest sources both changing and using the slackbuilds and using the build instructions but both times it failed with an error (missing a header file) and I haven't had time to investigate more.

Using the client.

The client is accessed by entering owncloud on the command line, this brings up dialogs that allows you to enter the login details for the server and the user credentials and to choose where you want the sync folder to be.

Disclaimer: Most of the information in this post is taken from the ownCloud website (owncloud.org) but is tweaked for use on Slackware since the ownCloud site generally only gives distro specific instructions for Debian, Fedora, CentOS, Ubuntu, openSUSE, ArchLinux, Gentoo and PCLinuxOS.

ownCloud is a Dropbox type application which is entirely under your control, it can be installed on any webserver providing it meets the requirements (ownCloud requirements)

I was talking with a friend who said he was having problems keeping all his devices (2 desktop computers, 2 laptop computers, tablet and 2 phones) in sync as the applications he used only allowed syncing to 2 or 3 devices without paying for extra licences, he uses computers a lot as tools for work but does not have the technical skills (or time) required to deal with any installation/configuration of anything not "click to install". This got me thinking and I remembered reading about ownCloud so I decided to look into this to see if it could help.

My home system is running Slackware 14.0 with Apache and PHP5.

There are two elements to the ownCloud system the server application and the optional ownCloud client installed on the users computer(s). The server application is a single zipped download from the ownCloud website and for a Slackware installation the client application consists of two packages ocsync and mirall (these are discussed and installed in Part 2 - the client)

The Server

The ownCloud server application can be downloaded from the ownCloud website and consists of the PHP files and associated content required to run the application. All that is required to install it is to extract the downloaded files and copy them to the webserver (probably need to do this as root).

$ tar -xjf owncloud-5.0.13.tar.bz2
Change to root and copy to webserver:
# cp -r owncloud/ /var/www/htdocs/

User files are stored under the data directory which does not exist at this point so it needs to be created. (The ownCloud instructions say that the data directory will be automatically created during the post install configuration but when I tried it complained that the data directory did not exist and should be created before continuing.)

# mkdir /var/www/htdocs/owncloud/data

Once this is done you need to change the ownership of the apps, config and data directories to the webserver user, in this case apache.

# chown -R apache:apache /var/www/htdocs/owncloud/apps
# chown -R apache:apache /var/www/htdocs/owncloud/config
# chown -R apache:apache /var/www/htdocs/owncloud/data

This should result in a simliar setup as below for the /var/www/htdocs/ownCloud directory.

directory listing of the owncloud webserver files

.htaccess and AllowOverride

ownCloud uses .htaccessfiles and the mod_rewrite module so these need to be configured since we are using the Apache server. This is done by editing the Apache configuration file /etc/httpd/httpd.conf . This is done by making sure that the mod_rewrite module line is uncommented and that the AllowOveride is set to All. Once these changes are done the server needs restarted to allow the changes to take effect

# apachectl restart

Provided there are no error messages you are now ready to do the first configuration through the web browser.

The install is finished by going through the installation setup through your web browser at your_server_IP/owncloud. If this on your local machine it usually is localhost/owncloud

Here you can enter the admin account details and set up the database in use by entering the database user details. Once this is done you can login to your new ownCloud installation and customise the setup and add users etc.

Once you have got this installed and setup using the web interface you can go ahead and install the client for any users. The instructions for this are in the second part here Setting up ownCloud on Slackware 14.0 (part 2 - the client)