init.d script for openSUSE

General support for problems installing or using Deluge
primus
New User
New User
Posts: 8
Joined: Fri Mar 19, 2010 1:07 am
Location: Norway

Re: init.d script for openSUSE

Post by primus »

Yeah, I think so.. I just used the scripts as they were posted on the wiki pages. What changes do I need to make?

Here's my deluged init script:

Code: Select all

#! /bin/sh
# Copyright (c) 1995-2000 SuSE GmbH Nuernberg, Germany.
#
# Author: José Ferrandis
#
# /etc/init.d/deluged
#
#   and symbolic its link
#
# /usr/sbin/deluged
#
### BEGIN INIT INFO
# Provides: deluged
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network

# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Daemonized version of deluge.
# Description:       Starts the deluge daemon with the user deluged

### END INIT INFO

DELUGED_BIN=/usr/bin/deluged

test -x $DELUGED_BIN || exit 5

DELUGED_USER="deluge"        # CHANGE THIS
test -n "$DELUGED_USER" || exit 6

DELUGED_ARGS="-P /.config/deluge/deluged.pid -c /.config/deluge/ -l /.config/deluge/deluged.log" # consult man deluged for more options

. /etc/rc.status

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status

# First reset status of this service
rc_reset

case "$1" in
    start)
        
	echo -n "Starting DELUGE daemon"
	## Start daemon with startproc(8). If this fails
	## the echo return value is set appropriate.

	startproc -f -u $DELUGED_USER $DELUGED_BIN $DELUGED_ARGS

	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down DELUGE daemon"
	## Stop daemon with killproc(8) and if this fails
	## set echo the echo return value.

	killproc -TERM $DELUGED_BIN

	# Remember status and be verbose
	rc_status -v
	;;
    try-restart)
        ## Stop the service and if this succeeds (i.e. the 
        ## service was running before), start it again.
        $0 status >/dev/null &&  $0 restart

        # Remember status and be quiet
        rc_status
        ;;
    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
        $0 stop
        $0 start

        # Remember status and be quiet
        rc_status
        ;;
    force-reload|reload)
	## Signal the daemon to reload its config. Most daemons
	## do this on signal 1 (SIGHUP).

	echo -n "Reload service DELUGED"

	killproc -HUP $DELUGED_BIN

        rc_status -v

        ;;
    status)
	echo -n "Checking for service DELUGED "
        ## Check status with checkproc(8), if process is running
        ## checkproc will return with exit status 0.

        # Status has a slightly different for the status command:
        # 0 - service running
        # 1 - service dead, but /var/run/  pid  file exists
        # 2 - service dead, but /var/lock/ lock file exists
        # 3 - service not running

	checkproc $DELUGED_BIN

	rc_status -v
	;;
    probe)
	## Optional: Probe for the necessity of a reload,
	## give out the argument which is required for a reload.

	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
	exit 1
	;;
esac
rc_exit
And here's my deluge-webd:

Code: Select all

#! /bin/sh
# Copyright (c) 1995-2000 SuSE GmbH Nuernberg, Germany.
#
# Author: José Ferrandis
#
# /etc/init.d/deluge-webd
#
#   and symbolic its link
#
# /usr/sbin/deluge-webd
#
### BEGIN INIT INFO
# Provides: deluge-webd
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network

# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Daemonized version of deluge-web.
# Description:       Starts the deluge-web daemon with the user specified in
#                    /home/jose/.config/deluge/web.conf

### END INIT INFO

DELUGED_WEB_BIN=/usr/bin/deluge-web
test -x $DELUGED_WEB_BIN || exit 5

DELUGED_WEB_USER="deluge"

. /etc/rc.status

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status

# First reset status of this service
rc_reset

case "$1" in
    start)
        
	echo -n "Starting DELUGE-WEB daemon"
	## Start daemon with startproc(8). If this fails
	## the echo return value is set appropriate.

	startproc -f -u $DELUGED_WEB_USER $DELUGED_WEB_BIN

	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down DELUGE-WEB daemon"
	## Stop daemon with killproc(8) and if this fails
	## set echo the echo return value.

	killproc -TERM $DELUGED_WEB_BIN

	# Remember status and be verbose
	rc_status -v
	;;
    try-restart)
        ## Stop the service and if this succeeds (i.e. the 
        ## service was running before), start it again.
        $0 status >/dev/null &&  $0 restart

        # Remember status and be quiet
        rc_status
        ;;
    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
        $0 stop
        $0 start

        # Remember status and be quiet
        rc_status
        ;;
    force-reload|reload)
	## Signal the daemon to reload its config. Most daemons
	## do this on signal 1 (SIGHUP).

	echo -n "Reload service DELUGED_WEB"

	killproc -HUP $DELUGED_WEB_BIN

        rc_status -v

        ;;
    status)
	echo -n "Checking for service DELUGED_WEB "
        ## Check status with checkproc(8), if process is running
        ## checkproc will return with exit status 0.

        # Status has a slightly different for the status command:
        # 0 - service running
        # 1 - service dead, but /var/run/  pid  file exists
        # 2 - service dead, but /var/lock/ lock file exists
        # 3 - service not running

	checkproc $DELUGED_WEB_BIN

	rc_status -v
	;;
    probe)
	## Optional: Probe for the necessity of a reload,
	## give out the argument which is required for a reload.

	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
	exit 1
	;;
esac
rc_exit
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: init.d script for openSUSE

Post by Cas »

Try these changes to deluge-webd script:

Find:

Code: Select all

DELUGED_WEB_BIN=/usr/bin/deluge-web
test -x $DELUGED_WEB_BIN || exit 5
Add After above lines:

Code: Select all

DELUGED_WEB_ARGS="-c /.config/deluge/ -l /.config/deluge/delugedweb.log"

Find:

Code: Select all

startproc -f -u $DELUGED_WEB_USER $DELUGED_WEB_BIN
Change line to:

Code: Select all

startproc -f -u $DELUGED_WEB_USER $DELUGED_WEB_BIN $DELUGED_WEB_ARGS
I cannot test as i do not have opensuse but im sure it will fix the issue.
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: init.d script for openSUSE

Post by johnnyg »

primus wrote:I'm running as root.
you shouldn't be running deluge as root. ever.

I've modified the init script. could you try again now?
primus
New User
New User
Posts: 8
Joined: Fri Mar 19, 2010 1:07 am
Location: Norway

Re: init.d script for openSUSE

Post by primus »

OK, I've updated the init scripts on my server to the newest versions that i found on the deluge wiki pages.

If I am logged in as a normal user (in this case, my username "ole") I'm getting permission denied while running deluge-webd

Code: Select all

Starting DELUGE-WEB daemonstartproc:  cannot set user id 1004: Operation not permitted
startproc: cannot stat /proc/16496/exe: Permission denied
When I am logged in as root i get the following error while trying to run deluge-webd

Code: Select all

 Traceback (most recent call last):
  File "/usr/bin/deluge-web", line 8, in <module>
    load_entry_point('deluge==1.2.2', 'console_scripts', 'deluge-web')()
  File "/usr/lib/python2.6/site-packages/deluge/ui/web/web.py", line 132, in start
    web.start()
  File "/usr/lib/python2.6/site-packages/deluge/ui/web/web.py", line 104, in start
    import server
  File "/usr/lib/python2.6/site-packages/deluge/ui/web/server.py", line 199, in <module>
    class Tracker(resource.Resource):
  File "/usr/lib/python2.6/site-packages/deluge/ui/web/server.py", line 200, in Tracker
    tracker_icons = TrackerIcons()
  File "/usr/lib/python2.6/site-packages/deluge/ui/tracker_icons.py", line 80, in __init__
    self.image_dir = os.path.join(deluge.configmanager.get_config_dir(), "icons")
  File "/usr/lib/python2.6/site-packages/deluge/configmanager.py", line 132, in get_config_dir
    return _configmanager.get_config_dir()
  File "/usr/lib/python2.6/site-packages/deluge/configmanager.py", line 93, in get_config_dir
    return self.config_directory
  File "/usr/lib/python2.6/site-packages/deluge/configmanager.py", line 51, in config_directory
    self.__config_directory = deluge.common.get_default_config_dir()
  File "/usr/lib/python2.6/site-packages/deluge/common.py", line 138, in get_default_config_dir
    return xdg.BaseDirectory.save_config_path("deluge")
  File "/usr/lib/python2.6/site-packages/xdg/BaseDirectory.py", line 59, in save_config_path
    os.makedirs(path, 0700)
  File "/usr/lib64/python2.6/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib64/python2.6/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/root/.config'
Sorry for being such of a newb, but I would really like to get this to work, and maybe I'll learn a couple of things on the way, too! :-)
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: init.d script for openSUSE

Post by Cas »

did you change the user "deluge" is both deluged and deluge-web scripts?
primus
New User
New User
Posts: 8
Joined: Fri Mar 19, 2010 1:07 am
Location: Norway

Re: init.d script for openSUSE

Post by primus »

Yes, in /etc/init.d/deluged: $DELUGED_USER="deluge" and in /etc/init.d/deluge-webd: $DELUGE_WEB_USER="deluge"

I tried changing both of them to my own username "ole". When I tried to run deluge-webd I got these errors:

Code: Select all

 Traceback (most recent call last):
  File "/usr/bin/deluge-web", line 8, in <module>
    load_entry_point('deluge==1.2.2', 'console_scripts', 'deluge-web')()
  File "/usr/lib/python2.6/site-packages/deluge/ui/web/web.py", line 132, in start
    web.start()
  File "/usr/lib/python2.6/site-packages/deluge/ui/web/web.py", line 119, in start
    self.server.start()
  File "/usr/lib/python2.6/site-packages/deluge/ui/web/server.py", line 517, in start
    self.start_normal()
  File "/usr/lib/python2.6/site-packages/deluge/ui/web/server.py", line 525, in start_normal
    self.socket = reactor.listenTCP(self.port, self.site)
  File "/usr/lib64/python2.6/site-packages/twisted/internet/posixbase.py", line 356, in listenTCP
    p.startListening()
  File "/usr/lib64/python2.6/site-packages/twisted/internet/tcp.py", line 858, in startListening
    raise CannotListenError, (self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn't listen on any:8112: [Errno 98] Address already in use.
primus
New User
New User
Posts: 8
Joined: Fri Mar 19, 2010 1:07 am
Location: Norway

Re: init.d script for openSUSE

Post by primus »

IT WORKS!

The user needs to be deluge in both scripts, and I changed the paths in DELUGED_WEB_ARGS to this:

DELUGED_WEB_ARGS="-c /home/deluge/ -l /home/deluge/delugedweb.log"

This way I'm sure the user deluge has write permissions to the log file. I don't know what the "-c /home/deluge/" argument does, but when it is set to the setting like above the script works!

So thank you so much Cas, Johnnyg and Jose for writing this script and helping me out! If there is anything I can do to help further I'd be happy to help!
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: init.d script for openSUSE

Post by Cas »

excellent

-c points to the config dir

really this init script needs reworked into a single file and take variables from a conf file, basically the same setup as ubuntu.
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: init.d script for openSUSE

Post by johnnyg »

Good to hear, could you update the init scripts (you'll need to register) to the working version you have?

-u should run the program as that user, meaning that ~ should no longer point to /root/.
But it appears that it still does :( (hence why you needed to use -c).
jferrandis
Member
Member
Posts: 10
Joined: Sat Mar 20, 2010 7:58 pm

Re: init.d script for openSUSE

Post by jferrandis »

Hi, primus. It's wonderful that the scrpts works for you. Now I have no much time but when I have, I'll take a sight to changes made by you more accurately. See you soon!!!
Post Reply