LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-12-2011, 02:41 PM   #1
kamaradski1
LQ Newbie
 
Registered: Oct 2011
Location: Currently in Bulgaria
Distribution: Xubuntu, Turnkey-LAMP, Turnkey-CORE
Posts: 22

Rep: Reputation: Disabled
Setting flags Debian init.d scripts


Hi all,

I actually think my next question is best at home in this newbie section as i feel kinda stupid for not being able to figure this one out. :S

I compiled pure-ftpd from source and i'm using the standard init.d script that normally comes with the pre-compiled package for the same program.

However i am trying to start pure-ftpd with my custom flags, but i cannot figure where to put them in the start-up script. Below you can see that i have been trying to define the flags in a string that will then be passed into the start-up command for the daemon in stand-alone mode.

No matter however where in the script i place my string i get the following error:
Code:
/etc/init.d/pure-ftpd: 22: -0: not found
init.d script as it is now:
Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides:          pure-ftpd
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      slapd mysql postgresql-8.3 postgresql-8.4
# Should-Stop:       slapd mysql postgresql-8.3 postgresql-8.4
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO
#
# pure-ftpd	starts and stops the pure-ftpd ftp daemon

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=pure-ftpd
DESC="ftp server"
: ${SSDAEMONLOGOPTS:="--quiet"}
UPLOADDAEMON=/usr/sbin/pure-uploadscript
UDNAME=pure-uploadscript
UDDESC="ftp upload handler"
WRAPPER=/usr/sbin/pure-ftpd-wrapper
MYFLAGS= -0 -4 -A -b -B -c 20 -C 4 -D -E -H -j -k 95 -l mysql:/etc/pure-ftpd/conf/mysql.conf -L 10000:3  -O stats:/var/log/ftp-transfer.log -p 50000:50100 -P ftp.kamaradski.com -R -u1 -U177:077 -w -y 2:0 -Y 3 -Z

# load LSB init-functions to get status_of_proc helper
. /lib/lsb/init-functions

PIDFILE=/var/run/pure-ftpd/pure-ftpd.pid

# try to figure with suffix this script is called,
# $0 might be a symlink pointing to this script
if [ -h $0 ]; then
	ME=`/bin/readlink $0`
else 
	ME=$0
fi

SUFFIX=`basename $ME | sed -ne 's/^pure-ftpd-\(.*\)/\1/p'`
if [ "$SUFFIX" ] ; then
	DAEMON=/usr/sbin/pure-ftpd-$SUFFIX
else
	DAEMON=/usr/sbin/pure-ftpd
fi

export STANDALONE_OR_INETD=inetd
export VIRTUALCHROOT=
test -r /etc/default/pure-ftpd-common && . /etc/default/pure-ftpd-common

if [ "$VIRTUALCHROOT" = "true" ]; then
	if [ "$SUFFIX" ]; then
		SUFFIX="$SUFFIX-virtualchroot"
	else
		SUFFIX="virtualchroot"
	fi
fi

test -x $DAEMON || exit 0
test -x $WRAPPER || exit 0

set -e

if [ ! -e `dirname $PIDFILE` ];then
       mkdir `dirname $PIDFILE`
fi

start_uploadscript() {
	if [ "$UPLOADSCRIPT" -a "$STANDALONE_OR_INETD" != inetd ] && \
		egrep -i '^[ 	]*(yes|1|on)[ 	]*' /etc/pure-ftpd/conf/CallUploadScript > /dev/null 2>&1
	then
		UOPTS=""
		test "$UPLOADUID" && UOPTS="$UOPTS -u $UPLOADUID"
		test "$UPLOADGID" && UOPTS="$UOPTS -g $UPLOADGID"
		echo -n "$1 $UDDESC: "
		start-stop-daemon --start $SSDAEMONLOGOPTS --oknodo \
			--exec $UPLOADDAEMON -- -r "$UPLOADSCRIPT" -B $UOPTS
		echo "$UDNAME."
		
	fi
}

case "$1" in
  start)
	test "$STANDALONE_OR_INETD" = standalone || exit 0
	echo -n "Starting $DESC: "
	start-stop-daemon --start $SSDAEMONLOGOPTS --pidfile "$PIDFILE" \
		--exec $WRAPPER -- $SUFFIX $MYFLAGS
	start_uploadscript Starting
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop $SSDAEMONLOGOPTS --oknodo \
		--pidfile "$PIDFILE"
	start-stop-daemon --stop $SSDAEMONLOGOPTS --oknodo --exec $UPLOADDAEMON
	echo "$NAME."
	;;
  restart|force-reload)
	test "$STANDALONE_OR_INETD" = standalone || exit 0
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop $SSDAEMONLOGOPTS --oknodo \
		--pidfile "$PIDFILE"
	start-stop-daemon --stop $SSDAEMONLOGOPTS --oknodo --exec $UPLOADDAEMON
	sleep 1
	start-stop-daemon --start $SSDAEMONLOGOPTS --pidfile "$PIDFILE" \
		--exec $WRAPPER -- $SUFFIX $MYFLAGS
	start_uploadscript Restarting
	;;
  status)
	status_of_proc -p /var/run/pure-ftpd/pure-ftpd.pid $DAEMON $NAME && exit 0 || exit $?
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
	exit 1
	;;
esac

exit 0
Maybe i'm just doing something small wrong, or i might even be taking a complete wrong approach as this whole 'daemonizing' process in linux was always a bit complicated for me to grasp.

Any help will be greatly appriciated.

KR
kamaradski
 
Old 12-12-2011, 05:41 PM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,604

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
Hi,

you need to use double-quotes if you want to assign something to a variable that contains spaces. Try it this way:
Code:
MYFLAGS=" -0 -4 -A -b -B -c 20 -C 4 -D -E -H -j -k 95 -l mysql:/etc/pure-ftpd/conf/mysql.conf -L 10000:3  -O stats:/var/log/ftp-transfer.log -p 50000:50100 -P ftp.kamaradski.com -R -u1 -U177:077 -w -y 2:0 -Y 3 -Z"
 
1 members found this post helpful.
Old 12-26-2011, 06:58 AM   #3
kamaradski1
LQ Newbie
 
Registered: Oct 2011
Location: Currently in Bulgaria
Distribution: Xubuntu, Turnkey-LAMP, Turnkey-CORE
Posts: 22

Original Poster
Rep: Reputation: Disabled
Thanks crts for the reply to that one i actually feel like a real noob now hahahaha Your answer made the script parse the flags correctly.

However the situation changed a little, as actually there where other issues with my Debian installation, that made me change to xubuntu on the ftp-machine.

So after re-installing and recompiling pure-ftpd on this machine i see that already a huge list of flags being passed to the init.d script. I'm still using the original unaltered init script as per my first post.

- Where do these flags come from (as they are not inside the script) ?
- and what is the easiest way to change them to my liking ?

KR
kamaradski
 
Old 12-26-2011, 02:36 PM   #4
kamaradski1
LQ Newbie
 
Registered: Oct 2011
Location: Currently in Bulgaria
Distribution: Xubuntu, Turnkey-LAMP, Turnkey-CORE
Posts: 22

Original Poster
Rep: Reputation: Disabled
I figured it out

the script is calling a wrapper, and the wrapper is parsing the installed config, and the present config files in /etc/pure-ftpd/conf, then passes it on to the start-script.

To overwrite or influence this you can do one of a combination of the following:

- create the appropriate config files.
- add flags to the start-up script
- change the wrapper script

issue solved, Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to monitor init scripts in /etc/init.d/ in rhel 5 me_spearhead Red Hat 2 02-09-2011 10:41 PM
Diffrence /etc/init.d and /etc/init.d/rc?.d scripts veeruhs Linux - Server 3 07-29-2010 04:42 AM
[SOLVED] init scripts, variables in INIT INFO section catkin Linux - General 1 08-18-2009 02:02 PM
Problem installing debian etch /scripts/init-premount guillermo Linux - General 2 01-19-2008 11:00 AM
passing bootable flags to init at boot ? Infernal211283 Linux - Newbie 3 12-18-2005 01:44 PM


All times are GMT -5. The time now is 12:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration