0

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?

Castaglia
  • 3,239
  • 3
  • 19
  • 40
Caio Tarifa
  • 65
  • 1
  • 10

2 Answers2

3

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.

fboaventura
  • 1,125
  • 11
  • 16
  • 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. http://img198.imageshack.us/img198/2976/ubootvsftpd.jpg – Caio Tarifa Jan 14 '13 at 05:06
  • 1
    @CaioTarifa I'd changed the script. May you please try again? – fboaventura Jan 15 '13 at 19:12
  • service vsftdp start return job failed to start. Please help – James Oct 14 '14 at 06:08
0

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.
John Siu
  • 3,577
  • 2
  • 15
  • 23