Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

trying to autostart 2 instances of a daemon on boot

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
geekness
Posts: 22
Joined: 2013-11-25 06:51

trying to autostart 2 instances of a daemon on boot

#1 Post by geekness »

Im trying to autostart 2 instances of a daemon on boot. The daemon is transmission-daemon.
This is the post I followed to get the 2 separate instances working. http://ubuntuforums.org/showthread.php? ... st11612949
I can get both to start, but only one ("transmission-daemon"), will autostart on boot.

Im running Wheezy on an ARM box (Iomega Iconnect), accessing through SSH, Putty on windows7

This is the command I use to enable the autostart

Code: Select all

sudo update-rc.d transmission-daemon2 defaults
then this is the error

Code: Select all

root@iconnect:~# sudo update-rc.d transmission-daemon2 defaults
update-rc.d: using dependency based boot sequencing
insserv: script transmission-daemon2: service transmission-daemon already provided!
insserv: exiting now!
update-rc.d: error: insserv rejected the script header
root@iconnect:~#
This is whats inside /etc/init.d/transmission-daemon2

Code: Select all

nano /etc/init.d/transmission-daemon2

Code: Select all

GNU nano 2.2.6      File: /etc/init.d/transmission-daemon2          Modified

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          transmission-daemon
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start or stop the transmission-daemon.
### END INIT INFO

NAME=transmission-daemon2
DAEMON=/usr/bin/$NAME
USER=debian-transmission
STOP_TIMEOUT=30

export PATH="${PATH:+$PATH:}/sbin"

[ -x $DAEMON ] || exit 0

[ -e /etc/default/$NAME ] && . /etc/default/$NAME

. /lib/lsb/init-functions

start_daemon () {
    if [ $ENABLE_DAEMON != 1 ]; then
        log_progress_msg "(disabled)"
                log_end_msg 255 || true
    else
        start-stop-daemon --start \
        --chuid $USER \
                $START_STOP_OPTIONS \
        --exec $DAEMON -- $OPTIONS || log_end_msg $?
                log_end_msg 0
    fi
}

case "$1" in
    start)
        log_daemon_msg "Starting bittorrent daemon" "$NAME"
        start_daemon
        ;;
    stop)
        log_daemon_msg "Stopping bittorrent daemon" "$NAME"
        start-stop-daemon --stop --quiet \
            --exec $DAEMON --retry $STOP_TIMEOUT \
            --oknodo || log_end_msg $?
        log_end_msg 0
        ;;
    reload)
        log_daemon_msg "Reloading bittorrent daemon" "$NAME"
        start-stop-daemon --stop --quiet \
            --exec $DAEMON \
            --oknodo --signal 1 || log_end_msg $?
        log_end_msg 0
This is whats inside /etc/init.d/transmission-daemon

Code: Select all

nano /etc/init.d/transmission-daemon

Code: Select all

  GNU nano 2.2.6       File: /etc/init.d/transmission-daemon

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          transmission-daemon
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start or stop the transmission-daemon.
### END INIT INFO

NAME=transmission-daemon
DAEMON=/usr/bin/$NAME
USER=debian-transmission
STOP_TIMEOUT=30

export PATH="${PATH:+$PATH:}/sbin"

[ -x $DAEMON ] || exit 0

[ -e /etc/default/$NAME ] && . /etc/default/$NAME

. /lib/lsb/init-functions

start_daemon () {
    if [ $ENABLE_DAEMON != 1 ]; then
        log_progress_msg "(disabled)"
                log_end_msg 255 || true
    else
        start-stop-daemon --start \
        --chuid $USER \
                $START_STOP_OPTIONS \
        --exec $DAEMON -- $OPTIONS || log_end_msg $?
                log_end_msg 0
    fi
}

case "$1" in
    start)
        log_daemon_msg "Starting bittorrent daemon" "$NAME"
        start_daemon
        ;;
    stop)
        log_daemon_msg "Stopping bittorrent daemon" "$NAME"
        start-stop-daemon --stop --quiet \
            --exec $DAEMON --retry $STOP_TIMEOUT \
            --oknodo || log_end_msg $?
        log_end_msg 0
        ;;
    reload)
        log_daemon_msg "Reloading bittorrent daemon" "$NAME"
        start-stop-daemon --stop --quiet \
            --exec $DAEMON \
            --oknodo --signal 1 || log_end_msg $?
        log_end_msg 0
Any help is greatly appreciated

geekness
Posts: 22
Joined: 2013-11-25 06:51

Re: trying to autostart 2 instances of a daemon on boot

#2 Post by geekness »

Update:

Just doing some tests and I found that if I remove autostart for "transmission-daemon"

Code: Select all

update-rc.d -f  transmission-daemon remove
then add autostart for "transmission-daemon2"

Code: Select all

sudo update-rc.d transmission-daemon2 defaults
when I try to add autostart for "transmission-daemon", I get that same error

Code: Select all

reboot
and "transmission-daemon2" is what starts this time.

My question now is how does debian sort and read it's autostart scripts? it seems that even if the titles are similar, it rejects the script.
I tried renaming but still get the same error
Do I need to rename every file and folder that has "transmission-daemon2" to something totally different? and then re-write every script/settings file to suit?

geekness
Posts: 22
Joined: 2013-11-25 06:51

Re: trying to autostart 2 instances of a daemon on boot

#3 Post by geekness »

I created a new script

Code: Select all

#! /bin/sh
# /etc/init.d/start-tr-mv
#

### BEGIN INIT INFO
# Provides:          transmission-daemon2
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       starts transmission-daemon2.
### END INIT INFO


# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting transmission-daemon2"
    # run application you want to start
    /usr/local/bin/transmission-daemon2
    ;;
  stop)
    echo "Stopping transmission-daemon2"
    killall transmission-daemon2
    ;;
  *)
    echo "Usage: /etc/init.d/transmission-daemon2 {start|stop}"
    exit 1
    ;;
esac

exit 0
Then I made it executable

Code: Select all

chmod 755 /etc/init.d/start-tr-mv
then I tried to add it to the start list, but got the same error

Code: Select all

root@iconnect:~# update-rc.d start-tr-mv defaults
update-rc.d: using dependency based boot sequencing
insserv: script transmission-daemon: service transmission-daemon already provided!
root@iconnect:~#

geekness
Posts: 22
Joined: 2013-11-25 06:51

Re: trying to autostart 2 instances of a daemon on boot

#4 Post by geekness »

Just found this on git
https://gist.github.com/ctavan/4482825
Is there a way to start both instances of transmission with a single script?

geekness
Posts: 22
Joined: 2013-11-25 06:51

Re: trying to autostart 2 instances of a daemon on boot

#5 Post by geekness »

OK, got it working, finally.
I needed to rename all files and folders totally so I renamed them like this

Code: Select all

mv /usr/bin/transmission-daemon2 /usr/bin/tv-daemon
mv /etc/init.d/transmission-daemon2 /etc/init.d/tv-daemon
mv /var/lib/transmission-daemon2 /var/lib/tv-daemon
mv /etc/transmission-daemon2 /etc/tv-daemon
mv /etc/default/transmission-daemon2 /etc/default/tv-daemon
Then I changed the script file as:

Code: Select all

NAME=transmission-daemon2
to
NAME=tv-daemon
but that still didn't work,
so I changed this:

Code: Select all

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          transmission-daemon
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start or stop the transmission-daemon.
### END INIT INFO
to this:

Code: Select all

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          tv-daemon
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start or stop the tv-daemon.
### END INIT INFO
and Voila, it's working. Im starting to think the

Code: Select all

# Provides:          transmission-daemon
may have been the culprit. maybe if I changed it to

Code: Select all

# Provides:          transmission-daemon2
it may have worked, but I think I may have tried that already with no luck. Anyway, it's working now, so im happy.
Now to install sickbeard and couch potato, then add my hard drives, then hopefully get it singing with Rasbmc.

If anybody can shed some light on any of the above, I'd love it.
Thanks.

User avatar
subhuman
Posts: 360
Joined: 2011-08-20 14:54

Re: trying to autostart 2 instances of a daemon on boot

#6 Post by subhuman »

Code: Select all

man start-stop-daemon
you're looking at the wrong places. start-stop-daemon creates a pidfile, meaning a file which contains the pid of the process it just started. whatever name you bestow upon your pudding, it still remains a pudding.

btw.: it would suffice if you posted only the context relevant snippets of your scriptlets.

SouzaRM
Posts: 1
Joined: 2018-04-22 15:15

Re: trying to autostart 2 instances of a daemon on boot

#7 Post by SouzaRM »

Thank you GeekNess...

You is very good!
geekness wrote:OK, got it working, finally.
I needed to rename all files and folders totally so I renamed them like this

Code: Select all

mv /usr/bin/transmission-daemon2 /usr/bin/tv-daemon
mv /etc/init.d/transmission-daemon2 /etc/init.d/tv-daemon
mv /var/lib/transmission-daemon2 /var/lib/tv-daemon
mv /etc/transmission-daemon2 /etc/tv-daemon
mv /etc/default/transmission-daemon2 /etc/default/tv-daemon
Then I changed the script file as:

Code: Select all

NAME=transmission-daemon2
to
NAME=tv-daemon
but that still didn't work,
so I changed this:

Code: Select all

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          transmission-daemon
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start or stop the transmission-daemon.
### END INIT INFO
to this:

Code: Select all

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          tv-daemon
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start or stop the tv-daemon.
### END INIT INFO
and Voila, it's working. Im starting to think the

Code: Select all

# Provides:          transmission-daemon
may have been the culprit. maybe if I changed it to

Code: Select all

# Provides:          transmission-daemon2
it may have worked, but I think I may have tried that already with no luck. Anyway, it's working now, so im happy.
Now to install sickbeard and couch potato, then add my hard drives, then hopefully get it singing with Rasbmc.

If anybody can shed some light on any of the above, I'd love it.
Thanks.

Post Reply