NFS init
Create a script to mount a directory
/etc/init.d/app-mount-nfs:
--------------------------
#! /bin/sh
#
# skeleton example file to build /etc/init.d/ scripts.
# This file should be used to construct scripts for /etc/init.d.
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Further changes by Javier Fernandez-Sanguino <jfs@debian.org>
#
# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
#
### BEGIN INIT INFO
# Provides: app shared directory
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Mount/umount app shared folder.
# Description: Mount/umount app shared folder.
### END INIT INFO
NAME="app-mount-nfs"
REMOTE="192.168.1.191"
REMOTE_DIR="/srv/share/app"
LOCAL_DIR="/home/dceresuela/code/app/app/static/data"
case "$1" in
start)
mount -t nfs -o rw,nosuid ${REMOTE}:${REMOTE_DIR} ${LOCAL_DIR}
;;
stop)
umount ${LOCAL_DIR}
;;
restart)
umount ${LOCAL_DIR}
mount -t nfs -o rw,nosuid ${REMOTE}:${REMOTE_DIR} ${LOCAL_DIR}
;;
*)
echo "Usage: $NAME {start|stop|restart}"
exit 1
;;
esac
exit 0
_$: chown root:root /etc/init.d/app-mount-nfs
_$: chmod 0755 /etc/init.d/app-mount-nfs
_$: update-rc.d app-mount-nfs defaults 99 00
_$: service app-mount-nfs start
To delete the script:
_$: update-rc.d -f app-mount-nfs remove
_$: rm /etc/init.d/app-mount-nfs