Part 4 - Setting up Rclone

The original source for the following tutorial on how to setup a Plex Media Server with GSuite has gone offline, so I thought i would re-post it so it's not lost.

Everything below is simply lifted from their website (with minor tweaks) (Tech Perplexed / techperplexed.ga)

Now that you finished Part 3 - Install and configure Plex, we're halfway there... keep with it! This part will discuss Rclone.

Installing Rclone

Installing Rclone itself is the easiest part. You don't even need to understand what is happening. After you have followed these steps to the letter, Rclone will be installed.

I suggest you start a new session in PuTTY (select your saved session and click "Open", then log in with plexuser (or the name you picked for yourself) so that we are no longer in local mode.

Copy and paste the following line:

curl https://rclone.org/install.sh | sudo bash 

That's all, Rclone is installed and ready to run!

Configuring Rclone with Google

You didn't think everything would be this easy, right? No, the hard part is still to come. Now we need to configure Rclone, which is a bit of a task because on our PuTTY terminal, we have no browser available. Not to worry, with a bit of work, your own local computer will come to the rescue.

In the PuTTY terminal, type

sudo rclone config

You will be presented with a choice, type the letter n for "New remote" and hit the Enter key.

This tutorial will cover Google Drive, which is by far the most popular service. If you have signed up for another cloud service, check the Rclone website how to set that up.

You are asked to give a name. For this tutorial to work properly, please make sure you type:

Gdrive

Notice the capital G in Gdrive - Linux is picky about these things. Again, to avoid problems, you should not deviate from this (unless you exactly know what you're doing, but then you probably wouldn't be following this guide).

Check which option mentions Google Drive "drive" in the list (in the latest version this is #11), so type 11 and Enter.

Leave client_id> blank, just Enter.
Leave client_secret> blank as well, just Enter.

Scope that Rclone should use> 1 (full access)

ID of root folder> blank, just Enter
Service account files> again leave blank, just Enter.

Type the letter n for No, you don't want to use auto config and Enter.

You'll get a message that if your browser doesn't open, you will need to copy and paste the following link. You will need to place the entire link in a block by dragging your mouse (see screenshot below). Do not hit Ctrl-C - remember, this is PuTTY - dragging the mouse and placing the link in a block means it's copied.

Go to your local browser and paste the link. You will be asked to log into Google and accept authorization. You will then be given a code to paste in PuTTY.

Paste the code (right click), hit Enter.

Next you will be asked if you want to configure it as a team drive. Unless you know exactly what this means, type n - you don't want it.

Finally type y that Yes, all is okay and then q to Quit config.

You should see both drives in your list of current remotes:

Head over to Part 5 - Mounting the drive(s).

Part 3 - Install and configure Plex

The original source for the following tutorial on how to setup a Plex Media Server with GSuite has gone offline, so I thought i would re-post it so it's not lost.

Everything below is simply lifted from their website (with minor tweaks) (Tech Perplexed / techperplexed.ga)

Finished Part 2 - Configuring Ubuntu? Then you can proceed with the installation of Plex itself. Thanks to an awesome script that is available for free, this is going to be a breeze. We now need to restart PuTTY in localhost mode to set up the Plex server using our local browser.

Open a new terminal window, select your saved Plex session and click "Load".

Don't click "Open" yet, first, look for Connection in the menu on the left hand side, open up SSH and click "Tunnels".

In the field behind Source port type: 32400
In the field behind Destination type: localhost:32400
Click "Add".

Now click "Open".

You can now login as your newly created plexuser.

Installing Plex

To install Plex, type (copy/paste):

bash -c "$(wget -qO - https://raw.githubusercontent.com/mrworf/plexupdate/master/extras/installer.sh)"

All in one line (you may need to scroll horizontally). If you are asked to enter your password, then this is not your Plex password, but the password you chose for plexuser in Linux.

Type the letter y to proceed with the installation, then hit Enter to agree to the default location "/opt/plexupdate".

You will be asked if you want to install the latest PlexPass releases. Important: answer y ONLY if you own a PlexPass, otherwise type n. I have a PlexPass, so I entered y.

If you choose y you will need to provide your Plex credentials. Enter your Plex e-mail address and Plex password.

Follow the rest of the prompts. I chose y when asked if I want to install the latest updates whenever they are released and y to check if the server is in use before upgrading,

Hit the Enter key twice when presented with the DNS/IP name and server port, 127.0.0.1 and 32400 are both correct.

I chose y to set up automatic daily updates for Plex.

Choose y that you wish to continue.

I chose n that I do not wish to run syslog, and n that I don't want to receive an email if an update is available.

Lastly, make sure you choose y that you want to run the Plex update right now.

Congratulations, Plex is installed!

If you ever need to make chances to this configuration, type

/opt/plexupdate/extras/installer.sh

This will run all options again and update the configuration with your new choices. Don't click away PuTTY, we're not done yet.

Getting Plex to run

Leave the terminal open on your desktop and open your local computer browser.

Visit this link:

http://127.0.0.1:32400/web

If all goes well, you will be presented with a Plex login screen. You're doing fantastic!

Sign in with your Plex credentials, or create a new account if you are new to Plex. Continue clicking "Next" until you get the Plex main page.

Later we'll finish setting up the server, but before we proceed there is one more thing to do. Make sure your Plex server is available at https://app.plex.tv. If it is, click the Settings button (top right), click "Server", then "Remote Access".

Make sure you see "Fully accessible outside your network" in green.

Perfect, Plex is installed properly and we're ready for Part 4 - Setting up Rclone and/or Plexdrive.

Part 2 - Configuring Ubuntu

The original source for the following tutorial on how to setup a Plex Media Server with GSuite has gone offline, so I thought i would re-post it so it's not lost.

Everything below is simply lifted from their website (with minor tweaks) (Tech Perplexed / techperplexed.ga)

You have completed all the steps in Part 1 - Creating an infinite Plex server using a VPS and a cloud service. We're now ready to configure Ubuntu so that it will work with Plex and your mounted Google drive.

Change root password

The root password you were provided with is probably not all that strong, and for an added layer of security you should change it. I suggest you use a password generator to create a really long 20 character super difficult password. Make sure it's stored somewhere safe. You will not need during the installation of Plex, but you may need it again in the future.

Here's mine: 5ehMN&7cQY*#yJZnAaNp. Notice it is 20 characters long, completely random, contains capital letters, small letters, numbers and symbols. Now that is a strong password!

You are still logged in as root on PuTTY. In the terminal, type:

passwd

Then paste (right click) your generated password, hit Enter, and paste it a second time.

f all goes well, it will tell you that your password was updated successfully.

Again, make sure your new password is stored in a safe place!

Installing updates and some vital packages

Next, we'll perform a few necessary updates and installations. You can type these commands manually, or if you're lazy like me, just copy and paste them from the browser here (Ctrl-C) into the PuTTY terminal (right click).

First, let's update Ubuntu with all the latest patches and updates. Type (or copy/paste):

sudo apt-get update && sudo apt-get upgrade

Sit back and relax while Linux flashes by lots of yakkety yak until it pauses and asks if you accept the additional disk space used. Type y and Enter.

After much more gobbledygook it'll probably pause on a blue screen. Ignore the warning by hitting Enter.

This time it'll probably finish and you'll see the green prompt again. If at some point in the future you get the message that there are packages that can be updated, run

sudo apt full-upgrade

We shall now install Fail2ban to prevent hackers from trying to get into your system. Enter

sudo apt-get install fail2ban

Agree to the installation (y, Enter). If the above command isn't displayed in one single line (depending on your browser settings), make sure you copy everything. Each time you see a text box containing a > this will mean you'll need to enter the entire code in PuTTY.

Go have a cup of coffee, talk a bit to a friend and come back after one hour. Then type

sudo cat /var/log/fail2ban.log

This will tell you the amount of hackers that tried to get into your system... yes... I was shocked too. At least we're protected now against brute force attacks.

Now we're going to install some packages that you need later. First we need the "GNU nano" text editor:

sudo apt-get install nano

Some newer versions of Linux don't include unzip or curl out of the box, let's install those just in case:

sudo apt-get install unzip 

Follow the prompts, depending on whether it was installed already or not. Curl is needed for some scripts:

sudo apt install curl

We also need to install FUSE, the package you asked your provider to enable.

sudo apt-get install fuse

Type y to continue. If at this point you get an error, you may need to contact your provider to enable FUSE, and wait for them to get back to you that it's done. You can't complete your installation until they have enabled it.

Depending on where your VPS server is, the time might be different from your local timezone. This would throw off your planned server maintenance / Plex downtime and other cron jobs. There is an easy fix for that:

sudo dpkg-reconfigure tzdata

Then select the area and time zone where you live.

Getting the firewall ready for Plex

We want Plex to be able to talk to the world, and you to be able to talk to your VPS. All other communications (hacker attempts!) are unwelcome. For added security, we will enable the firewall and create an exception for Plex. Type (or copy/paste) the following lines:

sudo apt-get install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 32400

Your firewall is now ready for Plex.

You can add other exceptions as needed. For example, if you plan to install trakt.tv later, you will need to add this line:

sudo ufw allow 33400

It's always best practise to only open the ports you will actually need. Then enable the firewall:

sudo ufw enable

Then type y to confirm the command.

Create another Linux user

Linux is very security minded, and you should perform most tasks under a separate user, not root. It is an added layer of security and also makes things easier in the long run when you need to perform maintenance. Think of a username you want to use - your own name would be great. Do not choose "plex", that name is reserved to be used by Plex itself. Other than that, you can use your imagination.

Type

adduser plexuser

Note: make sure you substitute plexuser to your own username wherever it occurs in the tutorial... I might not remember to remind you :)

Use a strong password that you'll remember easily (this is the password you'll be needing each time you log in or make changes), but hard to crack. I chose 123456 - just kidding!

You can enter through all the fields leaving them empty if you like, and finish by typing y and Enter.

Give your new user the right permissions to install and maintain Plex:

usermod -aG sudo plexuser

In order to prepare your server for Plex, you will need to give that name some permissions for later installations. Go ahead and enter

sudo visudo

A text file will open. Use the arrow keys on your keyboard to scroll to the bottom and add on a new line:

plexuser ALL=(ALL) NOPASSWD:ALL

It will look like this:

Save this file by hitting Ctrl-O, then Enter. Exit the editor by hitting Ctrl-X.

Exit the terminal now (just close the PuTTY window) and log back in with your brand new username and password. Make sure you see your newly created user before the green prompt, instead of "root".

We're ready for Part 3 - install and configure Plex!

Part 1 - Creating an infinite Plex server using a VPS and Cloud service

The original source for the following tutorial on how to setup a Plex Media Server with GSuite has gone offline, so I thought i would re-post it so it's not lost.

Everything below is simply lifted from their website (with minor tweaks) (Tech Perplexed / techperplexed.ga)

So you're thinking of starting a media server on a VPS with infinite storage on a cloud service, but you have no idea where to start. This sounds like me, a few weeks ago - I found the installation absolutely daunting!

Fortunately for you I have done all the homework, and now sharing with you what I learned to get the system up and running.

If you follow these steps to the letter, you'll end up with

  • A Plex or Emby server on a VPS of your choice,
  • Unlimited storage on a cloud provider (this tutorial uses Google),
  • A really good feeling of having accomplished something worthwhile!

What I will not be responsible for

  • Your services. You will need to provide the domain, VPS and cloud services yourself,
  • Your content. You will need to supply ​your own content and are solely responsible for what you upload to the cloud,
  • Any loss of data, money, time or hair.

What you will need:

  • A local computer to get set up. My tutorial is based on Windows 10 but if you're using a Mac or other system, that would work too,
  • A little computer knowledge - you know how to use a mouse and keyboard and can find your way around on your local computer,
  • Time, patience and a bit of perseverance. And you need a domain.

I mostly gathered the information from various Internet sources and the Plex forums, but I have also had some private help from friends (you know who you are). I can't thank you guys enough for your help and hope this tutorial will help some others to be up and running in no time.

VPS

A VPS is basically a computer away from home that offers various preselected (usually) Linux distros out of the box. You can then set it up with any service you like - in our case, Plex with an infinite cloud based storage system.

Choose a VPS service that is semi close to you - in other words, select a provider with data centers in Europe, North America, Asia or wherever you happen to live.  If you are given a choice, pick KVM (instead of OpenVZ)... it might be slightly pricier, but will also be more stable and faster.

These are the minimum specs you will need in order to stream HD content comfortably:

  • 2 CPU cores
  • 8GB of Ram
  • 40GB disk space
  • 4TB transfer

The above are the absolute minimum requirements for a single user/stream. If you have multiple users on Plex, or more concurrent transcoding streams, go for a service that offers at least 4 CPU cores and 16GB of RAM.

If you own a gigantic media library (thousands of movies, hundreds of TV shows, etc) or if you are going to use your VPS for downloading content, you might need more than 40GB storage because each media item will take some space to store its metadata and cache.

If you want to use your VPS to copy or sync files between cloud services, you'd want to look for one that unlimited bandwidth and generous rules on network usage.

Check Kimsufi or lowendbox.com/ or Hetzner or lowendtalk.com for offers in your surroundings - I signed up for a dedicated server at OneProvider when it was on sale.

Cloud

Next, sign up with the cloud service(s) of your preference. I picked Google Gsuite Business as my main service. The reason is that at the time of this writing, they are the most cost effective at $12/month + the cost of a domain. This tutorial will teach you how to set up Google with Plex and/or Emby to basically create an infinite media drive.

Upload your content

While you are are getting ready to setup your VPS, you might as well upload a few movies/TV shows to your cloud service. There are various tutorials on the Plex website on how to set up your media for usage with Plex. I also assume you know how to upload files to your cloud service, so I won't be covering those subjects in this tutorial.

Lastly, this tutorial does not cover data encryption. If this is a concern, you will be able to find numerous sources on the web that will explain the ins and outs of encryption.

PuTTY

You are almost ready to begin your Linux adventures. You will need PuTTY in order to connect to your VPS. You can download it here: http://www.putty.org/
You will need to install it on your local computer so pick the package files suitable for your system.

You'll be using PuTTY every time you have to access your VPS, so you might as well place that icon on your desktop.

We'll learn how to use the terminal throughout this tutorial.

Linux

This tutorial is based on Ubuntu 18.04 the 64bit version, which currently is the latest version of what most VPS providers offer.  Also, Ubuntu is one of the most popular Linux distros. If in your enthusiasm you already picked a distro when you signed up for a VPS, fret not... most providers allow you to easily rebuild your server.

FUSE

Last but not least, for our setup we need FUSE enabled. Many budget VPS services do not enable this by default, but will do so on request. You will need to open a ticket and submit a request so that your new provider enables FUSE for you.

Connecting to your VPS

Start PuTTY, you'll see a configuration screen.

Enter the IP address your VPS provider supplied you with, enter a descriptive name in "Saved Sessions" and hit "Save". Leave Port 22 as it is.

PuTTY will now remember your credentials for next time, always handy!

Next, click "Open". You'll probably get a very scary warning about a potential security breach. Don't panic, it is okay, that always happens the first time you access your VPS from a new location. You can safely click "Yes".

The first time you login, you need to use the password your VPS provider gave you.

Now, if you wish you can copy (Ctrl-C) that password so you won't have to type it out when you need to enter it.

Then go your black PuTTY terminal. Behind "login as" you need to type:

root

Hit the Enter key. It will ask you for your password. Do not enter Ctrl-V! Resist that temptation - it won't work. Don't say you weren't warned... just... you know... don't.

Instead, right click with your mouse button inside the terminal. But... nothing happened? Yes, your password that you copied before was pasted invisibly. Hit the Enter key and if all goes well, you'll be presented with this screen:

Admire that splash of green in an otherwise black and white world... that is your cursor.

Continue with Part 2 - Configuring Ubuntu

 

How to upload a file to umbraco 8

Uploading a file into Umbraco 8 has changed slightly, using the code below as found on the Umbraco Help Forums, worked for me:

Now you need the IContentTypeBaseServiceProvider and a Stream.


// Umbraco 8
using Umbraco.Core; <- Important..

// Needed Interfaces
IMediaService _mediaService; 
IContentTypeBaseServiceProvider _contentTypeBaseServiceProvider;

// The new way to do it.
IMedia media = _mediaService.CreateMediaWithIdentity("Filename", 1234, "File");
media.SetValue(_contentTypeBaseServiceProvider, "umbracoFile", "FilenameWithExtension", Stream);
_mediaService.Save(media);

Byte[]


byte[] byteArray;

using (Stream stream = new MemoryStream(byteArray))
{
    media.SetValue(_contentTypeBaseServiceProvider, "umbracoFile", "FilenameWithExtension", stream);
}

HttpPostedFileBase


HttpPostedFileBase httpPostedFileBase;

media.SetValue(_contentTypeBaseServiceProvider, "umbracoFile", httpPostedFileBase.FileName, httpPostedFileBase.InputStream);

Thanks to Bo Jacobsen for sharing the solution!