Help getting Plexconnect to work on Nas4free

Understood.

The current daemon code (or the latest changes to it) seem to postulate that you use a BASH shell: http://en.wikipedia.org/wiki/Bash_(Unix_shell)

Hense the file extension...

You are running it in a SH shell: http://en.wikipedia.org/wiki/Bourne_shell

Both are mostly similar - but not the same. Well, that is my understanding at least. I would put SH prior in history, with BASH following and (hopefully) doing things better... :-D

My advice...

a.) try running "bash" on your NAS. What does "./PlexConnect/PlexConnect_daemon.bash start" result in?

b.) install a decent BASH shell and try a.) again...

c.) revert the *_daemon.bash file to the prior version, which didn't do the directory link resolving.

If you need to go down that latter to c.) we might have to add a *.SH script without the new features. :-(

I installed BASH and everything works good now.  I did not have it installed in the jail.

Thanks for the help!

no problem... :-)

I installed BASH and everything works good now.  I did not have it installed in the jail.

Thanks for the help!

Hmm, okey so I updated my PlexConnect and tried. But didnt get it working how did you do it?

root@Mediacenter:/PlexConnect # bash
[root@Mediacenter /PlexConnect]# ./PlexConnect_daemon.bash start
bash: ./PlexConnect_daemon.bash: /bin/bash: bad interpreter: No such file or directory
[root@Mediacenter /PlexConnect]# ./PlexConnect/PlexConnect_daemon.bash start
bash: ./PlexConnect/PlexConnect_daemon.bash: No such file or directory
[root@Mediacenter /PlexConnect]#

Hmm, okey so I updated my PlexConnect and tried. But didnt get it working how did you do it?

root@Mediacenter:/PlexConnect # bash
[root@Mediacenter /PlexConnect]# ./PlexConnect_daemon.bash start
bash: ./PlexConnect_daemon.bash: /bin/bash: bad interpreter: No such file or directory
[root@Mediacenter /PlexConnect]# ./PlexConnect/PlexConnect_daemon.bash start
bash: ./PlexConnect/PlexConnect_daemon.bash: No such file or directory
[root@Mediacenter /PlexConnect]#

I am able to run the bash daemon through the following command:

root@PlexConnect:/ # bash /PlexConnect/PlexConnect_daemon.bash start
Starting PlexConnect...

hope this helps and works for you...

I am able to run the bash daemon through the following command:

root@PlexConnect:/ # bash /PlexConnect/PlexConnect_daemon.bash start
Starting PlexConnect...

hope this helps and works for you...

Yepp thanks alot.

Ole, I see that you updated the instructions but do you need to install bash as well on a standard setup?

Not on ny installation, when I ran pkg_add -r bash I got that it was already installed and I cant remember installing it previosly. Will check in a couple og days in a fresh jail after christmas.

Edit: Okey so I checked on my NAS on a fresh created jail, and bash are installed. But if anyone is having issues and need to install bash let me know and I update the guide.

Installed PlexConnect to a separate jail in freeNAS.

It finds my freeNAS Plex Server but not the one on my iMac? Any ideas?



Log?

Hello everyone!

Has anyone found a way to start the daemon automatically at jail startup?

Thanks

Just wanted to chime in and say that I had to install bash. Not a big deal but if you want to update your instructions, it might be easier for some people.

Also, I would love to know of a way to start this automatically! Any ideas?

I tried to create an rc.local file in /etc with this line, but it didn't work:

/usr/local/bin/bash /PlexConnect/PlexConnect_daemon.bash start

 

Also, I would love to know of a way to start this automatically! Any ideas?

Thanks allot for the guide. 

Managed to get it working. If you are using the official plexmediaserver plugin then you just have to install bash before you run the bash step.

pkg_add -r bash

No biggy. 

Just wanted to chime in and say that I had to install bash. Not a big deal but if you want to update your instructions, it might be easier for some people.

Also, I would love to know of a way to start this automatically! Any ideas?

Thanks allot for the guide. 

Managed to get it working. If you are using the official plexmediaserver plugin then you just have to install bash before you run the bash step.

pkg_add -r bash

No biggy. 

updated 1. post.

Has anyone gotten it to startup with the OS?

Make PlexConnect start with the OS:

- Okay. I am not a linux Guru and I am writing this as I go along so bear with me. 

- Furthermore, I assume you used this guide to install plexconnect and that you have installed all the required packages.

- Basically as I understand it (correct me if I am talking crap), if you want something to start at boot time you need to add a script to /etc/rc.d folder, 

- Since each jail runs its "own" little os within the jail you want the startup script to start when the vm is booted. 

- Also I assume that you are running all the scripts from the root directory. if you use CD to change directory change the commands accordingly. 

What you need:

  • Putty (or something similar)
  • A bit of patience. This is not difficult but you have to do a few things to get it working.

Initial Setup:

Putty


Connect to your Freenas using putty. Then similar to the guide above run the following command:

jls

then run 

jexec  csh

where jailnumber is the correct jail as returned by jls, if you installed plexconnect on the same jail as plexmediaserver.

Time to get messy:

While inside the jail run the following command to create the service script in rc.d:

nano /etc/rc.d/plexconnect

copy and paste the following code and then save and close the file. 

#!/bin/sh
#
#PROVIDE: PlexConnect
#REQUIRE: DAEMON
#KEYWORD: shutdown

. /etc/rc.subr

name=plexconnect
rcvar=plexconnect_enable

start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
extra_commands=“status”

plexconnect_start()
{
/usr/local/bin/bash /PlexConnect/PlexConnect_daemon.bash start
}
plexconnect_stop()
{
/usr/local/bin/bash /PlexConnect/PlexConnect_daemon.bash stop
}

plexconnect_status()
{
/usr/local/bin/bash /PlexConnect/PlexConnect_daemon.bash status
}

load_rc_config $name
run_rc_command “$1”

NOTE: if you installed PlexConnect in a different directory change the directory to the bash script. 

Next make sure the permissions are the same as the other scripts, run the following script:

chmod 0555 /etc/rc.d/plexconnect

Register the script (we will need this later):

Run the following command to open the rc.conf file:

nano /etc/rc.conf

and add the following line:

plexconnect_enable="Yes"  

It should look like this:

portmap_enable="NO"
sshd_enable="NO"
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
devfs_enable="YES"
devfs_system_ruleset="devfsrules_common"
plexconnect_enable="Yes"
plexmediaserver_enable="YES"

save and close the file.

Check that the script works:

so when you are in the root dir and you call:

/etc/rc.d/plexconnect start

and then calling:

/etc/rc.d/plexconnect status

and it returns:

PlexConnect is running

so great the script works. 

Now just run:

/etc/rc.d/plexconnect stop

So we make sure plex is not running before we try to start it as a service.

Setup the plexconnect service:

Now call same command from the service handler:

service plexconnect status

and you will get this if you use /usr/local/bin/bash:

/PlexConnect/PlexConnect_daemon.bash: line 29: python: command not found

No problem. We must edit the PlexConnect_daemon.bash so that it explicitly references the python instance. Run the following to open the .bash script:

nano /PlexConnect/PlexConnect_daemon.bash

You should the the following:

#!/bin/bash

Linux PlexConnect start stop script

Package

DNAME=“PlexConnect”
PNAME=“PlexConnect_daemon”

Others

current path resolver from http://stackoverflow.com/a/246128

SOURCE="${BASH_SOURCE[0]}"
while [ -h “$SOURCE” ]; do
DIR="$( cd -P “$( dirname “$SOURCE” )” && pwd )"
SOURCE="$(readlink “$SOURCE”)"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
INSTALL_DIR="$( cd -P “$( dirname “$SOURCE” )” && pwd )"

PYTHON=“python”
PROGRAM="${INSTALL_DIR}/${PNAME}.py"
PID_FILE="/var/${PNAME}.pid"

Edit the PYTHON line as follows (so that it references the python instance explicitly):

PYTHON="/usr/local/bin/python"

Save the file. 

FINALLY:

run the following command:

service plexconnect status

and it should return:

PlexConnect is not running

Okay great the service is now working. Thank god. Now just startup plexconnect:

service plexconnect start

So plexconnect is now running and it is a valid service. Yay. 

You can then test if it is working by either rebooting your NAS or toggling the plugins on off switch.

FINAL NOTE: When you update plexconnect. Make sure that you remember to re-edit the PlexConnect_daemon.bash file as that will be replaced when updating. 

--++00DONE00++--

Edit 1: Changed bash command in script to /usr/local/bin/bash (now the services compiler can find the bash command)

Edit 2: Changed PlexConnect_daemon.bash to point to python to /user/local/bin/python

Edit 3: Added startup to rc.conf

Edit 4: Moved the rc.conf step earlier.

Edit 5: Updated the guide to use only putty.

Thanks, this works.
 
Suggest some changes:
 
After chmod 555 for rc.d/plexconnect
first change the rc.conf:
plexconnect_enable="YES"
 
else you cannot start it.
Thanks, this works.
 
Suggest some changes:
 
After chmod 555 for rc.d/plexconnect
first change the rc.conf:
plexconnect_enable="YES"
 
else you cannot start it.

aha. thanks your the note. will update the post :)

aha. thanks your the note. will update the post :)

This was perfect. I was thinking about writing a how to on the FreeNas forums for installing plexconnect. Would you guys mind if I used some sections of your posts (with referencing of course)?