# PlexConnect on ArchLinux

**URL:** <https://forums.plex.tv/t/plexconnect-on-archlinux/55982>\
**Category:** Apps & Creations\
**Created:** [January 31, 2014, 2:16am UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982 "2014-01-31T02:16:26Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![odinb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/odinb/32/9516_2.png) [@odinb](https://forums.plex.tv/u/odinb)\
**Post date:** [January 31, 2014, 2:16am UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/1 "2014-01-31T02:16:26Z")

</div>

Hi!

&nbsp;

Anyone out there tried Plexconnect on ArchLinux?

&nbsp;

Starting it manually works just fine, but getting it to autostart, that is where I fail.

&nbsp;

Have put PlexConnect in this path: /home/PlexConnect-master

&nbsp;

I then created a systemd service file:

```
[root@alarm ~]# cat /etc/systemd/system/PlexConnect.service
[Unit]
Description=PlexConnect service
# Make sure we have functional network available
Requires=network.target
After=network.target

[Service]

# Allow process forking or oneshot

ExecStart=/usr/bin/sh /home/PlexConnect-master/PlexConnect.sh  
Type=forking  
RemainAfterExit=yes

# Restart service in case it fails after a minute

Restart=always  
RestartSec=60

[Install]  
WantedBy=multi-user.target  
[root@alarm ~]#
```

And activated it by doing:

```
systemctl enable PlexConnect
```

The PlexConnect.sh file is set to 755, and contains:

```
#!/bin/bash

/home/PlexConnect-master/PlexConnect.py
```

If I run it from the terminal, it works just fine:

```
[root@alarm PlexConnect-master]# /home/PlexConnect-master/PlexConnect.sh 
19:22:09 PlexConnect: ***
19:22:09 PlexConnect: PlexConnect
19:22:09 PlexConnect: Press CTRL-C to shut down.
19:22:09 PlexConnect: ***
19:22:09 PlexConnect: started: 19:22:09
19:22:09 PlexConnect: Version: 0.3.1+
19:22:09 PlexConnect: Python: 2.7.6 (default, Nov 29 2013, 11:17:54) 
[GCC 4.7.2]
19:22:09 PlexConnect: Host OS: linux2
19:22:09 PlexConnect: IP_self: 192.168.1.96
19:22:09 DNSServer: started: 19:22:09
19:22:09 DNSServer: ***
19:22:09 DNSServer: DNSServer: Serving DNS on 192.168.1.96 port 53.
19:22:09 DNSServer: intercept: ['trailers.apple.com'] => 192.168.1.96
19:22:09 DNSServer: restrain: ['mesu.apple.com', 'appldnld.apple.com', 'appldnld.apple.com.edgesuite.net'] => 127.0.0.1
19:22:09 DNSServer: forward other to higher level DNS: 8.8.8.8
19:22:09 DNSServer: ***
19:22:09 WebServer: started: 19:22:09
19:22:09 WebServer: ***
19:22:09 WebServer: WebServer: Serving HTTP on 192.168.1.96 port 80.
19:22:09 WebServer: ***
19:22:09 WebServer: started: 19:22:09
19:22:09 WebServer: ***
19:22:09 WebServer: WebServer: Serving HTTPS on 192.168.1.96 port 443.
```

But if I start the service manually:

```
systemctl start PlexConnect
```

or just reboot the server, it dies after about one and a half minute with the following log:

```
[root@alarm ~]# cat /home/PlexConnect-master/PlexConnect.log
20:02:50 PlexConnect: started: 20:02:50
20:02:50 PlexConnect: Version: 0.3.1+
20:02:50 PlexConnect: Python: 2.7.6 (default, Nov 29 2013, 11:17:54) 
[GCC 4.7.2]
20:02:50 PlexConnect: Host OS: linux2
20:02:50 Settings: getsetting enable_plexconnect_autodetect=True
20:02:50 PlexConnect: IP_self: 192.168.1.96
20:02:50 Settings: getsetting hosttointercept=trailers.apple.com
20:02:50 Settings: getsetting port_webserver=80
20:02:50 Settings: getsetting enable_dnsserver=True
20:02:51 DNSServer: started: 20:02:51
20:02:51 Settings: getsetting port_dnsserver=53
20:02:51 Settings: getsetting ip_dnsmaster=8.8.8.8
20:02:51 Settings: getsetting prevent_atv_update=True
20:02:51 DNSServer: ***
20:02:51 DNSServer: DNSServer: Serving DNS on 192.168.1.96 port 53.
20:02:51 DNSServer: intercept: ['trailers.apple.com'] => 192.168.1.96
20:02:51 DNSServer: restrain: ['mesu.apple.com', 'appldnld.apple.com', 'appldnld.apple.com.edgesuite.net'] => 127.0.0.1
20:02:51 DNSServer: forward other to higher level DNS: 8.8.8.8
20:02:51 DNSServer: ***
20:02:51 WebServer: started: 20:02:51
20:02:51 Settings: getsetting port_webserver=80
20:02:51 WebServer: ***
20:02:51 WebServer: WebServer: Serving HTTP on 192.168.1.96 port 80.
20:02:51 WebServer: ***
20:02:51 ATVSettings: init class CATVSettings
20:02:51 ATVSettings: load settings
20:02:51 Settings: getsetting enable_webserver_ssl=True
20:02:51 WebServer: started: 20:02:51
20:02:51 Settings: getsetting port_ssl=443
20:02:51 Settings: getsetting certfile=./assets/certificates/trailers.pem
20:02:51 Settings: getsetting certfile=./assets/certificates/trailers.pem
20:02:51 WebServer: ***
20:02:51 WebServer: WebServer: Serving HTTPS on 192.168.1.96 port 443.
20:02:51 WebServer: ***
20:04:19 PlexConnect: Shutting down.
20:04:19 DNSServer: Warning: DNS error (4): Interrupted system call
20:04:19 PlexConnect: Shutting down.
20:04:19 PlexConnect: Shutting down.
20:04:19 PlexConnect: Shutting down.
20:04:20 WebServer: Shutting down.
20:04:20 ATVSettings: save settings
20:04:20 WebServer: Shutting down.
20:04:24 DNSServer: Shutting down.
20:04:24 PlexConnect: shutdown
[root@alarm ~]#
```

What is causing the service to die after that duration?

What does "DNSServer: Warning: DNS error (4): Interrupted system call" mean?

---

<div class="post-metadata">

**Author:** ![baa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/baa/32/2026_2.png) [@baa](https://forums.plex.tv/u/baa)\
**Post date:** [January 31, 2014, 5:55am UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/2 "2014-01-31T05:55:55Z")

</div>

\>\>What does "DNSServer: Warning: DNS error (4): Interrupted system call" mean?

You pressed CTRL-C while python/your OS ran those DNS/networked handlers...

---

<div class="post-metadata">

**Author:** ![odinb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/odinb/32/9516_2.png) [@odinb](https://forums.plex.tv/u/odinb)\
**Post date:** [January 31, 2014, 4:42pm UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/3 "2014-01-31T16:42:46Z")

</div>

Nope, no one pressed CTRL-C, it happens "automagically" after the process has run for close to 1.5 min all the time.

---

<div class="post-metadata">

**Author:** ![baa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/baa/32/2026_2.png) [@baa](https://forums.plex.tv/u/baa)\
**Post date:** [January 31, 2014, 6:21pm UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/4 "2014-01-31T18:21:35Z")

</div>

That's cool...

---

<div class="post-metadata">

**Author:** ![f00b4r](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/f00b4r/32/768_2.png) [@f00b4r](https://forums.plex.tv/u/f00b4r)\
**Post date:** [January 31, 2014, 9:18pm UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/5 "2014-01-31T21:18:29Z")

</div>

Is there a reason you cannot use the bash daemon file on that distro?

---

<div class="post-metadata">

**Author:** ![odinb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/odinb/32/9516_2.png) [@odinb](https://forums.plex.tv/u/odinb)\
**Post date:** [January 31, 2014, 10:22pm UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/6 "2014-01-31T22:22:42Z")

</div>

This is what their Wiki states: [https://wiki.archlinux.org/index.php/Startup\_files](https://wiki.archlinux.org/index.php/Startup_files)

So therefor I used systemd as recommended. If I can get it working by other means, I would be happy to try it.

---

<div class="post-metadata">

**Author:** ![f00b4r](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/f00b4r/32/768_2.png) [@f00b4r](https://forums.plex.tv/u/f00b4r)\
**Post date:** [January 31, 2014, 10:56pm UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/7 "2014-01-31T22:56:34Z")

</div>

There is a daemon for Linux, the commands are:  
  
  
sudo ./PlexConnect\_daemon.bash start  
  
sudo ./PlexConnect\_daemon.bash status  
  
sudo ./PlexConnect\_daemon.bash stop

---

<div class="post-metadata">

**Author:** ![odinb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/odinb/32/9516_2.png) [@odinb](https://forums.plex.tv/u/odinb)\
**Post date:** [February 1, 2014, 8:25pm UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/8 "2014-02-01T20:25:09Z")

</div>

Well problem is that " **Warning:&nbsp;** Arch only supports&nbsp;[systemd](https://wiki.archlinux.org/index.php/Systemd "Systemd"). Arch's old initscripts package as described on this page is obsolete and is no longer supported. All Arch users need to&nbsp;[migrate to systemd](https://wiki.archlinux.org/index.php/Sysvinit#Migration_to_systemd "Sysvinit")."

[https://wiki.archlinux.org/index.php/initscripts](https://wiki.archlinux.org/index.php/initscripts)

But I gave it a spin anyways...

&nbsp;I created a systemd service file:

```
[root@alarm ~]# cat /etc/systemd/system/PlexConnect.service
[Unit]
Description=PlexConnect service

[Service]

# Allow process forking or oneshot

ExecStart=/usr/bin/sh /home/PlexConnect-master/PlexConnect\_daemon.bash  
Type=forking  
RemainAfterExit=yes

[Install]  
WantedBy=multi-user.target  
[root@alarm ~]#
```

Then I enabled it:

```
systemctl enable PlexConnect
```

The process still does not start at bootup, and checking with "systemctl list-units", it gives me:

```
PlexConnect.service loaded failed failed PlexConnect service
```

I cannot see any new entries in "/home/PlexConnect-master/PlexConnect.log"

Trying to start it manually:

```
./PlexConnect_daemon.bash start
```

It tells me:

```
Starting PlexConnect...
./PlexConnect_daemon.bash: line 29: python: command not found
[root@alarm PlexConnect-master]#
```

Which I think corresponds to this line:

```
${PYTHON} ${PROGRAM} --pidfile ${PID_FILE}
```

---

<div class="post-metadata">

**Author:** ![baa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/baa/32/2026_2.png) [@baa](https://forums.plex.tv/u/baa)\
**Post date:** [February 1, 2014, 9:58pm UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/9 "2014-02-01T21:58:53Z")

</div>

Maybe the environment variables are not fully set up yet?

---

<div class="post-metadata">

**Author:** ![odinb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/odinb/32/9516_2.png) [@odinb](https://forums.plex.tv/u/odinb)\
**Post date:** [February 2, 2014, 3:17am UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/10 "2014-02-02T03:17:29Z")

</div>

Finally found a workaround!

Seems there is some kind of resource that is needed that is not up when the service starts and it therefor fails, and it seems an environment variable was missing also.

To get it working on Archlinux as a systemd service:

Create a systemd file (/etc/systemd/system/PlexConnect.service) containing this:

```
[Unit]
Description=PlexConnect service

[Service]

# Allow one of simple, forking, oneshot, dbus, notify or idle process

Type=oneshot  
RemainAfterExit=yes  
ExecStart=/usr/bin/sh /home/PlexConnect-master/PlexConnect.sh

[Install]  
WantedBy=multi-user.target
```

"Type=oneshot" is used, since the timeout is disabled by default for this parameter.

If other type is used (simple, forking, dbus, notify or idle), the service will be killed after approximately 1.5 minute.

Create a&nbsp;PlexConnect.sh file (/home/PlexConnect-master/PlexConnect.sh) containing this, and set it to 755:

```
#!/bin/bash
sleep 5
python2 /home/PlexConnect-master/PlexConnect.py
```

"sleep 5" is needed in order for other process to start during boot prior to this service.

"python 2" is needed to compensate for missing env variable.

To make it start on boot, use:

```
systemctl enable PlexConnect
```

Then reboot your machine:

```
/sbin/reboot
```

After this, PlexConnect now starts at boot-up!

Useful commands to troubleshoot this are:

List active service Status:

```
systemctl list-units
```

&nbsp;

Detailed log of what happened:

```
journalctl -xn
```

---

<div class="post-metadata">

**Author:** ![wahlman.j](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/wahlman.j/32/6441_2.png) [@wahlman.j](https://forums.plex.tv/u/wahlman.j)\
**Post date:** [February 2, 2014, 3:36am UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/11 "2014-02-02T03:36:00Z")

</div>

Interesting in OSX I used a sleep 1 string in my app OpenConnect and WebConnect in my signature to get rid the non-bash plist I was always using specifically in plexconnect.bash that waits for network readiness and then runs plexconnect.py when the network becomes available. Guess there is a timing issue with arch Linux as well. Can you try to lower the timeout to sleep 1 and see if it still works?  
  
[https://github.com/wahlmanj/PlexConnect/blob/master/update/OSX/PlexConnect.bash](https://github.com/wahlmanj/PlexConnect/blob/master/update/OSX/PlexConnect.bash)  
  
  
You may be able to still use the bash if you include it in there similar to how I set it up for OSX.

---

<div class="post-metadata">

**Author:** ![odinb](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/odinb/32/9516_2.png) [@odinb](https://forums.plex.tv/u/odinb)\
**Post date:** [February 2, 2014, 5:23am UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/12 "2014-02-02T05:23:41Z")

</div>

It works with "sleep 3", but when I go to "sleep 2" it stops working. So to be safe, I left it on "sleep 5".

---

<div class="post-metadata">

**Author:** ![f00b4r](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/f00b4r/32/768_2.png) [@f00b4r](https://forums.plex.tv/u/f00b4r)\
**Post date:** [February 2, 2014, 9:24am UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/13 "2014-02-02T09:24:36Z")

</div>

> Interesting in OSX I used a sleep 1 string in my app OpenConnect and WebConnect in my signature to get rid the non-bash plist I was always using specifically in plexconnect.bash that waits for network readiness and then runs plexconnect.py when the network becomes available. Guess there is a timing issue with arch Linux as well. Can you try to lower the timeout to sleep 1 and see if it still works?  
>   
> [https://github.com/wahlmanj/PlexConnect/blob/master/update/OSX/PlexConnect.bash](https://github.com/wahlmanj/PlexConnect/blob/master/update/OSX/PlexConnect.bash)  
>   
> You may be able to still use the bash if you include it in there similar to how I set it up for OSX.

  
That's because you are running a hackintosh.  
The network readiness codes only kicks in if it detects you are running OSX, it does not do anything for Linux.

---

<div class="post-metadata">

**Author:** ![baa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/baa/32/2026_2.png) [@baa](https://forums.plex.tv/u/baa)\
**Post date:** [February 2, 2014, 11:21am UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/14 "2014-02-02T11:21:08Z")

</div>

Would the network detection work on Linux as well? I guess it would be better to have a "real" test than just a sleep...

---

<div class="post-metadata">

**Author:** ![Dimtar](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dimtar/32/82828_2.png) [@Dimtar](https://forums.plex.tv/u/Dimtar)\
**Post date:** [March 27, 2014, 8:07am UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/15 "2014-03-27T08:07:22Z")

</div>

Hi all.

Trying to get PlexConnect running on an Arch Linux VM..

Running this command gives an error:

[root@IronicsArchVM\_v4 PlexConnect]# ./PlexConnect.py

Traceback (most recent call last):

&nbsp; File "./PlexConnect.py", line 18, in 

&nbsp; &nbsp; import DNSServer, WebServer

&nbsp; File "/mnt/data/PlexConnect/DNSServer.py", line 116

&nbsp; &nbsp; print "ID {0:04x}".format((ord(paket[0])\<\<8)+ord(paket[1]))

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^

SyntaxError: invalid syntax

[root@IronicsArchVM\_v4 PlexConnect]# ./PlexConnect.py

Traceback (most recent call last):

&nbsp; File "./PlexConnect.py", line 18, in 

&nbsp; &nbsp; import DNSServer, WebServer

&nbsp; File "/mnt/data/PlexConnect/DNSServer.py", line 116

&nbsp; &nbsp; print "ID {0:04x}".format((ord(paket[0])\<\<8)+ord(paket[1]))

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^

SyntaxError: invalid syntax

&nbsp;

&nbsp;

I believe I have python2 so I am not sure what the issue might be.

&nbsp;

EDIT:

Turns out it was because the python script was trying to use the default python (which is 3) I updated the file a little and it started working by following this:

[https://wiki.archlinux.org/index.php/python](https://wiki.archlinux.org/index.php/python)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 21, 2019, 1:11am UTC](https://forums.plex.tv/t/plexconnect-on-archlinux/55982/16 "2019-12-21T01:11:42Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
