This tutorial describes the steps needed to create a remote (or local) Plex media server, along with unlimited Amazon cloud storage while encrypting file integrity.
Page Contents
Prerequisites
-
Have the administrative rights .
-
Have an Internet connection configured and activated.
-
A server / vps with FUSE (I use hetnzer online and ovh kimsufi), note to OpenVZ VPS, checked the availability of fuse.
-
SSH access
-
an account with amazon cloud storage
The preparation
First, you need to install Plex, please visit the download page , copy the link to Ubuntu and wget in your terminal. In my example, it’s version 1.3.3 of plex.
Plex
Cd ~ . Sudo dpkg -i plexmediaserver_1. *
For simplicity, it is the user plex that will be used, it simplifies the management of rights.
Sudo su Passwd plex Adduser plex sudo
Additionally, you can disable Plex SSH access.
Nano / etc / ssh / sshd_config
And adding at the end:
DenyUsers plex
And restart ssh:
Service ssh restart
The files
Once reconnected with the plex (su plex), we will create the necessary files, a detailed documentation is available here .
Su plex Sudo mkdir / home / plex / Sudo chown plex / home / plex / Mkdir /home/plex/.local-sorted/ Mkdir / home / plex / local-sorted / Mkdir /home/plex/.acd-sorted/ Mkdir / home / plex / acd-sorted / Mkdir / home / plex / sorted / Mkdir / home / plex / logs /
The packets
Then we install the set of necessary packages:
Sudo apt-get install python-fuse python-fuse python3-setuptools python3-appdirs python3-dateutil python3-requests python3-sqlalchemy git Sudo easy_install3 -U pip
Acd_cli
Once this is completed, we realize the installation of ACD_CLI which is a command-line interface that mounts cloud drives as local folders.
Sudo pip3 install git + https: //github.com/yadayada/acd_cli.git
We then check that everything works:
Acd_cli sync
This step will ask you to have a file oauth_data which allows a acd_cli to identify with amazon.
The first step is stopped when it must connect on https://tensile-runway-92512.appspot.com/ , made on your local browser, download the oauth_data, open it with a local drive. Copy the data and connect to a second ssh terminal and created with nano:
Nano /var/lib/plexmediaserver/.cache/acd_cli/oauth_data
Paste the data from the previously downloaded file, save it and return it to your previous ssh. Continue to follow acd_cli instructions.
Once completed, we can tackle the main key pont: folder mounting, encryption and synchronization.
Create a Plex Media Server with Amazon Unlimited Storage
The Key Point
The principle is simple:
-
/ local-sorted , which is not encrypted local file or you file your media.
-
its encrypted version encfs /.local-sorted which is the folder that will upload on amazon
-
/.acd-sorted which is the mount point cloud file, which is mounted encrypted.
-
/ acd-sorted is the decrypted remote folder.
-
/ sorted , the folder via unionfs, can “merge” local-acd-sorted and sorted, this will be the folder used by Plex.
We now generate the encryption key with encfs, it is imperative * * once these steps are completed, you should keep a backup of the encryption key.
To mount encfs, simply launch
Encfs /home/plex/.local-sorted / home / plex / local-sorted
Encfs will prompt you for the encryption settings, the default settings are correct, and a password, which you will also need to retain.
Once completed, any files placed in * / local-sorted * will appear encrypted in * /. Local-sorted *.
We will then move the encryption key:
Fusermount -u / home / plex / local-sorted Mv /home/plex/.local-sorted/.encfs6.xml /home/plex/encfs.xml
From now on, to mount an encfs file system, it will be necessary to stipulate the presence of a configuration file.
ENCFS6_CONFIG = '/ home / plex / encfs.xml' encfs /home/plex/.local-sorted / home / plex / local-sorted
Let’s test if it works:
Ls /home/plex/.local-sorted/ # Normally empty Touch / home / plex / local-sorted / test Ls /home/plex/.local-sorted/ A file with a name with no meaning should appear.
Editing Amazon Cloud Drive
Acd_cli mount /home/plex/.acd-sorted/
/home/plex/.acd-sorted/ now displays the files from / to cloud drive amazon encrypted manner.
We now mount with EncFS:
ENCFS6_CONFIG = '/ home / plex / encfs.xml' encfs /home/plex/.acd-sorted / home / plex / acd-sorted
The files appear on amazon cloud storage so decrypted in the folder / acd-sorted
Upload
For Upload, there are two ways, the simplest way is to use acd_cli upload followed by an acd_cli sync or rclone and a python crypt to automatically mount the mount point.
Acd_cli upload
Acd_cli upload /home/plex/.local-sorted/* / Acd_cli sync
This works but for now I find acd_cli upload inconsistent (with a lot of errors) and acd_cli unstable (frequent mount point crash)
Rclone
That’s the solution I’m using. The principle is as follows:
a bash script that I execute a screen with the following command:
Rclone move -v /home/plex/.local-sorted acd: /
the script :
Nano /home/plex/.loopreclone.sh
The following code is pasted:
#! / Bin / bash For i in {1..10} do Rclone move -v /home/plex/.local-sorted acd: / Mail -s "Upload $ i $ (date)" // your email // <<< 'Update!' Done
Then we render the script executable:
Chdmod + x /home/plex/.looprclone.sh
It is then executed in a screen, the upload will do this 10 times by sending an email at each end of the loop (to get an idea of the progress), it is very handy for a very large upload in a folder that It renews regularly when we download its personal media.
To refresh the list of files, execute:
Acd_cli sync
But this tends to crash the mount point, a more stable and automatic solution is available in the last part of the tutorial.
UnionFS-FUSE
We simply execute:
/ Home / plex / acd-sorted = RO / home / plex / sorted /
This merges the two unencrypted files into one single file / sorted . That will be used for plex. This has the advantage of allowing a plex to add a file quickly when added to the server in local-sorted / and when if is upload on amazon, decrypted and reassembled locally * / acd-sorted, not see difference as it will be identically mounted in / sorted .
Conclusion
Here you have the essential to realize your own infinite Plex Media Server. This is obviously to use with media of which you have legally acquired the property or your personal movies.
I invite you to finish the tutorial by reading the known problems, there are some, especially the one caused by acd_cli sync, which has planted the mount point and which becomes inaccessible.
Known Issues and Solutions
Crash of the assembly after a sync
The main fault is as explained above, acd_cli sync, which has a tendency to plan the mount point, which prevents to simply place an acd_cli in a crontab.
So we’re going to use two scripts. The first one, very simple, will execute an acd_cli sync immediately followed by a python script that will verify if the assembly has planted and reassembled if necessary.
Nano /home/plex/sync.sh
We stick to it:
#! / Bin / bash / Usr / local / bin / acd_cli -d sync Python3 /home/plex/.automount.py
and makes it executable by chmod + x .
then creates the .automount.py with the code I modified the script but the source is here :
Import os Import subprocess Import logging Logging.basicConfig (filename = 'acdmount.log', level = logging.INFO, format = '% (asctime) s% (levelname) s% Logging.info ('ACD mount checker started') DEVNULL = open (os.devnull, 'wb') #pb = Pushbullet ('pushbullet-api-key-here') # Logging.info ("running ACD sync") # Subprocess.call (["/ usr / local / bin / acd_cli", "sync"], stdin = None, stdout = DEVNULL) Exists = os.path.exists ("/ home / plex / .acd-sorted /") If exists is not True: Logging.warning ("ACD mount is down") # Push = pb.push_note ("ACD mount down", "attempting restart") # Logging.info ("attempting umount") # Subprocess.call (["/ usr / local / bin / acd_cli", "umount"], stdin = None, stdout = DEVNULL) Logging.info ("attempting umount fuser") Subprocess.call (["/ bin / fusermount", "-uz", "/home/plex/.acd-sorted"], stdin = None, stdout = DEVNULL) # Logging.info ("running ACD sync") # Subprocess.call (["acd_cli", "sync"], stdin = None, stdout = DEVNULL) Logging.info ("attempting ACD mount") Subprocess.call (["/ usr / local / bin / acd_cli", "mount", "/home/plex/.acd-sorted/"], stdin = None, stdout = DEVNUL $ # Print ("ACDmount done") # If os.path.exists ("/ home / plex / .acd-sorted /"): # Push = pb.push_note ("ACD mount back up", "restart successful") # Logging.info ("ACD mount restart succeeded") #else: # Print 'all good'
We will then run this script every 6 minutes via cron , a time between each sync is at least 5 minutes.
Reassembly after reboot
We will create a script that allows to trace all this via cron after a reboot. We first create a .encfspass file that will contain only the encfs password. <Code> nano /home/plex/.encfspass </ code> Then a ** mount.sh ** script containing the following code to be executed via ** chmod + x **
! / Bin / sh
/ Bin / fusermount -uz / home / plex / acd-sorted
/ Bin / fusermount -uz /home/plex/.acd-sorted
/ Bin / fusermount -uz / home / plex / local-sorted
/ Bin / fusermount -uz /home/plex/.local-sorted
/ Bin / fusermount -uz / home / plex / sorted
Acd_cli sync
Acd_cli mount -ro /home/plex/.acd-sorted
ENCFS6_CONFIG = '/ home / plex / encfs.xml' encfs --extpass = "cat /home/plex/.encfspass" /home/plex/.acd-sorted / home / plex / acd-sorted
ENCFS6_CONFIG = '/ home / plex / encfs.xml' encfs --extpass = "cat /home/plex/.encfspass" /home/plex/.local-sorted / home / plex / local-sorted
/ Home / plex / acd-sorted = RO / home / plex / sorted /
Exit
And adding a cron:
@reboot /home/plex/.mount.sh> /home/plex/logs/mount.log 2> & 1
Now you have successfully created a Plex Media Server using Amazon unlimited cloud storage. If you any challenges, you can drop your comment below.