Hi
I thank you for posting this, it would be helpfull if it worked for me but it doesnt, maybe you can help?
In addition of what I post below the /media/whateverdirectory exists.
My nfsmount.sh this exists and is executable in /usr/local/bin
Code:
#!/bin/bash
# The hostname or IP-address of the fileserver:
FILESERVER="192.168.1.7"
# Check every X seconds (60 is a good default):
INTERVAL=60
# The shares that need to be mounted:
MOUNTS=( "/media/TV_SERIES" "/media/MOVIES" "/media/MUSIC" "/media/SOURCES" )
while true; do
ping -c 1 "$FILESERVER" &>/dev/null
if [ $? -eq 0 ]; then
# Fileserver is up.
logger "Fileserver is up."
for MOUNT in ${MOUNTS[@]}; do
mount | grep -E "^${FILESERVER}:${MOUNT} on .*$" &>/dev/null
if [ $? -ne 0 ]; then
# NFS mount not mounted, attempt mount
logger "NFS shares not mounted; attempting to mount ${MOUNT}:"
mount -t nfs ${FILESERVER}:${MOUNT} ${MOUNT} ${MOUNT} ${MOUNT}
fi
done
else
# Fileserver is down.
logger "Fileserver is down."
for MOUNT in ${MOUNTS[@]}; do
mount | grep -E "^${FILESERVER}:${MOUNT} on .*$" &>/dev/null
if [ $? -eq 0 ]; then
# NFS mount is still mounted; attempt umount
logger "Cannot reach ${FILESERVER}, unmounting NFS share ${MOUNT}."
umount -f ${MOUNT}
fi
done
fi
sleep $INTERVAL
done
My nfsmount.conf exists and is 644 owned by root:root in /etc/init
Code:
# nfsmount
# mount NFS shares on fileserver, if present
# Created by JeroenHoek - http://bit.ly/c4Pwv6
# Modded by X3, Team iQuik 2010
description "Mount NFS-shares"
start on (filesystem)
respawn
exec /usr/local/bin/nfsmount
My nfsmount upstart created it exists in /etc/init.d
Code:
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: nfsmount
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start nfsmount daemon at boot time
# Description: Enable nfsmount service provided by daemon.
### END INIT INFO
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
INITSCRIPT="$(nfsmount "$0")"
JOB="${INITSCRIPT%.sh}"
if [ "$JOB" = "upstart-job" ]; then
if [ -z "$1" ]; then
echo "Usage: upstart-job JOB COMMAND" 1>&2
exit 1
fi
JOB="$1"
INITSCRIPT="$1"
shift
else
if [ -z "$1" ]; then
echo "Usage: $0 COMMAND" 1>&2
exit 1
fi
fi
COMMAND="$1"
shift
if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
ECHO=echo
else
ECHO=:
fi
$ECHO "Rather than invoking init scripts through /etc/init.d, use the service(8)"
$ECHO "utility, e.g. service $INITSCRIPT $COMMAND"
case $COMMAND in
status)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
$COMMAND "$JOB"
;;
start|stop|restart)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
PID=$(status "$JOB" 2>/dev/null | awk '/[0-9]$/ { print $NF }')
if [ -z "$PID" ] && [ "$COMMAND" = "stop" ]; then
exit 0
elif [ -n "$PID" ] && [ "$COMMAND" = "start" ]; then
exit 0
elif [ -z "$PID" ] && [ "$COMMAND" = "restart" ]; then
start "$JOB"
exit 0
fi
$COMMAND "$JOB"
;;
reload|force-reload)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted to an"
$ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
reload "$JOB"
;;
*)
$ECHO
$ECHO "The script you are attempting to invoke has been converted to an Upstart" 1>&2
$ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2
exit 1
esac
this never works tried
Code:
root@iMedia:/usr/local/bin# nfsmount
No command 'nfsmount' found, did you mean:
Command 'ntfsmount' from package 'ntfsprogs' (main)
nfsmount: command not found
root@iMedia:/usr/local/bin#
Code:
root@iMedia:/usr/local/bin# ./nfsmount.sh
Usage: mount -V : print version
mount -h : print this help
mount : list mounted filesystems
mount -l : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
mount -a [-t|-O] ... : mount all stuff from /etc/fstab
mount device : mount device at the known place
mount directory : mount known device here
mount -t type dev dir : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
mount --bind olddir newdir
or move a subtree:
mount --move olddir newdir
One can change the type of mount containing the directory dir:
mount --make-shared dir
mount --make-slave dir
mount --make-private dir
mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
mount --make-rshared dir
mount --make-rslave dir
mount --make-rprivate dir
mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using -L label or by uuid, using -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say man 8 mount .
Usage: mount -V : print version
mount -h : print this help
mount : list mounted filesystems
mount -l : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
mount -a [-t|-O] ... : mount all stuff from /etc/fstab
mount device : mount device at the known place
mount directory : mount known device here
mount -t type dev dir : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
mount --bind olddir newdir
or move a subtree:
mount --move olddir newdir
One can change the type of mount containing the directory dir:
mount --make-shared dir
mount --make-slave dir
mount --make-private dir
mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
mount --make-rshared dir
mount --make-rslave dir
mount --make-rprivate dir
mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using -L label or by uuid, using -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say man 8 mount .
Usage: mount -V : print version
mount -h : print this help
mount : list mounted filesystems
mount -l : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
mount -a [-t|-O] ... : mount all stuff from /etc/fstab
mount device : mount device at the known place
mount directory : mount known device here
mount -t type dev dir : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
mount --bind olddir newdir
or move a subtree:
mount --move olddir newdir
One can change the type of mount containing the directory dir:
mount --make-shared dir
mount --make-slave dir
mount --make-private dir
mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
mount --make-rshared dir
mount --make-rslave dir
mount --make-rprivate dir
mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using -L label or by uuid, using -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say man 8 mount .
Usage: mount -V : print version
mount -h : print this help
mount : list mounted filesystems
mount -l : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
mount -a [-t|-O] ... : mount all stuff from /etc/fstab
mount device : mount device at the known place
mount directory : mount known device here
mount -t type dev dir : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
mount --bind olddir newdir
or move a subtree:
mount --move olddir newdir
One can change the type of mount containing the directory dir:
mount --make-shared dir
mount --make-slave dir
mount --make-private dir
mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
mount --make-rshared dir
mount --make-rslave dir
mount --make-rprivate dir
mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using -L label or by uuid, using -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say man 8 mount .
Code:
root@iMedia:/usr/local/bin# nfsmount start
No command 'nfsmount' found, did you mean:
Command 'ntfsmount' from package 'ntfsprogs' (main)
nfsmount: command not found
Code:
root@iMedia:/usr/local/bin# /etc/init.d/nfsmount start
/etc/init.d/nfsmount: 17: nfsmount: not found
I've ran out of ideas, what have I done wrong?
I cant see the mistake or error.