Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I installed the VSFTPd 3.0.2 on Ubuntu 12.04 following this commands:

$ wget https://security.appspot.com/downloads/vsftpd-3.0.2.tar.gz

$ tar xzvf vsftpd-3.0.2.tar.gz
$ cd vsftpd-3.0.2

$ make -j8

$ mkdir -p /usr/share/empty /var/ftp /usr/local/man/man5 /usr/local/man/man8

$ useradd -d /var/ftp ftp
$ chown root.root /var/ftp
$ chmod og-w /var/ftp

$ cp vsftpd.conf /etc

$ make install

So, to start, the documentation says to run this command:

/usr/local/sbin/vsftpd &

But, I'd like to create a /etc/init.d/vsftpd file to init and puts on daemon to start.

How should I proceed?

share|improve this question

2 Answers 2

up vote 3 down vote accepted
+50

Can you try this one:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          vfstpd
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: VSFTPD init script
# Description:       File created for starting VSFTPD manually
#                    installed on Ubuntu 12.04
### END INIT INFO

PATH=/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin
DESC="VSFTP Daemon"
NAME=vsftpd
DAEMON=/usr/local/sbin/$NAME
DAEMON_ARGS=" "
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

[ -x "$DAEMON" ] || exit 0
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
. /lib/init/vars.sh
. /lib/lsb/init-functions

RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
NORMAL=$(tput sgr0)

col=80 # change this to whatever column you want the output to start at

do_start()
{
    echo -n "* Starting vsftpd "
    $DAEMON & >/dev/null 2>&1
    if [ "$?" -eq "0" ]
    then
            printf '%*s[%s%s]\n' $col "$NORMAL" "OK" "$NORMAL"
            pidof $NAME > $PIDFILE
            return 0
    else
            printf '%*s[%s%s]\n' $col "$NORMAL" "${RED}fail" "$NORMAL"
            return 2
    fi
}

do_stop()
{
    echo -n "* Stopping vsftpd "
    kill -KILL `cat $PIDFILE` >/dev/null 2>&1
    if [ "$?" -eq "0" ]
    then
            rm -f $PIDFILE
            printf '%*s[%s%s]\n' $col "$NORMAL" "OK" "$NORMAL"
            return 0
    else
            printf '%*s[%s%s]\n' $col "$NORMAL" "${RED}fail" "$NORMAL"
            return 2
    fi
}

do_status()
{
    echo -n "* Service vsftpd is "
    pidof $NAME >/dev/null 2>&1
    if [ "$?" -eq "0" ]
    then
            echo "running"
            return 0
    else
            echo "not running"
            return 2
    fi
}

do_reload() {
    kill -HUP `cat $PIDFILE`
        return 0
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  status)
       do_status
       ;;
  restart|force-reload)
        log_daemon_msg "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                log_end_msg 1
                ;;
        esac
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
        exit 3
        ;;
esac

Save it as /etc/init.d/vsftpd and try to start the daemon using it. If it fails to start, please return with log entry.

EDIT: I had modified the script. Seems that vsftpd ain't made for start-stop-daemon. And this time I had time to test it out, so is working.

share|improve this answer
    
Brazilian greetings! Helped me a lot, but I still have a little problem when I do update-rc.d -f vsftpd defaults, see in the picture. img198.imageshack.us/img198/2976/ubootvsftpd.jpg –  Caio Tarifa Jan 14 '13 at 5:06
1  
@CaioTarifa I'd changed the script. May you please try again? –  fboaventura Jan 15 '13 at 19:12
    
Thank you! Perfectly works! :) –  Caio Tarifa Jan 16 '13 at 14:09
    
service vsftdp start return job failed to start. Please help –  Trinh Hoang Nhu Oct 14 '14 at 6:08

The lazy way (Ubuntu 12.04)

Do following

  1. apt-get install vsftpd
  2. apt-get remove vsftpd
  3. Modify path in /etc/init/vsftpd.conf, and additional options in /etc/vsftpd.
  4. Rename /etc/init/vsftpd.conf to /etc/init/vsftpd-local.conf to prevent future accidental over write by standard package.
share|improve this answer
    
Thanks, but didn't work. It's impossible to change the path in this startup file, in this case, works only for packages installed using aptitude/apt-get. –  Caio Tarifa Jan 9 '13 at 5:59
    
Ubuntu 12.04 changed vsftp to use upstart script. I updated answer. –  John Siu Jan 9 '13 at 11:38
    
This doesn't seem a good solution ... I think ideally the solution is a specific file for this version "manually installed". –  Caio Tarifa Jan 9 '13 at 20:19
    
Rename vsftpd.conf to vsftpd-local.conf. –  John Siu Jan 9 '13 at 20:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.