Page 1 of 1

[Solved] 1.6 Server Autostart on Mac

PostPosted: Mon Feb 01, 2016 9:39 am
by mpi
Hi,

It seems the WIKI method (http://wiki.serviio.org/doku.php?id=mac ... _autostart) to disable Serviio autostart on Mac does not work anymore on Serviio 1.6 / El Capitan.
Please find my org.serviio.server.plist here:
http://pastebin.com/mwe1RZn0
Let me know if it is incorrect.

Maybe launchctl has evolved a bit recently...

Thanks for any hint.

Re: 1.6 Server Autostart on Mac

PostPosted: Mon Feb 01, 2016 10:54 am
by mpi
Replying to myself...

According to this:
It seems now the proper way to enable/disable launchdeamons is trhough -w option in launchctl command.
Indeed Disabled status is stored in area that are not accessible.

Therefore to disable autolaunch, one should type in terminal:
  Code:
sudo launchctl unload -w /Library/LaunchDaemons/org.serviio.server.plist

And to re-enable:
  Code:
sudo launchctl load -w /Library/LaunchDaemons/org.serviio.server.plist


to launch without consideration of Disable status:
  Code:
sudo launchctl load -F /Library/LaunchDaemons/org.serviio.server.plist[


@zip: can you please double-check and eventually update instructions in WIKI to disable autostart?
Thanks!

Re: 1.6 Server Autostart on Mac

PostPosted: Mon Feb 01, 2016 1:49 pm
by zip
It says -w override the Disabled flag, so I assume it still looks at the plist flag first.

I don't have a Mac around, so cannot confirm, can someone else ?

Re: 1.6 Server Autostart on Mac

PostPosted: Mon Feb 01, 2016 4:35 pm
by mpi
For some obscure reason it seems a default override is set to Disabled false in my system.
Can be seen with:
  Code:
sudo cat /var/db/com.apple.xpc.launchd/disabled.plist

LaunchControl utility confirms this.
I did try to rebuild launchd database with tools like Onyx, but same result.

Can't find a way to remove that override except by using -w option as described above.
Curious if anyone else has the same issue (Serviio starting whatever state of Disabled key inside modified /Library/LaunchDaemons/org.serviio.server.plist as per WIKI)

Best

Re: 1.6 Server Autostart on Mac

PostPosted: Mon Feb 01, 2016 9:59 pm
by mpi
Same issue on another Mac running Serviio 1.5 under El Capitan.

However, finally found a workaround to remove override.
Restart the Mac under recovery mode (cmd-R), and then, under terminal edit (with vi or other)
  Code:
/Volumes/<YourVolumeName>/var/db/com.apple.xpc.launchd/disabled.plist

removing
<key>org.serviio.server</key>
<false/>
(mind what you do!)
With that, WIKI instructions work as expected to disable Serviio on startup.
Then to start the server manually, one should type:
  Code:
sudo launchctl load -F /Library/LaunchDaemons/org.serviio.server.plist
and
  Code:
sudo launchctl unload /Library/LaunchDaemons/org.serviio.server.plist
to stop it.

The tiny AppleScript app below allows to toggle the server in any circumstances, and launch console.

Re: 1.6 Server Autostart on Mac

PostPosted: Tue Feb 02, 2016 8:58 am
by mpi
I think I found the root cause of the issue.
It probably lies in the post-install script of Serviio package:
  Code:
#!/bin/bash

SERVIIO_PLIST="/Library/LaunchDaemons/org.serviio.server.plist"

# Load and start the launch daemon
/bin/launchctl load -w $SERVIIO_PLIST

The -w option is the issue, as it sets the override!
Once set, Disable statement in plist as per WIKI is ignored.
It can not be removed at runtime: only through recovery (or single mode) as described above.

@zip, you may want to change to:
  Code:
/bin/launchctl load -F $SERVIIO_PLIST


Thanks.

EDIT: did set a Bitbucket ticket

Re: 1.6 Server Autostart on Mac

PostPosted: Tue Feb 02, 2016 4:24 pm
by zip
great, thanks

Re: 1.6 Server Autostart on Mac

PostPosted: Wed Feb 03, 2016 1:38 pm
by mpi
You're welcome.

...one more thing...
After some tests, It turns out that one can remove the Disabled override which had been set with previous Installers under normal session (no need for Restore or Single mode), by typing:
  Code:
sudo defaults delete /var/db/com.apple.xpc.launchd/disabled.plist org.serviio.server

You may want to add that line to newer installers (along with changing the -w to -L option as mentioned previously).
This will then fix the override issue for all users who installed Serviio with previous installers.

Note:
You can test if override has been previously set on your system with:
  Code:
sudo defaults read /var/db/com.apple.xpc.launchd/disabled.plist org.serviio.server
It will return an error if Override was not set, or the 1-true value if it was set.