The following is a Debian based Remote FTP Server Mount script that will connect to an FTP server at boot time and mount the fileshare to the filesystem at /mnt/ftpserver. This script depends on curlftpfs
and umount
and you may need to install them if they're not already installed. You can change the MOUNT path to any path on your server and please don't forget to replace the ftp details in the OPTIONS string.
Here's the script to use. Save it to disk, naming it something like ftp-mount.sh
.
#! /bin/sh
### BEGIN INIT INFO
# Provides: ftpserver
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start ftpserver daemon at boot time
# Description: Enable ftpserver service provided by daemon.
### END INIT INFO
# Author: Justin Hartman <[email protected]>
# URL: http://justinhartman.co.za
# From Debian skeleton
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/curlftpfs
OPTIONS="-o allow_other ftp://myusername:[email protected]"
MOUNT=/mnt/ftpserver
UMOUNT=/bin/umount
NAME=ftpserver
DESC="Remote FTP Server Mount"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
case "$1" in
start)
echo -n "Mounting the $DESC: $NAME"
$DAEMON $OPTIONS $MOUNT
echo "Server has been mounted at $MOUNT"
;;
stop)
echo -n "Stopping $DESC: $NAME"
$UMOUNT $MOUNT
echo "Server has been unmounted"
;;
restart|force-reload)
echo -n "Re-mounting the $DESC: $NAME"
$UMOUNT $MOUNT
sleep 2
$DAEMON $OPTIONS $MOUNT
echo "The server has been re-mounted at $MOUNT"
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0