Showing posts with label plex. Show all posts
Showing posts with label plex. Show all posts

Thursday, April 3, 2014

Reversing launchctl of Plex (PMS)

In my previous post, I covered adding the behavior to support launching the Plex Media Server (PMS) after logging.  That was fine, except the extra cycles stolen from the general use of the machine was making the machine more painful to use.  With that, I am going to cover reversing the actions from my previous post to auto launch PMS after log in.  This will provide the needed resources that are required for the users at the machine.

First up, looking in the folder, /Library/LaunchAgents.  This proved to be a dead end.  The plist file originally entered there was now gone or I changed my mind (and don't remember).  I then looked in /Library/LaunchDaemons.  It sort of sounds the same, so why not right?  Again, nothing.  Hmm.

Well, worse case scenario, I know the file name.  I can just use the find command.
find / com.plex.pms.plist | grep plex.pms
Fairly brute force, but it worked!  In a matter of a couple of minutes I found my file.  It was in the directory, /System/Library/LaunchAgents.  It has been a while, so I don't recall placing the file there.  A quick change directory command into the folder and we can start surgically removing the auto launch of PMS.  First, let's unload the launch agent.
launchctl unload com.plex.pms.plist
Next, you can move or remove that file from the directory.  This will ensure that PMS doesn't automatically load when a user logs into the machine.

Now log out and log back into to your account.  You should see that you're no longer launching PMS at log in.

Tuesday, October 15, 2013

Auto-launch Plex Media Server on Mac OS X

I set out to find a solution that would load Plex Media Server (PMS) as a daemon process at the time my Mac booted.  I found that some folks were actually working on this solution.  The main solution I found was using an open source project, PlexConnect.  I tried a few different attempts at it.  I decided with my lack of interest in setting the whole solution up and the amount of seemingly direct ties to Apple TV, it was not the solution for me.

I found a plist file, com.plex.pms.plist on gtihub.  I dropped this file in to my /Library/LaunchAgents folder.  Soon I discovered the power of launchctl.  I added this plist through launchctl with following command.
launchctl load /Library/LaunchAgents/com.plex.pms.plist
Voila!  PMS was starting.  I tried to quit PMS and suddenly it was starting again.  This seemed promising.  Now I discovered that I had originally set up PMS with the current login.  Later I created a Plex account that then held all of my content.   I also wanted to have PMS auto launch with any of the primary logged in accounts.  This machine will generally have one of the logged in accounts active on the machine.  It is the primary machine for the house.

I started to investigate where PMS stored all of it's information.  I found information regarding for removing PMS from my mac, on the wiki.  Thus, I devised a plan.  I wanted to centralize that data into one location so that I could have any of the primary accounts login and the data presented on my Roku was the right data.

I created a folder in /var named Plex.  I re-created all of the primary directories inside of this folder mimicking the folder structure in a user account and moved those folders from the Plex user account.
  • Library/Application Support/Plex Media Server
  • Library/Caches/PlexMediaServer
  • Library/Preferences/com.plexapp.plexmediaserver.plist
After I moved all of that data to the /var location, I symlinked each of these locations into the two primary accounts as well as the Plex account.  In order to ensure that the data was fully accessible, I also made the /var/Plex/Library folder readable/writable by the Plex account and the group "everyone". This will ensure that if new data is found on my NAS drive holding my data, that it will be added regardless of the account launching PMS.

A relaunch of PMS and the Media Manager showed the information from my library as it was originally set up. This isn't the greatest solution, however, it works and satisfies my needs and requirements.  I could not make much head way with the other solutions or the lack of solution offered by PMS.