16

I'm trying to figure out how to enable logging in Transmission.

I know I can run the daemon in the foreground:

transmission-daemon -f --logfile /your/path/to/transmission.log

But this is not what I want. I want to enable this option (logfile) in the service instance.

I've discovered that running sudo service transmission-daemon executes the file located in /etc/init.d/transmission-daemon. This file (as shown below) doesn't really make me any wiser.

So far, I understand the following:

--exec $DAEMON -- $OPTIONS executes the effective daemon. This file (as seen in the variable on top of the script) is located in /usr/bin/$NAME. $NAME is transmission-daemon. This is an executable located in there.

So I think you can pass it some options (e.g., --logfile). I added an instantiation of the OPTIONS variable but this doesn't seem to write anything.

I tried the OPTIONS=" --logfile /smb/torrents/transmission.log" line so that it might append them to the execution but it throws an error.

Another thing I tried was using the option without any quotes.

OPTIONS= -e /smb/torrents/transmission.log

This throws the same error:

:~$ sudo service transmission-daemon restart
/etc/init.d/transmission-daemon: 15: /etc/init.d/transmission-daemon: -e /smb/torrents/transmission.log: not found

Doing the above without - doesn't show me any errors, but doesn't write to the log file either.

Adding the --logfile option after the execution --exec $DAEMON --logfile /path/file -- $OPTIONS yields another error as well:

* Restarting bittorrent daemon transmission-daemon
start-stop-daemon: unrecognized option '--logfile'

The logfile has sufficient permissions, though:

-rwxrwxrwx  1 debian-transmission debian-transmission    0 Dec 30 11:14 transmission.log*

My question is, how to do this exactly?

#!/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
OPTIONS=" --logfile /smb/torrents/transmission.log"

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, see /etc/default/${NAME})"
    else    
        start-stop-daemon --start \
        --chuid $USER \
        $START_STOP_OPTIONS \
        --exec $DAEMON -- $OPTIONS
    fi
}

case "$1" in
    start)
        log_daemon_msg "Starting bittorrent daemon" "$NAME"
        start_daemon
        log_end_msg 0
        ;;
    stop)
        log_daemon_msg "Stopping bittorrent daemon" "$NAME"
        start-stop-daemon --stop --quiet \
            --exec $DAEMON --retry $STOP_TIMEOUT \
            --oknodo
        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 0
        ;;
    restart|force-reload)
        log_daemon_msg "Restarting bittorrent daemon" "$NAME"
        start-stop-daemon --stop --quiet \
            --exec $DAEMON --retry $STOP_TIMEOUT \
            --oknodo
        start_daemon
        log_end_msg 0
        ;;
    status)
        status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
        ;;
    *)
        echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart|status}"
        exit 2
        ;;
esac

exit 0

1 Answer 1

19

I fixed it in the meanwhile. There is a file in /etc/default/ named transmission-daemon as well (see below). This file has an instantiation for the OPTIONS parameter. I just added --logfile /path/to/logfile and it worked fine!

# defaults for transmission-daemon
# sourced by /etc/init.d/transmission-daemon

# Change to 0 to disable daemon
ENABLE_DAEMON=1

# This directory stores some runtime information, like torrent files
# and links to the config file, which itself can be found in
# /etc/transmission-daemon/settings.json
CONFIG_DIR="/var/lib/transmission-daemon/info"

# Default options for daemon, see transmission-daemon(1) for more options
OPTIONS="--config-dir $CONFIG_DIR --logfile /path/transmission.log"

# (optional) extra options to start-stop-daemon
#START_STOP_OPTIONS="--iosched idle --nicelevel 10"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .