odroid-xu4:software:omv_nas:eng:02_intermediate

Intermediate Level

Intermediate level. At this level, the knowledge about Linux and the work with SSH connection are required.

Plex Media Server is a media server program that supports transconding.
If the codec is not supported by the playback device, the Plex Media Server will streaming it with real time encoding so that it can be played.
Also, when streaming media from your home NAS to external using mobile internet like LTE or 4G, you can use transcoding to reduce image quality so that it makes data consumption lower.

The Plex Media Server can be installed using OMV's plugin as well. But you can't install it right away, you need to specify additional search locations to search when OMV searches for plugins.
Click OMV “Extras” menu. And click “Plexmediaserver” entry, click “Edit” button, then check “Enabled” option at the appears window and save.


Now go to OMV “Plugins” menu to install Plex Media Server by searching plex.

  • Since you work only through SSH connections, you should have a knowledge about Linux.
  • All of used bash commands must run in superuser permission.
    • If you login with root account, you can directly copy and paste the commands.
    • If you login with general user account, you have to getting superuser permission via sudo or login again with root account to proceed.
  • You can directly access to the Plex Media Server through the address bar of the web browser by enter ODROID IP address.

Once the plugin is installed, there will be a “Plex Media Server” menu on OMV.
In that menu, set the appropriate shared folder as “Database Volume”, check “Enable” and save.

Login SSH to create soft link for preventing from filling metadata on root file system.
The mounted directory path may differ from yours.

target
rmdir /var/lib/plexmediaserver
ln -s /srv/dev-disk-by-label-MyHDD/plexmediaserver /var/lib/plexmediaserver
chown -R plex:nogroup /var/lib/plexmediaserver

Once you're done, click “Plex Web Client” button above to connect to Plex.
Since you are using it for the first time, sign up and proceed.

Just follow the instructions on the screen.
In the “Add Library” - “Add Folder” section, the HDD installed in ODROID-HC1 appears as “/srv/dev-disk-by-…“ path. You can set that as the media file path.

Installation will be completed when you proceed.

Go to “Settings” - “Server” menu.
In the “Library” menu, check “Update my library automatically” and “Run a partial scan when changes are detected” of advanced settings, then click “SAVE CHANGES” button.

And in the “Transcoder” menu, set “Transcoder quality” to “Prefer higher speed encoding” and then click “SAVE CHANGES” button.

You can start streaming the added media files immediately on your various devices.
The streaming via PC can be done right at the web page.
And you can do the same thing on the Android and iOS devices by installing Plex application. Installing the app is free, but you will have to pay for it because it will stop the video every minute.

  • If you're in trouble with leaking memory when it runs on Kodi - Plex addon, please refer to this thread.
    on the online interface https://app.plex.tv/ -> Settings -> Network
    Secured Connections -> set it back to Disabled
    Check - Enable local network discovery (GDM)
    
    On the Plex addon Settings -> Advanced
    Allow Insecure Connections - On Same Network
    Check - Server Discovery (GDM)
  • Since you work only through SSH connections, you should have a knowledge about Linux.
  • All of used bash commands must run in superuser permission.
    • If you login with root account, you can directly copy and paste the commands.
    • If you login with general user account, you have to getting superuser permission via sudo or login again with root account to proceed.
  • You can use DLNA service if you installed the Plex Media Server. But it is recommended to install Serviio when you're watching the high quality videos or it has its subtitles.
  • This document referenced Serviio Wiki pages.

When you install the DLNA Service, you can start streaming your media via your smartphone, tablet or TV at home.

  • The version here might be different from real latest version so you would check the latest version by accessing the site.

Once you are connected to SSH, install the necessary packages for Serviio by entering the following commands.

  • The Java JDK installation will ask for license agreement. If you don't agree, it will not be installed.
target
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update && apt-get install -y ffmpeg dcraw oracle-java8-installer oracle-java8-set-default

Then proceed with the installation instruction as provided by Serviio.

target
useradd -r -s /bin/false serviio
mkdir -p /opt
cd /opt
wget http://download.serviio.org/releases/serviio-1.9.2-linux.tar.gz
tar zxvf serviio-1.9.2-linux.tar.gz
rm -f serviio-1.9.2-linux.tar.gz
ln -s serviio-1.9.2 serviio
chown -R root:root serviio-1.9.2
cd serviio-1.9.2
mkdir log
chown -R serviio:serviio library log

You should register Serviio as a service so that ODROID-HC1 will start automatically even if it is rebooted.
We will use vi as a CLI based text editor.

target
vi /etc/systemd/system/serviio.service

Copy and paste the following:

[Unit]
Description=Serviio Media Server
After=syslog.target local-fs.target network.target
 
[Service]
Type=simple
User=serviio
Group=serviio
ExecStart=/opt/serviio/bin/serviio.sh
ExecStop=/opt/serviio/bin/serviio.sh -stop
KillMode=none
Restart=on-abort
 
[Install]
WantedBy=multi-user.target

And register the new service to the system so that the newly created service works properly.

target
systemctl daemon-reload
systemctl enable serviio
service serviio start
  • If the console page is not immediately visible, try again in a few minutes.

You can setting up the Serviio through the websites.
Open a web browser and enter http://{ODROID IP}:23423/console into the address bar. You have to enter your ODROID NAS IP instead of {ODROID IP}.

Go to “Library” - “Shared folders” menu.
Click “Add” button to specify the path of media folder which willing to be shared.
As this time, the mounted HDD is named ”/srv/dev-disk-by-…“.

Select “Media type” and click “Browse” button to specify the path. If you're done, click “OK” - “Save” button to save.

You can start streaming media on your PC, as well as on a variety of devices including smartphones and smart TVs with DLNA support.

nPlayer (Android, iOS)

You can start streaming media using DLNA using the nPlayer app on the Android devices.

  • Since you work only through SSH connections, you should have a knowledge about Linux.
  • All of used bash commands must run in superuser permission.
    • If you login with root account, you can directly copy and paste the commands.
    • If you login with general user account, you have to getting superuser permission via sudo or login again with root account to proceed.
  • Preinstalled Web server and DBMS are required. You can see following document to install Nginx/MySQL on OMV.
  • If you upload your important files and medias such as photos, videos, please backup them to other places.
  • Files uploaded to Seafile are all stored on the server as be split. If you want to get the complete files, refer to the document below.
  • Enable email features so that getting various notification and share your files by sending a email.
  • Seafile supports file versioning simply. You can restore your previous file that covered by edited file. Refer to the following document to get more information.
  • This guide referenced the Seafile Manual pages.

You can share your data on PC, smartphone and tablet via Seafile, and can backup your photos and screenshots of the devices automatically.
Install it to your home NAS and use your own cloud storage service similar to Dropbox.

After connection with SSH, download Seafile by enter following commands.

target
wget https://github.com/haiwen/seafile-rpi/releases/download/v6.3.2/seafile-server_6.3.2_stable_pi.tar.gz

And since the web service of Seafile works with Nginx, we are going to install the Seafile in the ”/var/www” path. Create directory for Seafile, and configure the Seafile directories.

target
mkdir -p /var/www/seafile
mv seafile-server_* /var/www/seafile
cd /var/www/seafile
tar -xzf seafile-server_*
mkdir installed
mv seafile-server_* installed

Install necessary packages in advance before installing Seafile.

target
apt-get install python2.7 libpython2.7 python-setuptools python-dev python-pil python-ldap python-urllib3 ffmpeg python-pip python-mysqldb python-memcache python-requests libmemcached-dev zlib1g-dev
 
pip install --upgrade pip
pip install pillow moviepy

You have to know the absolute path where the Seafile data stored.
In ODROID-HC1, we can assume that the one HDD always appears to “/dev/sda”, and you can find where it is by enter following command.

target
df | grep /dev/sda1 | awk '{print$6}'
 
# results like
/sharedfolders/HDD1

Now enter following commands to install.

target
cd seafile-server-6.3.2
./setup-seafile-mysql.sh

Following text is the example of installation result. Follow the example below and answer the question as you please.
Questions that do not have an answer during the example are questions that use default values via the Enter key.

Checking python on this machine ...
  Checking python module: setuptools ... Done.
  Checking python module: python-imaging ... Done.
  Checking python module: python-mysqldb ... Done.

-----------------------------------------------------------------
This script will guide you to setup your seafile server using MySQL.
Make sure you have read seafile server manual at

        https://github.com/haiwen/seafile/wiki

Press ENTER to continue
-----------------------------------------------------------------


What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] CS2-Joshua

What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] 192.168.0.198

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/var/www/seafile/seafile-data" ] /sharedfolders/HDD1/seafile-data

Which port do you want to use for the seafile fileserver?
[ default "8082" ] 

-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------

[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

[ 1 or 2 ] 1

What is the host of mysql server?
[ default "localhost" ] 

What is the port of mysql server?
[ default "3306" ] 

What is the password of the mysql root user?
[ root password ] 

verifying password of user root ...  
verifying password of user root ...  done

Enter the name for mysql user of seafile. It would be created if not exists.
[ default "seafile" ] 

Enter the password for mysql user "seafile":
[ password for seafile ] 

verifying password of user seafile ...  done

Enter the database name for ccnet-server:
[ default "ccnet-db" ] 

Enter the database name for seafile-server:
[ default "seafile-db" ] 

Enter the database name for seahub:
[ default "seahub-db" ] 

---------------------------------
This is your configuration
---------------------------------

    server name:            CS2-Joshua
    server ip/domain:       192.168.0.198

    seafile data dir:       /sharedfolders/HDD1/seafile-data
    fileserver port:        8082

    database:               create new
    ccnet database:         ccnet-db
    seafile database:       seafile-db
    seahub database:        seahub-db
    database user:          seafile



---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------

Generating ccnet configuration ...

done
Successly create configuration dir /var/www/seafile/ccnet.
Generating seafile configuration ...

Done.
done
Generating seahub configuration ...

----------------------------------------
Now creating seahub database tables ...

----------------------------------------

creating seafile-server-latest symbolic link ...  done




-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------

run seafile server:     ./seafile.sh { start | stop | restart }
run seahub  server:     ./seahub.sh  { start <port> | stop | restart <port> }

-----------------------------------------------------------------
If you are behind a firewall, remember to allow input/output of these tcp ports:
-----------------------------------------------------------------

port of seafile fileserver:   8082
port of seahub:               8000

When problems occur, Refer to

        https://github.com/haiwen/seafile/wiki

for information.
  • We wrote a command line that makes the beginners to enter the settings into a file with only one command line.
  • When you need to create new settings file for several lines or edit the file that set before, you have to work with CLI based text editor.

1) Set timezone

If you use it by default, the timezone might be different from yours. You have to manually set the timezone so you can see exactly when you are creating, editing, and deleting.
Enter following commands to set the timezone.
This guide assumes that the Seafile is installed in “/var/www/seafile” path.
The “Asia/Seoul” part should be edit by yours.

target
echo "TIME_ZONE = 'Asia/Seoul'" >> /var/www/seafile/conf/seahub_settings.py && cat /var/www/seafile/conf/seahub_settings.py

2) Automatically start when boot

Let's setup Seafile to start automatically when your ODROID NAS is booted. Since Seafile is a standalone program(Not a web application), you have to setup this manually.
We are going to create/register the services, Seafile and Seahub. Assumes that Seafile is installed in “/var/www/seafile” path in the system.
Create the service for Seafile first.

target
vi /etc/systemd/system/seafile.service

Copy following text and paste it, then save.

[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
After=network.target mysql.service

[Service]
Type=forking
ExecStart=/var/www/seafile/seafile-server-latest/seafile.sh start
ExecStop=/var/www/seafile/seafile-server-latest/seafile.sh stop
User=root
Group=root

[Install]
WantedBy=multi-user.target

And create the service for Seahub.

target
vi /etc/systemd/system/seahub.service

Copy following text and paste it, then save.

[Unit]
Description=Seafile hub
After=network.target seafile.service

[Service]
Type=forking
# change start to start-fastcgi if you want to run fastcgi
ExecStart=/var/www/seafile/seafile-server-latest/seahub.sh start
ExecStop=/var/www/seafile/seafile-server-latest/seahub.sh stop
User=root
Group=root

[Install]
WantedBy=multi-user.target

Register the services you created to the system and enable them by enter following commands.

target
systemctl enable seafile.service && systemctl enable seahub.service

3) Performance optimization by applying Memcache

You can improve the response speed of Seafile by applying Memcache. Since it is supported by default, just enter the setup strings simply.
Install necessary packages via Python package manager.

target
pip install pylibmc
pip install django-pylibmc

And put following contents at the end of seahub_settings.py.

target
vi /var/www/seafile/conf/seahub_settings.py
CACHES = {
    'default': {
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
        'LOCATION': '127.0.0.1:11211',
    },
    'locmem': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    },
}
COMPRESS_CACHE_BACKEND = 'locmem'

Seafile runs as a shell script file. Seafile consists of Seafile, a back end part for managing data, and Seahub, a front end part for providing an interface to the user, such as Django, and CCnet for internal RPC that connects the two. So you need to run both Seafile and Seahub to use it.
Even if you register that as a service for automatic start up, Seahub will have to be executed for the first time. This is because you need to create an administrator account.
Execute Seafile and Seahub using following commands.

target
cd /var/www/seafile/seafile-server-latest
./seafile.sh start
./seahub.sh start

The appears message at first runs is:

LC_ALL is not set in ENV, set to en_US.UTF-8
Starting seahub at port 8000 ...

----------------------------------------
It's the first time you start the seafile server. Now let's create the admin account
----------------------------------------

What is the email for the admin account?
[ admin email ] admin@example.com

What is the password for the admin account?
[ admin password ] 

Enter the password again:
[ admin password again ] 



----------------------------------------
Successfully created seafile admin
----------------------------------------




Seahub is started

Done.

If Seafile and Seahub are running normally, you can access to Seahub by enter http://{ODROID IP}:8000 in the address bar of internet browser.


Seafile provides the clients for various platform. You can refer to following link for installation file and more information of each client.
https://www.seafile.com/en/download/

  • Since you work only through SSH connections, you should have a knowledge about Linux.
  • All of used bash commands must run in superuser permission.
    • If you login with root account, you can directly copy and paste the commands.
    • If you login with general user account, you have to getting superuser permission via sudo or login again with root account to proceed.
  • Preinstalled Web server and DBMS are required. You can see following document to install Nginx/MySQL on OMV.

Wordpress is a web based platform that makes build your personal blog and portfolio site more easier with modern looks.

Since Wordpress saves its data using the database, you have to create a database in your DBMS for Wordpress.
To access database administrator page, go to OMV MySQL menu and click the “Show” button.

And login as omvadmin.
Click the “Database” - “Create” menu to create a new database.

If you're done, click the “Tools” - “User Manager” menu.

Click the “Add User” button to add the user for Wordpress. Type “localhost” in host when you are adding.

And select the newly added user in “Select a User”, click the “Database Privileges” tab.

After granting full access to the Wordpress-only database, click the “Update User” button.

  • When you need to create new settings file for several lines or edit the file that set before, you have to work with CLI based text editor.

Download a Wordpress installation file after accessing using SSH.

target
wget https://wordpress.org/latest.zip

Unzip that file in the ”/var/www” path.

target
unzip -d /var/www/ latest.zip
rm latest.zip

And you have to edit the global settings file of Wordpress.

target
cd /var/www/wordpress
vi wp-config-sample.php

Find below contents and edit.

...
 
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'your-wp-db'); // The database name for Wordpress
 
/** MySQL database username */
define('DB_USER', 'your-wp-username'); // The database user name for Wordpress
 
/** MySQL database password */
define('DB_PASSWORD', 'your-wp-password'); // Password of the user
 
...
 
/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
/**
 * Delete all of the contents below and go to the link to replace the contents below.
 * https://api.wordpress.org/secret-key/1.1/salt/
 */
define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');
 
...

Rename the settings file.

target
cp wp-config-sample.php wp-config.php

Create a new shell script file to set the permissions.

target
cd ~
vi fix-wordpress-permission.sh

Copy contents below and paste it.

#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro 
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
WS_GROUP=www-data # <-- webserver group
 
# reset to safe defaults
find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \;
find ${WP_ROOT} -type d -exec chmod 755 {} \;
find ${WP_ROOT} -type f -exec chmod 644 {} \;
 
# allow wordpress to manage wp-config.php (but prevent world access)
chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php
chmod 660 ${WP_ROOT}/wp-config.php
 
# allow wordpress to manage wp-content
find ${WP_ROOT}/wp-content -exec chgrp ${WS_GROUP} {} \;
find ${WP_ROOT}/wp-content -type d -exec chmod 775 {} \;
find ${WP_ROOT}/wp-content -type f -exec chmod 664 {} \;

After save, and grant the permission to execute, then execute it.

target
chmod 755 fix-wordpress-permission.sh
./fix-wordpress-permission.sh /var/www/wordpress
  • Since not yet applying domain and SSL, we'll access with port number for now. Advanced level will deals with applying domain and SSL.

Wordpress which is composed with PHP is a web based platform that needs web server. So you have to set the Nginx configurations to access Wordpress.
Before you're doing it, you have to edit the global settings file of Nginx to increase the maximum capacity of each single file.

target
vi /etc/nginx/nginx.conf

Add contents below in http block.

client_max_body_size 100M;

Now you can upload the file that is sized up to maximum 100MB for each single file.
And go to the “Pools” tab in the OMV “Nginx” menu.
Click the “Add” button to add a new PHP pool. Refer to following screenshot.

After save, click the “Add” button in “Server” tab. Specify port number first, and to edit the others you can refer to contents below.
Remember your port number.


And copy following contents and paste it in “Extra options” at the bottom of the window.

root /var/www/wordpress/;
client_max_body_size 100M;
 
location = /favicon.ico {
    log_not_found off;
    access_log off;
}
 
location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}
 
location / {
    # This is cool because no php is touched for static content.
    # include the "?$args" part so non-default permalinks doesn't break when using query string
    try_files $uri $uri/ /index.php?$args;
}
 
 location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
     expires max;
     log_not_found off;
}

And go back to SSH, then enter the following commands.

target
WP_PORT='{Your Wordpress port number}' # example) WP_PORT='8001'
WP_URL='http://{Your ODROID IP}:'$WP_PORT # example) WP_URL='http://192.168.0.2:'$WP_PORT
echo -e "\ndefine('WP_HOME', '"$WP_URL"');\ndefine('WP_SITEURL', '"$WP_URL"');" >> /var/www/wordpress/wp-config.php

Access to port number set at Nginx configuration.
http://{ODROID IP}:{PORT}

Select your language first.
And enter site name, user name, password, email address, etc.

The email address seems like actually registered in the Wordpress official site. To get the notifications you should enter your real email address.
Click the “Install WordPress button to finish the installation.


  • You should have a knowledge about Linux and Port-forward.
  • All of used bash commands must run in superuser permission.
    • If you login with root account, you can directly copy and paste the commands.
    • If you login with general user account, you have to getting superuser permission via sudo or login again with root account to proceed.
  • As we guided, we'll deals with only FTP, WebDAV, Transmission, Plex Media Server, Seafile, Wordpress.
    • In Samba and Servvio, you can't apply port-forwarding since it is only for local network.
  • We use the router called EFM ipTIME. It is not much different of the method for applying port-forward even if you are using a router from another manufacturer.

Because the port forwarding rule setting is done by the router, access the router setting page.

Login with your administrator account and go to the Port-forward settings page.
In the router EFM ipTIME, the default administrator account information is admin / admin. Refer to the page above to know the default administrator account information each of you.

It should look similar with above screenshot. See the table below to add the port-forward rules one by one.

  • The SSH entry is for access ODROID NAS.
  • Enter appropriate port number in {Yours} part of SSH port. You should choose random number for protect from attack by hackers since the port number of SSH is specified by international rules.
  • You don't need to use the SSL port at this time, but you can register in advance to use it when applying domain and SSL.
  • To apply port-forward to the client applications, you need to specify the public IP address to the IP the client applications access in settings.
  • You can edit the FTP Passive mode port on OMV FTP setup page. Make the same settings for OMV FTP's passive mode port and port-forward rule.
Service Out → in Router → NAS
FTP (Command) 21 21
FTP (Passive, Data) 49152 ~ 65534 49152 ~ 65534
Web (OMV, WebDAV) 80 80
Web (Wordpress) 8001 8001
Transmission 9091 9091
Plex Media Server 32400 32400
Seafile 8000 8000
Seafile (File server) 8082 8082
SSH {Yours} (> 1024) 22
Web (SSL) 443 443
  • You need a knowledge about Linux.
  • There are no special settings to be set on the server other than Wordpress, Seafile among the services that we've guided.
  • Assume the public IP is 100.100.100.100.

Proceed after SSH connection.

Wordpress

Wordpress must know its external access address in order to provide its links and so on.
Write external access address directly to the settings file using the following commands.

target
PRIV_IP='{Your ODROID IP}' # example) PRIV_IP='192.168.0.2'
PUB_IP='{Your public IP}' # example) PUB_IP='100.100.100.100'
sed --in-place=.bak 's, '"$PRIV_IP"','"$PUB_IP"',g' /var/www/wordpress/wp-config.php

Seafile

Seafile must know its external access address in order to provide its links and so on.
Write external access address directly to the settings file using the following commands.

target
PRIV_IP='{Your ODROID IP}' # example) PRIV_IP='192.168.0.2'
PUB_IP='{Your public IP}' # example) PUB_IP='100.100.100.100'
sed --in-place=.bak 's, '"$PRIV_IP"','"$PUB_IP"',g' /var/www/seafile/conf/ccnet.conf
echo "FILE_SERVER_ROOT = 'http://'"$PUB_IP"':8082'" >> /var/www/seafile/conf/seahub_settings.py
echo "SERVE_STATIC = False" >> /var/www/seafile/conf/seahub_settings.py
  • odroid-xu4/software/omv_nas/eng/02_intermediate.txt
  • Last modified: 2018/09/28 15:29
  • by joshua