Installing and Running from GIT on OSX (10.7+)

Most commonly asked questions will have thire awnsers here, please search before asking!
jbrickley
Junior Member
Posts: 4
Joined: 23 Jun 2012 22:58
Contact:
Status: Offline

Installing and Running from GIT on OSX (10.7+)

Postby jbrickley » 24 Jun 2012 08:19

[Disclaimer – This is a hack, so long as this configuration is not distributed by the authors of CouchPotatoServer – Use At Your Own Risk! Backup your data before attempting this configuration. I am not responsible for anything that goes wrong with your computer. If you are savvy enough to muck around inside the Terminal at a Unix shell prompt, then you should be OK. If not, kids don’t try this at home, I am a professional!]

How to install CouchPotatoServer on OS X 10.7+

Requirements:
1. Version control system git
a. Included with Xcode from Mac App Store (free)
b. Xcode -> Preferences -> Downloads -> Command line tools

Open Terminal located in /Applications/Utilities/Terminal

Unix commands to type in:

Code: Select all

cd /Applications
git clone https://github.com/RuudBurger/CouchPotatoServer.git
python CouchPotatoServer/CouchPotato.py


At this point you have a Terminal window you can’t close because it will terminate the CouchPotatoServer process you just started. The warning sheet dialog will say “Do you want to close this window? Closing this window will terminate the running processes: login, bash, Python”. This means you have to keep that terminal window running and who wants to do that?

Running CouchPotatoServer at boot time or login time

OS X manages all startup processes using a daemon called Launchd. This daemon (background service) manages the startup of just about everything on OS X. It is a very modern Open Source Unix service management framework. If you are a geek, and you have a Mac, you need to start looking it up! You could use it to launch scripts, watch folders, detect hardware changes, and perform any number of actions when those events occur.

Launchd requires an XML text file ending in ‘.plist’ that tells it what to do. Where you place this file determines when it runs.

  • /System/Library/LaunchDaemons – Reserved for operating system (DO NOT USE)
  • /System/Library/LaunchAgents - Reserved for operating system (DO NOT USE)
  • /Library/LaunchDaemons – Launch on Boot
  • /Library/LaunchAgents – Launch when any user logs in
  • /Users/$USERNAME/Library/LaunchAgents - Specific user login only

Most people will use one of their Mac’s to run CouchPotatoServer and are likely to install it under the primary user account that is logged on most all the time. In this case, it’s much simpler to put the Plist file in the ~/Library/LaunchAgents folder inside the primary users home folder. If you share it with another user you should be fine so long as your account is not logged out. i.e. fast user switching.

I have just recently started testing CouchPotatoServer running under /Library/LaunchDaemons so it starts up even if I am not logged on. This is ideal for a Mac server such as a Mac Mini, etc.

Here is the XML plist file, named “com.ruudburger.couchpotatoserver.plist”

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.ruudburger.couchpotatoserver</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/bin/python</string>
    <string>CouchPotato.py</string>
    <string>--quiet</string>
    <string>--daemon</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>WorkingDirectory</key>
  <string>/Applications/CouchPotatoServer</string>
</dict>
</plist>


All that code merely means run:

Code: Select all

/usr/bin/python /Applications/CouchPotatoServer/CouchPotato.py –quiet –daemon


Run when the primary user logs on

Code: Select all

cd ~/Library/LaunchAgents
pico com.ruudburger.couchpotatoserver.plist


Copy and Paste the XML Plist text above and press CTRL+X and save the modified buffer. Since this folder location belongs to the current user, there is no need to modify permissions, etc.

Start it by typing:

Code: Select all

launchctl load ~/Library/LaunchAgents/com.ruudburger.couchpotatoserver.plist


Go to http://localhost:5050/ and CouchPotatoServer should load.

Reboot and login again to make sure it still works.

~/Library/Application Data/CouchPotato is where the database, logs, etc. live.

Run at boot without needing to login

[ you should be comfortable using ‘sudo’ and dealing with permissions before you do it this way. There are several security features that are going to get in your way if you have to repair the SQLite DB or view logs, etc. ]

Putting this file in /Library/LaunchDaemons will make it run as the root (god account) user when the system boots. This file must be owned by the root user and have the proper permissions as well. To avoid having any weirdness due to legacy Mac resource forks;

You should just navigate to the global folder via:

Code: Select all

cd /Library/LaunchDaemons


Open the ‘pico’ text editor in the terminal and copy and paste the code block for the Plist file from this forum post.

Code: Select all

pico com.ruudburger.couchpotatoserver.plist


Use CTRL+X to close the file after you paste and save the modified buffer to save the file.

Change the permissions on the file so root is the owner and only root can write to the file, all others can only read.

Code: Select all

sudo chown root:wheel /Library/LaunchDaemons/com.ruudburger.couchpotatoserver.plist
sudo chmod 644 com.ruudburger.couchpotatoserver.plist


(yeah, you could just “pico com.ruudburger.couchpotatoserver.plist” and the file would by default be owned by root and the permissions would be set. But it’s good to know how to do it after the fact. i.e. someone is going to use BBEdit instead and have a problem<hint: resource forks are a pain in the arse!)

Start it by typing:

Code: Select all

sudo launchctl load ~/Library/LaunchAgents/com.ruudburger.couchpotatoserver.plist


Go to http://localhost:5050/ and CouchPotatoServer should load.

Reboot and do not login and try to access the server from another computer on your home LAN. e.g. http://192.168.X.X:5050 <- change X to your server’s IP.

Since you are running CouchPotatoServer as root, it lives in a special root user home folder.

Code: Select all

/var/root/Library/Application Support/CouchPotato


TIP: You can do ‘sudo –s’ to switch to the root user, then you can “cd /var/root/Library/Application Support/CouchPotato”.

Reply if you found anything else to contribute or need some help.

A Forum Admin may wish to turn this into a FAQ.

PandaPieMm
Junior Member
Posts: 4
Joined: 19 Jun 2012 21:57
Contact:
Status: Offline

RE: Start CouchPotatoServer at Login/Boot

Postby PandaPieMm » 24 Jun 2012 11:38

Thanks a lot for this awesome guide! It's going to really help me and a lot of others out

jbrickley
Junior Member
Posts: 4
Joined: 23 Jun 2012 22:58
Contact:
Status: Offline

RE: Start CouchPotatoServer at Login/Boot

Postby jbrickley » 24 Jun 2012 16:13

FYI, you can do the same with Sickbeard, in fact, I copied the Sickbeard plist from their forum and turned it into the CPS one. I haven't figured out SABnzb yet nor Plex Media Server.

bengalih
Senior Member
Posts: 334
Joined: 14 May 2012 23:39
Contact:
Status: Offline

RE: Installing and Running on OSX (10.7+)

Postby bengalih » 26 Jun 2012 18:19

Thanks for your time on this jbrickley.

Although unsupported, I don't see anything about this that is a hack to the actual CP files and mostly a guide to running at startup....

I am moving this to the FAQ forum and sticky-ing for others who may have these questions.

jbrickley
Junior Member
Posts: 4
Joined: 23 Jun 2012 22:58
Contact:
Status: Offline

RE: Installing and Running on OSX (10.7+)

Postby jbrickley » 22 Jul 2012 20:55

Arsenal wrote:Is there a reason this guide is only for 10.7+? How does one install v2/CouchPotatoServer in 10.6?


It should work on 10.6. I just haven't tried it. Same launchd system shouldn't be a problem.

bucketachicken
Junior Member
Posts: 13
Joined: 15 May 2012 03:30
Contact:
Status: Offline

RE: Installing and Running on OSX (10.7+)

Postby bucketachicken » 12 Aug 2012 09:28

jbrickley wrote:
Arsenal wrote:Is there a reason this guide is only for 10.7+? How does one install v2/CouchPotatoServer in 10.6?


It should work on 10.6. I just haven't tried it. Same launchd system shouldn't be a problem.


I know this is late, but for anyone who needs to know, it does indeed work on 10.6 -- I set up v2 a few months back and also looked at the SickBeard guide and modded it for CP. And still on 10.6, too lazy and no real need so far as I know to upgrade when it's just a media server, at least for now.

And as for
FYI, you can do the same with Sickbeard, in fact, I copied the Sickbeard plist from their forum and turned it into the CPS one. I haven't figured out SABnzb yet nor Plex Media Server.
it's pretty straightforward -- SAB and PMS have "run on login" options built-in which have never failed me, no need for plists.

mkopel
Junior Member
Posts: 2
Joined: 18 Aug 2012 20:26
Contact:
Status: Offline

RE: Installing and Running on OSX (10.7+)

Postby mkopel » 19 Aug 2012 07:06

thank you for the guide... worked perfect!
[hr]
one question. When I did a restart from inside couch potato, it did not restart. I had to manual use: launchctl start com.ruudburger.couchpotatoserver

would that be expected?

zoomby
Junior Member
Posts: 19
Joined: 27 Aug 2012 13:20
Contact:
Status: Offline

RE: Installing and Running on OSX (10.7+)

Postby zoomby » 09 Sep 2012 22:08

I think all about here for installing and running on OSX by jbrickley.Thanks again for this excellent contribution.

PinballWizard
Junior Member
Posts: 6
Joined: 31 Aug 2012 10:10
Contact:
Status: Offline

RE: Installing and Running on OSX (10.7+)

Postby PinballWizard » 13 Sep 2012 10:42

I'm having an issue where I can't restart CP (v2) if I launch it with the --daemon argument. If I start it with this arument, Restarting CP causes it to crash and the 'Python' process in Activity Monitor shoots up to 190% CPU usage. If I start it without the daemon argument, I can restart CP without any trouble.

Does anyone have any ideas why this might be happening?

Many thanks

PinballWizard
Junior Member
Posts: 6
Joined: 31 Aug 2012 10:10
Contact:
Status: Offline

RE: Installing and Running on OSX (10.7+)

Postby PinballWizard » 13 Sep 2012 15:09

That's got it working perfectly - I can restart without any issues now. Many thanks matthijsvdr!!! :)

RuudBurger
Main Honcho
Posts: 204
Joined: 10 May 2012 12:01
Been thanked: 9 times
Contact:
Status: Offline

RE: Installing and Running on OSX (10.7+)

Postby RuudBurger » 16 Sep 2012 22:13

You can now use the build for OSX (see homepage). Just drag the .app to your Application folder, done ;)

PinballWizard
Junior Member
Posts: 6
Joined: 31 Aug 2012 10:10
Contact:
Status: Offline

RE: Installing and Running on OSX (10.7+)

Postby PinballWizard » 17 Sep 2012 10:20

Thanks RuudBurger. The new Mac OSX build works great as an .app; however, I'm getting the dreaded "Do you want the application 'CouchPotato.app' to accept incoming network connections?" message box every time I start CP, despite it being added to the list of allowed applications in the firewall settings. SABNZBd had this bug for a while - I believe it's to do with the signing of the .app.


Return to “FAQ”