Jump to content

How to get restart from the webinterface working on Ubuntu 14.04


Go to solution Solved by jant90,

Recommended Posts

Posted (edited)

I just installed Emby Server on my Ubuntu 14.04 server but I noticed I can't restart Emby from the webinterface.

 

Manually executing "sudo /usr/lib/emby-server/restart.sh" from cli works fine. However when pressing the restart button in the webinferce Emby only shuts down.

 

Is this a permissions issue of some sorts? I need to be root to successfully restart from cli.

 

I installed the latest stable Emby Server (3.0.5871.0) from the repo using apt-get as per the instructions.

 

EDIT:

I also tried a chown, but that didn't help either (so I changed it back to root just in case):

sudo chown -R emby:emby /usr/lib/emby-server

EDIT2:

It could also be useful to mention that Emby start fine when booting the system.

Edited by jant90
Posted

It's not just fresh installs, I've got the same thing here, since one or two updates ago (don't remember)

 

"sudo service restart emby-server" works and restart the server but not from the web interface (server shuts down and doesn't restart)

everydayevil
Posted

Just tested mine and confirmed for me as well.
I usually start/stop via sudo service emby-server rather than GUI button so didn't notice this.

I wonder if this impacts other emby initiated restarts (upgrade reboots, etc)

Posted (edited)

..............

Edited by mymovies
Posted

I also can not restart from the web page.

  • Solution
Posted

I looked at the sudoers file thinking Emby might not have the right permissions or something but I found quite a big file from Emby ensuring all required permissions were in place.

 

So I took the restart.sh file down to the very basic and now it's restarting fine from the web interface, so "sudo nano /usr/lib/emby-server/restart.sh":

#!/bin/bash
service emby-server restart

I hope this file will remain in tact during Emby updates.

  • Like 2
everydayevil
Posted (edited)

Disregard for now i misread some of that code and my changes were wrong... restart was intermittently working.

 

 

jant90,

 

I went through and looked at the restart.sh after I saw your fix.

I found the reason the existing code wasn't working.

 

 

if you want to fix the existing code use this.....

Tested on my system and working.

___________________________________________________
#!/bin/bash

NAME=emby-server

restart_cmds=("s6-svc -t /var/run/s6/services/${NAME}" \
  "systemctl restart ${NAME}" \
  "service ${NAME} restart" \
  "/etc/init.d/${NAME} restart" \
  "invoke-rc.d ${NAME} restart")

PIDFILE=`find /var/run -name "emby*.pid" -print -quit`
[ -n "$PIDFILE" ] && EMBY_PID=`cat ${PIDFILE} 2> /dev/null || true`

for restart_cmds in "${restart_cmds[@]}"; do
  cmd=$(echo "$restart_cmds" | awk '{print $1}')
  cmd_loc=$(command -v ${cmd})
  if [ -n "$cmd_loc" ]; then
    restart_cmds=$(echo "$restart_cmds" | sed -e "s%${cmd}%${cmd_loc}%")
    exec sudo $restart_cmds > /dev/null 2>&1 || true
    sleep 1
    if ! kill -0 $EMBY_PID > /dev/null; then
      break
    fi
  fi
done
_________________________________________________________________-

 

Luke,

 

There were multiple typos in the restart_cmds variable cmd singular vs cmds plural

 

-everydayevil

Edited by everydayevil
hurricanehrndz
Posted

This will not remain intact. The updates overwrite the file.

hurricanehrndz
Posted

Thank you all for your feedback though. I believe I discovered the issue. It has to do with the sudoers file. The emby group needs permission to secured directories such as /sbin. I will try and address it. 

  • Like 2
hurricanehrndz
Posted

Same here on Debian 7, but this started long time ago.

But its not such a big problem because i do most restarts with ssh.

Update and upgrade is not affected, also at server reboot it starts trough the init script.

I just tested a debian 7 clean install, version 3.0.5871.0 and restart works perfectly fine. 

 

I will check ubuntu 14.04 next.

hurricanehrndz
Posted

Can confirm an issue on ubuntu 14.04.

  • Like 1
runtimesandbox
Posted

From my experience it was an issue with Ubuntu 14.04

I have since moved to Debain 8.3 and it is not a problem there.

  • Like 1
hurricanehrndz
Posted

From my experience it was an issue with Ubuntu 14.04

I have since moved to Debain 8.3 and it is not a problem there.

Yes, it seems to be only an issue with 14.04.

  • 1 month later...
Posted (edited)

@@hurricanehrndz please fix this in the next release, if it's just an Ubuntu 14.04 issue then it's just a matter of detecting the OS and just doing a simple service restart.

 

My suggestion, place this code at the start of the restart.sh script and we, Ubuntu 14.04 users, are happy again:

#!/bin/bash
if [[ $(lsb_release -d) == *"Ubuntu 14.04"* ]] ; then
	service emby-server restart
	exit
fi

Easy enough and should have no downsides as it only executes on Ubuntu 14.04 systems.

Edited by jant90
AdamBearWA
Posted

Pretty sure I had the same issue in 15.04 & 15.10.

Also, when updating via apt-get, the service never comes back on. Might be related? 

hurricanehrndz
Posted

@@hurricanehrndz please fix this in the next release, if it's just an Ubuntu 14.04 issue then it's just a matter of detecting the OS and just doing a simple service restart.

 

My suggestion, place this code at the start of the restart.sh script and we, Ubuntu 14.04 users, are happy again:

#!/bin/bash
if [[ $(lsb_release -d) == *"Ubuntu 14.04"* ]] ; then
	service emby-server restart
	exit
fi

Easy enough and should have no downsides as it only executes on Ubuntu 14.04 systems.

I have tried running the command and that same script on my 14.04 and it will not restart. I don't see this issue anywhere else. I can not depend on lsb_release. I will try again. In my testing situations I have not be able to get emby to restart at all within 14.04 no matter what restart command I use.

hurricanehrndz
Posted

Pretty sure I had the same issue in 15.04 & 15.10.

Also, when updating via apt-get, the service never comes back on. Might be related? 

Not in my testing, if using systemd.

  • 3 weeks later...
Posted

Not in my testing, if using systemd.

I basically run apt-get -y install emby-server from cron (as root) every night to auto-update Emby and then it restarts perfectly fine indeed. However the restart.sh file gets overridden and to solve that issue for me I just added a line to my auto-update script to change the restart.sh script to what I proposed. This solves both the missing auto-update feature and the restart issue for me.

 

I do hope you get to the bottom of this issue though, the contradicting bug reports in this thread must be very frustrating.

hurricanehrndz
Posted

Yeah, with 16.04 about to come out. I hope people care a lot less about 14.04

 

Sent from my D6603 using Tapatalk

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...