KhaosT / homebridge-amazondash

Amazon Dash Button plugin for Homebridge
58 stars 14 forks source link

Run Homebridge with elevated privileges? #3

Open michis0806 opened 8 years ago

michis0806 commented 8 years ago

Simple n00b-question: how do I run homebridge with "elevated privileges"?

KhaosT commented 8 years ago

sudo homebridge On Thu, Sep 1, 2016 at 3:42 PM michis0806 notifications@github.com wrote:

Simple n00b-question: how do I run homebridge with "elevated privileges"?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/KhaosT/homebridge-amazondash/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/ABpU4Mt2q3pg4IyOajffaoUFUodnhcwlks5qlz8GgaJpZM4JzImw .

ooii commented 6 years ago

But, how to start the homebridge service on ubuntu with elevated privileges? I know I should ask the question on the homebridge repo but maybe you faced the issue and can help.

In my case, if I run sudo homebridge, everything is fine. But if I start the service with service homebridge start, it hangs at:

Load homebridge-amazondash.AmazonDash
Load homebridge-camera-ffmpeg.Camera-ffmpeg
Load homebridge-edomoticz.eDomoticz

Note that the other plugins work perfectly if I don't use the amazondash one and without sudo.

Here is my init.d/homebridge file:

dir="/home/user/.homebridge"
cmd="DEBUG=* /home/user/.npm-global/bin/homebridge"
user="root"

name=`basename $0`
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"

get_pid() {
    cat "$pid_file"
}

is_running() {
    [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
}

case "$1" in
    start)
   ...

Thanks.

bobvann commented 4 years ago

Actually, you may just give capabilities.

If you run the following command from root, you won't need root permission to use pcap.

setcap cap_net_raw,cap_net_admin=eip /usr/bin/node