Results 1 to 8 of 8

Thread: Help needed to daemonize CouchPotato

  1. #1

    Default Help needed to daemonize CouchPotato

    Hi all,

    I am trying to run CouchPotato as a daemon at startup on my openSuSE 12.2 box.

    I have put together this script based on what works for sabnzbd and sickbeard, put it in /etc/init.d/couchpotato, chmod 755 and calling it using "/etc/init.d/couchpotato start"

    Code:
    #!/bin/sh
    #
    ### BEGIN INIT INFO
    # Provides:             couchpotato
    # Required-Start:       $network
    # Default-Start:        3 5
    # Default-Stop:         0 1 2 6
    # Description:          Starts Couch Potato at system startup
    ### END INIT INFO
    #
    . /etc/rc.status
    rc_reset
    
    case "$1" in
    start)
      echo "Starting Couch Potato."
      /usr/bin/sudo -u user -H "/home/user/CouchPotato-ff2b275/CouchPotato.py"
      rc_status -v
    ;;
    stop)
      echo "Shutting down Couch Potato."
      /usr/bin/env wget -q --delete-after "http://localhost:5000/config/exit/"
      rc_status -v
    ;;
    *)
      echo "Usage: $0 {start|stop}"
      exit 1
    esac
    
    exit 0
    And this is the error I am getting when trying to launch it
    Code:
    downloader:~ # /etc/init.d/couchpotato start
    redirecting to systemctl
    Job failed. See system journal and 'systemctl status' for details.
    System journal has this to say:
    Code:
    Sep 29 11:18:12 downloader[2433]: Failed at step EXEC spawning /etc/init.d/couchpotato: Exec format error
    Sep 29 11:18:12 downloader systemd[1]: couchpotato.service: control process exited, code=exited status=203
    Sep 29 11:18:12 downloader systemd[1]: Unit couchpotato.service entered failed state.
    Any thoughts?
    running openSUSE 12.2 (Mantis) x86_64
    P4 3.2 Ghz | 2 GB RAM | 1000 GB HDD
    Serves as Usenet downloader (couchpotato, headphones, sickbeard and sabnzbd) and SMB Media server.

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,832
    Blog Entries
    15

    Default Re: Help needed to daemonize CouchPotato

    Quote Originally Posted by ShaolinSatellite
    Hi all,

    I am trying to run CouchPotato as a daemon at startup on my openSuSE
    12.2 box.

    I have put together this script based on what works for sabnzbd and
    sickbeard, put it in /etc/init.d/couchpotato, chmod 755 and calling it
    using "/etc/init.d/couchpotato start"


    Code:
    --------------------
    #!/bin/sh
    #
    ### BEGIN INIT INFO
    # Provides: couchpotato
    # Required-Start: $network
    # Default-Start: 3 5
    # Default-Stop: 0 1 2 6
    # Description: Starts Couch Potato at system startup
    ### END INIT INFO
    #
    . /etc/rc.status
    rc_reset

    case "$1" in
    start)
    echo "Starting Couch Potato."
    /usr/bin/sudo -u user -H
    "/home/user/CouchPotato-ff2b275/CouchPotato.py" rc_status -v
    ;;
    stop)
    echo "Shutting down Couch Potato."
    /usr/bin/env wget -q --delete-after
    "http://localhost:5000/config/exit/" rc_status -v
    ;;
    *)
    echo "Usage: $0 {start|stop}"
    exit 1
    esac

    exit 0
    --------------------


    And this is the error I am getting when trying to launch it

    Code:
    --------------------
    downloader:~ # /etc/init.d/couchpotato start
    redirecting to systemctl
    Job failed. See system journal and 'systemctl status' for details.
    --------------------


    System journal has this to say:

    Code:
    --------------------
    Sep 29 11:18:12 downloader[2433]: Failed at step EXEC
    spawning /etc/init.d/couchpotato: Exec format error Sep 29 11:18:12
    downloader systemd[1]: couchpotato.service: control process exited,
    code=exited status=203 Sep 29 11:18:12 downloader systemd[1]: Unit
    couchpotato.service entered failed state. --------------------


    Any thoughts?

    Hi
    Use systemd

    Use the file below (you need to be root), save in /lib/systemd/system/
    as couchpotato.service you need to change the 'user' to your username.

    Code:
    # /lib/systemd/system/couchpotato.service
    #
    
    [Unit]
    Description=Starts Couch Potato at system startup.
    
    [Service]
    Type=simple
    User=user
    ExecStart=/bin/sh -c "/home/user/CouchPotato-ff2b275/CouchPotato.py"
    ExecStop=/bin/sh -c "/usr/bin/wget -q --delete-after \"http://localhost:5000/config/exit/\""
    KillSignal=SIGHUP
    
    [Install]
    WantedBy=multi-user.target
    Now run;

    Code:
    systemctl --system daemon-reload
    systemctl enable couchpotato.service
    systemctl start couchpotato.service
    systemctl status couchpotato.service
    systemctl stop couchpotato.service
    systemctl status couchpotato.service
    If it all starts/stops, restart and your good to go.

    --
    Cheers Malcolm °¿° (Linux Counter #276890)
    openSUSE 12.2 (x86_64) Kernel 3.4.6-2.10-desktop
    up 4 days 2:15, 5 users, load average: 0.10, 0.09, 0.10
    CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU
    Last edited by malcolmlewis; 29-Sep-2012 at 08:59.

  3. #3

    Default Re: Help needed to daemonize CouchPotato

    Works perfectly, thanks a lot!

    Can I convert sabnzbd and sickbeard that I was launching using a script in /etc/init.d to systemd? Should I use the example above as a framework and replace paths accordingly?
    systemd seems to be more suited to daemonizing programs.
    running openSUSE 12.2 (Mantis) x86_64
    P4 3.2 Ghz | 2 GB RAM | 1000 GB HDD
    Serves as Usenet downloader (couchpotato, headphones, sickbeard and sabnzbd) and SMB Media server.

  4. #4
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,832
    Blog Entries
    15

    Default Re: Help needed to daemonize CouchPotato

    Quote Originally Posted by ShaolinSatellite
    Works perfectly, thanks a lot!

    Can I convert sabnzbd and sickbeard that I was launching using a
    script in /etc/init.d to systemd? Should I use the example above as a
    framework and replace paths accordingly?
    systemd seems to be more suited to daemonizing programs.

    Hi
    You should be able to use it as an example, there are many more
    options/ways with systemd. If they work, consider pushing them back to
    the developers to review/include in their source.


    --
    Cheers Malcolm °¿° (Linux Counter #276890)
    openSUSE 12.2 (x86_64) Kernel 3.4.6-2.10-desktop
    up 2:05, 3 users, load average: 0.03, 0.16, 0.20
    CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU


  5. #5

    Default Re: Help needed to daemonize CouchPotato

    Fair enough.
    Are there any advantages to use systemd over init.d scripts? Should one be preferred to the other?
    running openSUSE 12.2 (Mantis) x86_64
    P4 3.2 Ghz | 2 GB RAM | 1000 GB HDD
    Serves as Usenet downloader (couchpotato, headphones, sickbeard and sabnzbd) and SMB Media server.

  6. #6
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,832
    Blog Entries
    15

    Default Re: Help needed to daemonize CouchPotato

    Quote Originally Posted by ShaolinSatellite
    Fair enough.
    Are there any advantages to use systemd over init.d scripts? Should one
    be preferred to the other?

    Hi
    openSUSE is moving towards systemd rather than sysVinit there may be
    limited support for it in the next release, but current talk on the
    development mailing list is for it to be dropped for 12.3.

    I would say systemd is preferred

    --
    Cheers Malcolm °¿° (Linux Counter #276890)
    openSUSE 12.2 (x86_64) Kernel 3.4.6-2.10-desktop
    up 10:59, 3 users, load average: 0.01, 0.07, 0.06
    CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU


  7. #7

    Default Re: Help needed to daemonize CouchPotato

    Thanks for your help!
    running openSUSE 12.2 (Mantis) x86_64
    P4 3.2 Ghz | 2 GB RAM | 1000 GB HDD
    Serves as Usenet downloader (couchpotato, headphones, sickbeard and sabnzbd) and SMB Media server.

  8. #8
    Join Date
    Apr 2014
    Location
    Italy GMT+1
    Posts
    2

    Default Re: Help needed to daemonize CouchPotato

    Many many thanks from Italy as well!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •