Choose style:

Author Topic: startup daemon (SOLVED)  (Read 16193 times)

0 Members and 1 Guest are viewing this topic.

Offline kiwi_guy

  • Jr. Member
  • **
  • Posts: 29
  • Karma: 0
  • New Forum User
    • View Profile
  • Peppermint version(s): 3.8.0-35-generic
startup daemon (SOLVED)
« on: July 13, 2014, 11:36:30 pm »
I have installed Plexconnect and want to set it up so the PlexConnect_daemon.bash start when the system starts.

Not sure what info someone may need so will say that to start manually I need to runt he following:

Code: [Select]
plex@plex ~/plexconnect/PlexConnect-master $ sudo ./PlexConnect_daemon.bash start

Been trying to follow to some Ubunto forums on the Plex forums but having issues as none are specific to Peppermint.

Any help or info required to help let me know

Thanks


« Last Edit: July 29, 2014, 03:01:13 am by kiwi_guy »

Offline kiwi_guy

  • Jr. Member
  • **
  • Posts: 29
  • Karma: 0
  • New Forum User
    • View Profile
  • Peppermint version(s): 3.8.0-35-generic
Re: startup daemon
« Reply #1 on: July 14, 2014, 05:00:00 pm »
Just a bit more as the above is a bit light:

I have a peppermint machine which is a standalone media server running Plex. My smart TV has the Plex app so that talks to it fine, but the TV in my kids play room isn't so smart. I have an Apple TV3 set in there for Netflix but there is alot of movies on the media server that she likes. I installed PlexConnect so that I can access the content from the Apple TV by following:

https://github.com/iBaa/PlexConnect/wiki/Install-Guide-Linux

Now where I am getting stuck is that because the machine doesn't have a screen attached to have to manually start the PlexCOnnect Daemon each time is a pain I tried this:

https://github.com/iBaa/PlexConnect/wiki/nix-autostart

But following what they did for the Ubuntu I was getting file does not exist errors and didn't want to start trying to play too much without checking here.
« Last Edit: July 14, 2014, 05:01:34 pm by kiwi_guy »

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 22015
  • Karma: 2468
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R and 9
Re: startup daemon
« Reply #2 on: July 18, 2014, 02:46:17 pm »
Does it NEED to be run as root ?

or can it  be started with:
Code: [Select]
/home/plex/plexconnect/PlexConnect-master/PlexConnect_daemon.bash start
?
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline kiwi_guy

  • Jr. Member
  • **
  • Posts: 29
  • Karma: 0
  • New Forum User
    • View Profile
  • Peppermint version(s): 3.8.0-35-generic
Re: startup daemon
« Reply #3 on: July 20, 2014, 03:59:55 am »
I do get asked for my root pw as soon as enter this command, been thinking this is the sticking point.

I am also looking at upgrading the whole system to v5 in the near future and what I was trying to accomplish I have found that it caused me issues with legit stuff through the ATV3. How would you like me to sign off this thread? As it will be a month or so before I do the upgrade I don't mind playing if you have any suggestions and trying to get it working so its here for future visitors, but I don't want to waste anyones time trying to solve something that that time is better spent on other issues.
« Last Edit: July 20, 2014, 04:20:48 am by kiwi_guy »

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 22015
  • Karma: 2468
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R and 9
Re: startup daemon
« Reply #4 on: July 20, 2014, 08:19:30 am »
Can you post the contents of:
Code: [Select]
gedit /home/plex/plexconnect/PlexConnect-master/PlexConnect_daemon.bash
and the output from:
Code: [Select]
echo $USER
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline kiwi_guy

  • Jr. Member
  • **
  • Posts: 29
  • Karma: 0
  • New Forum User
    • View Profile
  • Peppermint version(s): 3.8.0-35-generic
Re: startup daemon
« Reply #5 on: July 20, 2014, 11:31:27 pm »
Location changed slightly from my initial post

Code: [Select]
plex@plex ~ $ gedit /usr/local/lib/PlexConnect/PlexConnect-master/PlexConnect_daemon.bash

File:

Code: [Select]
#!/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"


start_daemon ()
{
    cd "${INSTALL_DIR}"
    ${PYTHON} ${PROGRAM} --pidfile ${PID_FILE}
}

stop_daemon ()
{
    kill `cat ${PID_FILE}`
    wait_for_status 1 20 || kill -9 `cat ${PID_FILE}`
    rm -f ${PID_FILE}
}

daemon_status ()
{
    if [ -f ${PID_FILE} ] && kill -0 `cat ${PID_FILE}` > /dev/null 2>&1; then
        return
    fi
    rm -f ${PID_FILE}
    return 1
}

wait_for_status ()
{
    counter=$2
    while [ ${counter} -gt 0 ]; do
        daemon_status
        [ $? -eq $1 ] && return
        let counter=counter-1
        sleep 1
    done
    return 1
}

# Determine if the network is up by looking for any non-loopback network interfaces.
# Currently supports only OSX "Darwin" OS

CheckForNetwork()
{
local test

if [ -z "${NETWORKUP:=}" ]; then
test=$(ifconfig -a inet 2>/dev/null | sed -n -e '/127.0.0.1/d' -e '/0.0.0.0/d' -e '/inet/p' | wc -l)
if [ "${test}" -gt 0 ]; then
NETWORKUP="-YES-"
else
NETWORKUP="-NO-"
fi
fi
}

# Determine if the operating system is OSX "darwin". If so, then delay running the rest of
# the script until the network is up. This avoids the binding of PlexConnect to the
# loopback address which occurs if the bash script is called from a LaunchDaemon/plist
# file at boot time.

if [[ "$OSTYPE" == "darwin"* ]]; then
CheckForNetwork
while [ "${NETWORKUP}" != "-YES-" ]
do
sleep 5
NETWORKUP=
CheckForNetwork
done
fi

# Now do what you need to do.

case $1 in
    start)
        if daemon_status; then
            echo ${DNAME} is already running
        else
            echo Starting ${DNAME}...
            start_daemon
        fi
        ;;
    stop)
        if daemon_status; then
            echo Stopping ${DNAME}...
            stop_daemon
        else
            echo ${DNAME} is not running
        fi
        ;;
    status)
        if daemon_status; then
            echo ${DNAME} is running
            exit 0
        else
            echo ${DNAME} is not running
            exit 1
        fi
        ;;
    restart)
        $0 stop && sleep 2 && $0 start && sleep 2 && $0 status
        ;;
    *)
        exit 1
        ;;
esac

Code: [Select]
plex@plex ~ $ echo $USER
plex
plex@plex ~ $

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 22015
  • Karma: 2468
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R and 9
Re: startup daemon
« Reply #6 on: July 21, 2014, 07:22:59 am »
Can you post the output from:
Code: [Select]
ls -al /etc/init.d/plexconnect
and
Code: [Select]
ls -al /home/plex/plexconnect/PlexConnect-master/PlexConnect_daemon.bash
and
Code: [Select]
ls /etc/rc*.d
« Last Edit: July 21, 2014, 07:28:39 am by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline kiwi_guy

  • Jr. Member
  • **
  • Posts: 29
  • Karma: 0
  • New Forum User
    • View Profile
  • Peppermint version(s): 3.8.0-35-generic
Re: startup daemon
« Reply #7 on: July 21, 2014, 03:48:48 pm »
]The second command didn't work but that I think is due to me chaning locations of where the folder was to reflect that of where it was in the guide I was trying to follow.

Was originally home/plex/...  now usr/local/lib/...

I did both incase I should have something in home/plex that is being referenced that I have missed the boat on on my code checks between provided code and my particular set up

Code: [Select]

plex@plex ~ $ ls -al /etc/init.d/plexconnect
-rwxr-xr-x 1 root root 2612 Jul 15 13:21 /etc/init.d/plexconnect

plex@plex ~ $ ls -al /home/plex/plexconnect/PlexConnect-master/PlexConnect_daemon.bash
ls: cannot access /home/plex/plexconnect/PlexConnect-master/PlexConnect_daemon.bash: No such file or directory

plex@plex ~ $ ls -al /usr/local/lib/PlexConnect/PlexConnect-master/PlexConnect_daemon.bash
-rwxr-xr-x 1 plex plex 2630 Jul  5 09:14 /usr/local/lib/PlexConnect/PlexConnect-master/PlexConnect_daemon.bash

plex@plex ~ $ ls /etc/rc*.d
/etc/rc0.d:
K10unattended-upgrades  K20plexconnect  S30urandom       S60umountroot
K20hddtemp              README          S31umountnfs.sh  S90halt
K20nullmailer           S20sendsigs     S40umountfs

/etc/rc1.d:
K20hddtemp     K20plexconnect  README        S70dns-clean  S90single
K20nullmailer  K77ntp          S30killprocs  S70pppd-dns

/etc/rc2.d:
README      S20nullmailer   S23ntp    S70dns-clean  S75sudo         S99ondemand
S20hddtemp  S20plexconnect  S50rsync  S70pppd-dns   S99grub-common  S99rc.local

/etc/rc3.d:
README      S20nullmailer   S23ntp    S70dns-clean  S75sudo         S99ondemand
S20hddtemp  S20plexconnect  S50rsync  S70pppd-dns   S99grub-common  S99rc.local

/etc/rc4.d:
README      S20nullmailer   S23ntp    S70dns-clean  S75sudo         S99ondemand
S20hddtemp  S20plexconnect  S50rsync  S70pppd-dns   S99grub-common  S99rc.local

/etc/rc5.d:
README      S20nullmailer   S23ntp    S70dns-clean  S75sudo         S99ondemand
S20hddtemp  S20plexconnect  S50rsync  S70pppd-dns   S99grub-common  S99rc.local

/etc/rc6.d:
K10unattended-upgrades  K20plexconnect  S30urandom       S60umountroot
K20hddtemp              README          S31umountnfs.sh  S90reboot
K20nullmailer           S20sendsigs     S40umountfs

/etc/rcS.d:
README  S37apparmor  S47lm-sensors  S51mintsystem  S55urandom  S70x11-common

I just noticed that daemon is plex plex do I need to chmod  root:root or has doing that to the init.d file caused the issues

Offline kiwi_guy

  • Jr. Member
  • **
  • Posts: 29
  • Karma: 0
  • New Forum User
    • View Profile
  • Peppermint version(s): 3.8.0-35-generic
Re: startup daemon
« Reply #8 on: July 21, 2014, 04:27:57 pm »
I think somewhere in my attempts to get this running i HAVE MADE A SERIOUS HASH.

Been trying to install Arista and Unetbootin via the software manager but when I try and install it starts then reverts back to saying install.

Wondering it would pay for me setup a bootable USB and then over write the PM3 with version 5 and start again with my installs of Plex and PlexConnect and try from there as something seems weird with my current setup

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 22015
  • Karma: 2468
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R and 9
Re: startup daemon
« Reply #9 on: July 21, 2014, 04:48:11 pm »
Your call .. let me know what you want to do

just as a matter of interest, what's the output from:
Code: [Select]
ps aux | grep [p]lex

[EDIT]

Can you also link to the tutorial you're following, and where you downloaded plexconnect
« Last Edit: July 21, 2014, 04:57:27 pm by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline kiwi_guy

  • Jr. Member
  • **
  • Posts: 29
  • Karma: 0
  • New Forum User
    • View Profile
  • Peppermint version(s): 3.8.0-35-generic
Re: startup daemon
« Reply #10 on: July 22, 2014, 03:28:02 am »
Code: [Select]
plex@plex ~ $ ps aux | grep [p]lex
plex      1444  0.0  0.1  71144  6656 ?        Ssl  19:19   0:00 /usr/bin/lxsession -s Peppermint -e LXDE
plex      1489  0.0  0.0   4132   204 ?        Ss   19:19   0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session /usr/bin/im-launch /usr/bin/startpeppermint
plex      1492  0.0  0.0   3884   784 ?        S    19:19   0:00 /usr/bin/dbus-launch --exit-with-session /usr/bin/im-launch /usr/bin/startpeppermint
plex      1493  0.0  0.0   4084  1392 ?        Ss   19:19   0:00 //bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
plex      1506  0.0  0.0  46828  3204 ?        Sl   19:19   0:00 /usr/bin/gnome-keyring-daemon --start --components=ssh
plex      1514  0.0  0.0  28664  2688 ?        Sl   19:19   0:00 /usr/lib/gvfs/gvfsd
plex      1518  0.0  0.0  42632  2796 ?        Sl   19:19   0:00 /usr/lib/gvfs//gvfsd-fuse -f /run/user/plex/gvfs
plex      1521  0.4  0.2  46284 10328 ?        S    19:19   0:00 xfwm4
plex      1531  0.6  0.4  91472 15264 ?        Sl   19:19   0:01 lxpanel --profile Peppermint
plex      1532  0.0  0.0   8900  2444 ?        S    19:19   0:00 xscreensaver -no-splash
plex      1534  0.2  0.5 121832 20252 ?        Sl   19:19   0:00 pcmanfm --desktop --profile peppermint
plex      1535  0.0  0.1  52308  6104 ?        Sl   19:19   0:00 /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
plex      1550  0.0  0.3 104864 11864 ?        Sl   19:19   0:00 update-notifier
plex      1552  0.0  0.1  77640  6172 ?        Sl   19:19   0:00 zeitgeist-datahub
plex      1556  0.1  0.4 118360 16412 ?        Sl   19:19   0:00 nm-applet
plex      1578  0.0  0.0   2272   552 ?        S<   19:19   0:00 /bin/sh /usr/sbin/start_pms
plex      1587  0.1  0.5 185988 20172 ?        S<l  19:19   0:00 ./Plex Media Server
plex      1618  0.0  0.0  42988  3496 ?        Sl   19:19   0:00 /usr/bin/zeitgeist-daemon
plex      1621  0.0  0.0   6560  1688 ?        S    19:19   0:00 xbindkeys
plex      1627  0.0  0.1  50168  4732 ?        Sl   19:19   0:00 /usr/lib/zeitgeist/zeitgeist-fts
plex      1634  0.0  0.1  61016  4260 ?        Ssl  19:19   0:00 xfce4-power-manager
plex      1636  0.0  0.1  29888  4048 ?        Sl   19:19   0:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
plex      1639  0.0  0.2  62904  7972 ?        Sl   19:19   0:00 /usr/lib/i386-linux-gnu/notify-osd
plex      1643  0.0  0.0  15732  2824 ?        Ssl  19:19   0:00 /usr/lib/i386-linux-gnu/menu-cache/menu-cached
plex      1658  0.0  0.0  27680  2460 ?        Sl   19:19   0:00 /usr/lib/gvfs/gvfs-mtp-volume-monitor
plex      1662  0.0  0.0  28908  2644 ?        Sl   19:19   0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
plex      1663  0.0  0.0   5488   284 ?        S    19:19   0:00 /bin/cat
plex      1667  0.0  0.0  40188  2844 ?        Sl   19:19   0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
plex      1675  0.0  0.0  43148  2984 ?        Sl   19:19   0:00 /usr/lib/at-spi2-core/at-spi-bus-launcher
plex      1683  2.3  0.7 178480 27520 ?        SNl  19:19   0:03 Plex Plug-in [com.plexapp.system] /home/plex/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 0.9.8.18.290-11b7fdd /home/plex/Library/Application Support/Plex Media Server/Plug-ins/System.bundle
plex      1688  0.0  0.0   3284  1424 ?        S    19:19   0:00 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
plex      1703  0.0  0.0  17184  3092 ?        Sl   19:19   0:00 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-session
plex      1715  0.0  0.0   6352  2280 ?        S    19:19   0:00 /usr/lib/i386-linux-gnu/xfce4/xfconf/xfconfd
plex      1743  0.0  0.0  10120  2384 ?        S    19:19   0:00 /usr/lib/i386-linux-gnu/gconf/gconfd-2
plex      1897  0.0  0.4 154708 16028 ?        S<l  19:19   0:00 /usr/lib/plexmediaserver/Plex DLNA Server
plex      1930  1.1  0.6 124208 21892 ?        S<l  19:19   0:01 Plex Plug-in [com.plexapp.agents.themoviedb] /home/plex/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 0.9.8.18.290-11b7fdd /home/plex/Library/Application Support/Plex Media Server/Plug-ins/The-Movie-Database.bundle
plex      2013  6.3  2.6 528368 95868 ?        Sl   19:19   0:08 chromium-browser                         
plex      2019  0.1  0.2 150764  7548 ?        S    19:19   0:00 chromium-browser                         
plex      2020  0.0  0.0   3620   900 ?        S    19:19   0:00 /usr/lib/chromium-browser/chrome-sandbox /usr/lib/chromium-browser/chromium-browser --type=zygote
plex      2021  0.1  0.5 164796 19980 ?        S    19:19   0:00 chromium-browser --type=zygote                         
plex      2025  0.0  0.1 164796  4816 ?        S    19:19   0:00 chromium-browser --type=zygote                         
plex      2055  0.7  1.2 233928 44068 ?        Sl   19:19   0:00 /usr/lib/chromium-browser/chro                         
plex      2062  4.4  1.7 249448 63796 ?        Sl   19:19   0:06 /usr/lib/chromium-browser/chro                         
plex      2075  0.2  0.7 220864 25768 ?        Sl   19:19   0:00 /usr/lib/chromium-browser/chro                         
plex      2109  0.1  0.6 179020 24780 ?        Sl   19:19   0:00 chromium-browser --type=gpu-process --channel=2013.6.1497758331 --supports-dual-gpus=false --gpu-driver-bug-workarounds=0,8,22 --disable-accelerated-video-decode --gpu-vendor-id=0x8086 --gpu-device-id=0x2e12 --gpu-driver-vendor=Mesa --gpu-driver-version=9.1
plex      2113  0.0  0.1 169800  6196 ?        S    19:19   0:00 chromium-browser --type=gpu-process --channel=2013.6.1497758331 --supports-dual-gpus=false --gpu-driver-bug-workarounds=0,8,22 --disable-accelerated-video-decode --gpu-vendor-id=0x8086 --gpu-device-id=0x2e12 --gpu-driver-vendor=Mesa --gpu-driver-version=9.1
plex      2117  3.0  1.0 217492 37484 ?        Sl   19:19   0:03 chromium-browser --type=plugin --plugin-path=/usr/lib/flashplugin-installer/libflashplayer.so --lang=en-GB --channel=2013.7.15497482
plex      2129  0.9  1.3 237104 49704 ?        Sl   19:20   0:00 /usr/lib/chromium-browser/chro                         
plex      2155  1.0  0.4  82300 14600 ?        Rl   19:21   0:00 lxterminal
plex      2156  0.0  0.0   2440   720 ?        S    19:21   0:00 gnome-pty-helper
plex      2157  0.1  0.0   7400  2536 pts/0    Ss   19:21   0:00 /bin/bash
plex      2202  0.0  0.0   6460  1188 pts/0    R+   19:21   0:00 ps aux
plex      2203  0.0  0.0   5656   844 pts/0    S+   19:21   0:00 grep --colour=auto [p]lex

The tutorial I was following is

https://github.com/iBaa/PlexConnect/wiki/Install-Guide-Linux

Plexconnect that I got was in here, the next few bits I have done are from following the link at the bottom.

I am happy to keep going did some digging today and I have only played with stuff related to Plex and it looks like the New Zealand servers are my problem. Trouble shooting why I can't get onto servers to do software updates so will do that on the side and keep working with you on this and will do the upgrade at a later date.

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 22015
  • Karma: 2468
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R and 9
Re: startup daemon
« Reply #11 on: July 22, 2014, 02:00:00 pm »
Do you have to run:
Code: [Select]
/usr/local/lib/PlexConnect/PlexConnect-master/PlexConnect_daemon.bash start
or will it start without the "start" at the end, as in:
Code: [Select]
/usr/local/lib/PlexConnect/PlexConnect-master/PlexConnect_daemon.bash
?

And can you post the contents of:
Code: [Select]
gedit /etc/init.d/plexconnect
« Last Edit: July 22, 2014, 02:01:34 pm by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline kiwi_guy

  • Jr. Member
  • **
  • Posts: 29
  • Karma: 0
  • New Forum User
    • View Profile
  • Peppermint version(s): 3.8.0-35-generic
Re: startup daemon
« Reply #12 on: July 22, 2014, 03:30:27 pm »
It has to have start in front

Code: [Select]
plex@plex /usr/local/lib/PlexConnect/PlexConnect-master $ sudo ./PlexConnect_daemon.bash status
PlexConnect is not running
plex@plex /usr/local/lib/PlexConnect/PlexConnect-master $ sudo ./PlexConnect_daemon.bash start
Starting PlexConnect...
plex@plex /usr/local/lib/PlexConnect/PlexConnect-master $ sudo ./PlexConnect_daemon.bash status
PlexConnect is running
plex@plex /usr/local/lib/PlexConnect/PlexConnect-master $ sudo ./PlexConnect_daemon.bash stop
Stopping PlexConnect...
plex@plex /usr/local/lib/PlexConnect/PlexConnect-master $ sudo ./PlexConnect_daemon.bash status
PlexConnect is not running
plex@plex /usr/local/lib/PlexConnect/PlexConnect-master $ sudo ./PlexConnect_daemon.bash
plex@plex /usr/local/lib/PlexConnect/PlexConnect-master $ sudo ./PlexConnect_daemon.bash status
PlexConnect is not running

The script:

Code: [Select]
#!/bin/bash
### BEGIN INIT INFO
# Provides:          plexconnect
# Required-Start:    plexmediaserver networking
# Required-Stop:     plexmediaserver networking
# Default-Start:     3 4 5
# Default-Stop:      0 1 6
# Short-Description: This is the Plex Connect daemon
# Description:       This script starts the Plex Connect
#                    Python scripts in a detached screen.
### END INIT INFO

# Using the lsb functions to perform the operations.
. /lib/lsb/init-functions

# Process name ( For display )
NAME=PlexConnect

# Daemon name, where is the actual executable
DAEMON="/usr/bin/screen"
DAEMON_OPTS="-S PlexConnect -d -m /usr/local/lib/PlexConnect/PlexConnect-master/PlexConnect_daemon.bash"
DAEMON_USER="root"

# pid file for the daemon
PIDFILE=/var/run/PlexConnect.pid

# If the daemon is not there, then exit.
test -x "$DAEMON" || exit 5

case $1 in
 start)
  # Checked the PID file exists and check the actual status of process
  if [ -e $PIDFILE ]; then
   status_of_proc -p $PIDFILE "$DAEMON $DAEMON_OPTS" "$NAME process" && status="0" || status="$?"
   # If the status is SUCCESS then don't need to start again.
   if [ $? = "0" ]; then
    log_success_msg "Starting the process $NAME"
    exit # Exit
   fi
  fi
  # Start the daemon.
  # Start the daemon with the help of start-stop-daemon
  # Log the message appropriately
  if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -p $PIDFILE -- ${DAEMON_OPTS}; then
   while read line ; do [[ $line =~ ([0-9]*).PlexConnect ]] && echo ${BASH_REMATCH[1]} ; done < <(screen -ls) > $PIDFILE
   log_success_msg "Starting the process $NAME"
  else
   log_failure_msg "Starting the process $NAME"
  fi
  ;;
 stop)

  # Stop the daemon.
  if [ -e $PIDFILE ]; then
   status_of_proc -p $PIDFILE "$DAEMON DAEMON_OPTS" "Stoppping the $NAME process" && status="0" || status="$?"
   if [ "$?" = 0 ]; then
    start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
    /bin/rm -rf $PIDFILE
    log_success_msg ""Stopping the $NAME process""
   fi
  else
   log_failure_msg "$NAME process is not running"
  fi
  ;;
 restart)
  # Restart the daemon.
  $0 stop && sleep 2 && $0 start
  ;;
 status)
  # Check the status of the process.
  if [ -e $PIDFILE ]; then
   status_of_proc -p $PIDFILE "$DAEMON $DAEMON_OPTS" "$NAME process" && exit 0 || exit $?
   log_success_msg "$NAME process is running"
  else
   log_failure_msg "$NAME process is not running"
  fi
  ;;
 reload)
  $0 restart
  ;;
 *)
  # For invalid arguments, print the usage message.
  echo "Usage: $0 {start|stop|restart|reload|status}"
  exit 2
  ;;
esac


Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 22015
  • Karma: 2468
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R and 9
Re: startup daemon
« Reply #13 on: July 22, 2014, 05:21:22 pm »
What's the output from:
Code: [Select]
dpkg -l | grep screen
?
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline kiwi_guy

  • Jr. Member
  • **
  • Posts: 29
  • Karma: 0
  • New Forum User
    • View Profile
  • Peppermint version(s): 3.8.0-35-generic
Re: startup daemon
« Reply #14 on: July 22, 2014, 05:49:50 pm »
Code: [Select]
plex@plex ~ $ dpkg -l | grep screen
ii  libts-0.0-0:i386                     1.0-11                                   i386         touch screen library
ii  mtr-tiny                             0.82-3ubuntu1                            i386         Full screen ncurses traceroute tool
ii  scrot                                0.8-13                                   i386         command line screen capture utility
ii  tsconf                               1.0-11                                   all          touch screen library common files
ii  xscreensaver                         5.15-2ubuntu1                            i386         Automatic screensaver for X
ii  xscreensaver-data                    5.15-2ubuntu1                            i386         data files to be shared among screensaver frontends