[SOLVED] sabnzbd creating Downloads folder before external Drive can mount

Support for the Debian/Ubuntu package, created by JCFP.
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
Xeijin
Newbie
Newbie
Posts: 9
Joined: February 3rd, 2010, 8:31 am

[SOLVED] sabnzbd creating Downloads folder before external Drive can mount

Post by Xeijin »

Version: 0.5.3
OS: Ubuntu (Karmic - Minimal)
Install-type: Linux Repo
Skin (if applicable): Plush
Firewall Software: none
Are you using IPV6? no
Is the issue reproducible? yes

I'm trying to get sab to download to my External NTFS Hard Drive. The drive is set to mount to /media/Media Server, and I have configured the folders Tab in Sab to send downloads to /media/Media Server/Downloads

The problem is that when I reboot, sab creates this folder before my NTFS drive can actually mount, this means that my NTFS drive then gets mounted to "/media/Media Server_" instead of "/media/Media Server".

So my question is:

Can I prevent Sab trying to consistently create this directory?

if not...

Can I force Ubuntu to mount my NTFS drive *before* sab tries to create the directory?

I tried mounting my NTFS drive in /etc/fstab, but to be honest I don't know what I'm doing and either way it didn't seem to work...

Thanks in advance for your help.
Last edited by Xeijin on August 18th, 2010, 4:20 pm, edited 1 time in total.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: sabnzbd creating Downloads folder before external Drive can mount

Post by shypike »

Don't know how you start SABnzbd.
Through a script? If so, you'll need to add a sleep statement in the script.
60 seconds should do.
Xeijin
Newbie
Newbie
Posts: 9
Joined: February 3rd, 2010, 8:31 am

Re: sabnzbd creating Downloads folder before external Drive can mount

Post by Xeijin »

I believe SAB is starting through an init.d script, where do I go about adding the sleep statement to the script?

Edit: Also, would this cause a delay in boot? (I am using the PC as a media centre with XBMC installed, so ideally I'd like to keep boot times as low as possible).

Here is the script:

Code: Select all

#!/bin/sh
#
# Copyright (C) 2008-2010 by JCF Ploemen <[email protected]>
# released under GPL, version 2 or later

################################################
#                                              #
#  TO CONFIGURE EDIT /etc/default/sabnzbdplus  #
#                                              #
################################################

### BEGIN INIT INFO
# Provides:          sabnzbdplus
# Required-Start:    $local_fs $network $remote_fs
# Required-Stop:     $local_fs $network $remote_fs
# Should-Start:      NetworkManager
# Should-Stop:       NetworkManager
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: SABnzbd+ binary newsgrabber
### END INIT INFO

DAEMON=/usr/bin/sabnzbdplus
SETTINGS=/etc/default/sabnzbdplus

([ -x $DAEMON ] && [ -r $SETTINGS ]) || exit 0

DESC="SABnzbd+ binary newsgrabber"
DEFOPTS="--daemon"
PYTHONEXEC="^$(sed -n '1s/^#\!\([a-z0-9\.\/]\+\)\(.*\)/\1(\2)?/p' $DAEMON)"
PIDFILE=/var/run/sabnzbdplus.pid

# these are only accepted from the settings file
unset USER CONFIG HOST PORT EXTRAOPTS

. /lib/lsb/init-functions

check_retval() {
	if [ $? -eq 0 ]; then
		log_end_msg 0
		return 0
	else
		log_end_msg 1
		exit 1
	fi
}

is_running() {
	# returns 0 when running, 1 otherwise
	PID="$(pgrep -f -x -u $USER "$PYTHONEXEC $DAEMON $DEFOPTS.*")"
	RET=$?
	[ $RET -gt 1 ] && exit 1 || return $RET
}

load_settings() {
	. $SETTINGS

	[ -z "$USER" ] && {
		log_warning_msg "$DESC: not configured, aborting. See $SETTINGS";
		return 1; }

	OPTIONS="$DEFOPTS"
	[ -n "$CONFIG" ] && OPTIONS="$OPTIONS --config-file $CONFIG"
	[ -n "$HOST" ] && SERVER="$HOST" || SERVER=
	[ -n "$PORT" ] && SERVER="$SERVER:$PORT"
	[ -n "$SERVER" ] && OPTIONS="$OPTIONS --server $SERVER"
	[ -n "$EXTRAOPTS" ] && OPTIONS="$OPTIONS $EXTRAOPTS"
	return 0
}

case "$1" in
	start)
		load_settings || exit 0
		if ! is_running; then
			log_daemon_msg "Starting $DESC"
			start-stop-daemon --quiet --chuid $USER --start --exec $DAEMON -- $OPTIONS
			check_retval
			# create a pidfile; we don't use it but some monitoring app likes to have one
			[ -w $(dirname $PIDFILE) ] && \
				pgrep -f -x -n -u $USER "$PYTHONEXEC $DAEMON $OPTIONS" > $PIDFILE
		else
			log_success_msg "$DESC: already running (pid $PID)"
		fi
	;;
	stop)
		load_settings || exit 0
		if is_running; then
			TMPFILE=$(mktemp /tmp/sabnzbdplus.XXXXXXXXXX || exit 1)
			trap '[ -f $TMPFILE ] && rm -f $TMPFILE' EXIT
			echo "$PID" > $TMPFILE
			log_daemon_msg "Stopping $DESC"
			start-stop-daemon --stop --user $USER --pidfile $TMPFILE --retry 30
			check_retval
		else
			log_success_msg "$DESC: not running"
		fi
		[ -f $PIDFILE ] && rm -f $PIDFILE
	;;
	force-reload|restart)
		$0 stop || exit $?
		$0 start || exit $?
	;;
	status)
		load_settings || exit 4
		if is_running; then
			log_success_msg "$DESC: running (pid $PID)"
		else
			log_success_msg "$DESC: not running"
			[ -f $PIDFILE ] && exit 1 || exit 3
		fi
	;;
	*)
		log_failure_msg "Usage: $0 {start|stop|restart|force-reload|status}"
		exit 3
	;;
esac

exit 0
Edit: Nevermind, got it working by mounting through fstab. For anyone who happens to be in a similar situation this is what I did:

Mounting an External NTFS drive through fstab (Ubuntu Karmic)

1. Find the UUID of the drive you want mounted by doing:

Code: Select all

sudo blkid
2. Add the drive to fstab using your favourite editor. E.g.

Code: Select all

sudo nano /etc/fstab
3. Add the following line to the end of fstab inserting your UUID where specified, and the mount point for the drive

Code: Select all

UUID=<<UUID OF YOUR DRIVE>>  <<mount point - e.g. /media/Storage>>  ntfs-3g  auto,users,uid=1000,gid=100,dmask=027,fmask=137,utf8  0  0
4. Save and reboot.
Last edited by Xeijin on August 18th, 2010, 4:20 pm, edited 1 time in total.
monmon_4
Newbie
Newbie
Posts: 6
Joined: May 12th, 2010, 10:26 pm

Re: [SOLVED] sabnzbd creating Downloads folder before external Drive can mount

Post by monmon_4 »

Waiting for a solution to this for a while. Amazing, thank you.

There should be an option in sabnzbd to delay boot time or edit fstab like this for you. Just a thought since a lot of people use sabnzbd with XBMC Live based on Ubuntu.
pabloikba
Newbie
Newbie
Posts: 16
Joined: October 30th, 2009, 11:59 am

Re: [SOLVED] sabnzbd creating Downloads folder before external Drive can mount

Post by pabloikba »

Thanks for the soluition.
Post Reply