Tag Archives: sysadmin

How To Stream Music & Video With Plex on FreeBSD

Introduction

Plex is a great piece of software, if you’ve never heard it before think of it as an easy to use service that runs on a computer that streams just about any format of audio/video to a Smart TV, Apple TV, Roku, or modern console. You can even easily configure it so that your iOS device can stream content from your media server across the Internet. Perfect!

If you are running a small blog on a VPS instance, chances are you have way more bandwidth, disk space, RAM, and CPU than you need for the blog. I’ve put together this short tutorial on how to install & configure Plex on your VPS to stream your music/video collection from that instead of your home computer (for example, if you want to stream your music library without hitting your residential data cap at home!).

Prerequisites

Before you begin this guide you’ll need the following:

Freebsd 10.x Droplet

A non-root user with sudo privileges (https://www.digitalocean.com/community/tutorial_series/getting-started-with-freebsd) explains how to set this up.)

Up To Date Ports Tree

Step 1 — Updating Ports Tree

The Ports Tree is updated constantly, you should update your system’s local copy on a regular basis. To do this manually, execute the following command:

sudo portsnap fetch update

Step 2 – Install Plex

Plex doesn’t have a lot of prerequisites, the easiest way to install is to run:

sudo pkg install plexmediaserver

After the package has been installed, the installation process tells you how to set the plexmediaserver service to start automatically at boot as well as how to manually start it. We’ll perform both commands now:

sudo sysrc plexmediaserver_enable=YES

and

sudo service plexmediaserver start

Step 3 – Configure Plex

root@freebsd:~ # pkg install plexmediaserver
Updating FreeBSD repository catalogue…
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 2 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
plexmediaserver: 1.0.0.2261
compat9x-amd64: 9.3.903000.20160608

Number of packages to be installed: 2

The process will require 170 MiB more space.
65 MiB to be downloaded.

Proceed with this action? [y/N]: y

After downloading and installing, it will prompt you with the following information:

Message from plexmediaserver-1.0.0.2261:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

multimedia/plexmediaserver includes an RC script:
/usr/local/etc/rc.d/plexmediaserver

TO START PLEXMEDIASERVER ON BOOT:
sysrc plexmediaserver_enable=YES

START MANUALLY:
service plexmediaserver start

Once started, visit the following to configure:
http://localhost:32400/web

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

NOTES: If there is an issue getting to the initial setup screen of the server after adding your IP to the allowed network setting, try a different browser or close all tabs and windows and empty cookies.

If there is a problem “Claiming” the new server, log out of plex and back in again.

If there is a problem with the new server showing up on iOS, sign out of your account in the plex app and force kill it. Re-launch and log back in.

Desktop Central Forwarding Agent

Desktop Central has the ability to manage smartphones via the standard MDM APIs. It can do much of the same things any MDM solution can offer, and if you already have it in place for employee computers you might be interested in using it for your MDM solution as well.

One of the optional components is simply called the Desktop Central Forwarding Server. You install this on a server in your DMZ, open a few ports between it and the internal Desktop Central server, a few ports between it and the Internet, and your mobile devices can be managed when not on the internal network. All without exposing your Desktop Central server to the Internet. However, there is one key step that isn’t clearly explained in the documentation.

There is a step when you install the Fowarding Server that you need to to copy over a couple encrpytion keys from Desktop Central for the installer to import. You also need to generate Apple MDM certificates from apple.com and import those into Desktop Central. The first step is so the traffic between the Forwarding Server and Desktop Central is encrypted and you don’t run into any issues with the Forwarding Server complaining about not trusting the Self Signed Certs on Desktop Central. The certs from Apple that get imported into Desktop Central are to allow Desktop Central to be able to manage iOS devices (send push notifications, remotely lock and wipe the device, etc). However, if you import the files from Desktop Central to the Forwarding Server and then import the Apple certs you will break the connection between Desktop Central and the Forwarding Server. It is critical that you import the Apple certs to Desktop Central first, and then copy Desktop Central’s keys over to the Forwarding Server. Otherwise you end up stuck on an extremely unhelpful error message when trying to enroll an iOS device remotely. The exact error you get is:

** PROFILE INSTALLATION FAILED**

Profile Failed To Install

With no explanation as to why that is happening.

Make sure you do the certs in the order specificed above. Your day will go a lot smoother if you do.

Release Notes

It’s been a while since I’ve posted to the blog. I had (and have) aspirations of writing here on a regular basis, not every day but certainly more often than I have been lately. I don’t have time to post every day (or multiple times a day) about news happening in the Sysadmin part of the world. There are better sites out there for that type of thing, this site doesn’t need to replicate work that already being done better elsewhere.

I want to focus more on longer/better but less frequent articles. I want to continue writing posts more like the Unifi post. This one is about the importance of reading release notes for all the bits of software sysadmins are responsible for in a modern datacenter.

I just finished a major software upgrade for my company’s production VMware cluster. It was running vSphere 5.5 xxxx and needed to be upgraded to 5.5 update 3, both to address a bug we were experiencing at the version we were at but to also get the wide range of security fixes that had been patched between the two builds. Seems simple enough, right? I mean just login to the vSphere client, connect to the vSphere Update Manager and go to town.

Not so much. I’ve got an approved maintenance window of 3 hours a week, same 3 hours every Thursday. The business knows that’s the time upgrades happen, but everything needs to be back in a running state before 10 PM. I can’t get all of this done in one 3 hour block, so things need to be kept happy and running between maintenance windows.

Besides vSphere, I also needed to account for the following:

Trend Micro Deep SecurityHas various hooks into each host in order to be able to inspect and product the guest VMs. Needs to support both the existing ESXi build as well update 3. Also needed to confirm that the new version of DSM would work with the existing appliances since they could only be upgraded as each host was upgraded in turn. -vShield Networking and Security
Needed upgraded to address bugs, etc but also needs to be upgraded to a version that is supported by Deep Security, the version of ESXi I was currently running, as well as the version of ESXi I would be going to.
Nutanix Controller VMs (NOS)Although there were no known issues at the time of update 3a’s release, I waited approximately 2 weeks for Nutanix to do internal QA with their code and Update 3a to ensure there were no tricky gotchas waiting for me. That’s great because that’s one less thing I need to worry about and it isn’t like I didn’t have a couple maintenance windows worth of other updates that needed to be applied for prior to rolling out the update hypervisor anyway.
Horizon View DesktopsNeeded to upgrade to a version of Horizon View that supported both the current build of ESXi I was on as well as the Update 3a. The VMware Product Interoperability listed no such version. I had to open a ticket with VMware support to verify which build of View I should go to. The matrix has since been updated to show version 6.1.1 was the magic build for me.
After a lot of checking, double checking, and note taking I had a comprehensive set of steps in Omnifocus that would result in an updated cluster that could be completed in chunks spread across several weeks with no downtime outside of the Thursday night maintenance window.

That process was:

Upgrade vShield Network
Update Deep Security Manager
Upgrade vCenter Server Appliance
Upgrade Horizon View Connection Server
Upgrade Nutanix Controller software
Begin updating the hypervisor on each host, one at a time.Pick first hostPut host in maintenance modeUpgrade vShield Endpoint Driver
Upgrade Trend Micro Filter Driver
Upgrade physical NIC drivers for ESXi (update needed)
Reboot
Remove old Trend Micro appliance
Provision new Trend Micro appliance
Apply vSphere updates
Reboot
Exit maintenance mode
Verify Nutanix Controller services restarted and rejoined the cluster
Repeat for additional hosts

I was lucky. I managed to just barely squeak by without needing to do multiple updates of a single product to get up to date. If I had waited much longer, I’d have had to upgrade vSphere partway, upgrade View, then upgraded vSphere the rest of the way, then finish updating View.

I’ve got resources in the cluster such that we can continue to run at 100% load with one host out of the cluster. I could power off test VMs and other non-critical servers to free up resources so that more than one host could be down at a time. But at the end of the day, I decided that the time savings from jumping through all the hoops to be able to reboot multiple hosts at once would likely be the same as if I just took down one host a time and vMotion’d everything around. In the end, I just did it one host a time. To get everything updated and make it through two reboots of a physical server (rebooting a VM has us all so spoiled, such a fast reboot cycle versus booting a physical server) took about an hour each. I ended up doing two hosts (back to back) in a maintenance window, so it took a few weeks to get everything done.

In news that will come as a shock to absolutely no one who reads a Sysadmin blog, before I got all my hosts upgraded to the latest and greatest build…….a new round of patches was released. Don’t get me wrong, bugs need fixed and security holes need patched. I’m glad to receive improvements and updates. I just need to not let it go so long between update cycles. It makes it a real pain to get it all sorted out.