Well, after reading myself, what I said is really true only for the stop case... Sorry for the mistake.
Anyway, it is better to write an SysVInit script according to usual standards (managing parameters start, stop, ...) like this one (not tested) :
Code:
#! /bin/bash
### BEGIN INIT INFO
# Provides: linkup
# Required-Start: $remote_fs $syslog $ssh $sshfs
# Required-Stop: $remote_fs $syslog $ssh $sshfs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: sshfs - Needed drives
# Description: Lan - Needed drives
### END INIT INFO
SCRIPTNAME=linkup
PATH=/sbin:/usr/sbin:/bin:/usr/bin
case "$1" in
start)
echo -n "Starting $SCRIPTNAME"
# Little-Tux
#you could need to give the absolute path to sshfs
sshfs amy@192.168.1.6:/ /media/Little-Tux/
# XMBC
#you could need to give the absolute path to sshfs
sshfs media@192.168.1.3:/ /media/XMBC/
# Alternative, if you need to execute it from another user, for example called toto :
# Little-Tux
#you could need to give the absolute path to sshfs
#/bin/su - toto -c "sshfs amy@192.168.1.6:/ /media/Little-Tux/"
# XMBC
#you could need to give the absolute path to sshfs
#/bin/su - toto -c "sshfs media@192.168.1.3:/ /media/XMBC/"
echo "$SCRIPTNAME started"
;;
stop)
echo -n "Stopping $SCRIPTNAME"
umount -a -t fuse.sshfs
echo "$SCRIPTNAME stopped"
;;
*)
echo "Usage: /etc/init.d/$SCRIPTNAME {start|stop}"
exit 1
esac
exit 0
BUT, what could still be a problem is :
- sshfs command may not be in the PATH during init (so change the PATH variable or give the full path)
- Do you have created a public key with no passphrase between the local root user (which should be the one executing the script during init) and the amy user of 192.168.1.6 ?
Otherwise, the script will wait for an interactive user input, which cannot be done at boot time
- Same question and remark, this time between the local root user and the media user of 192.168.1.3
Remarks :
- If the sshfs command is not intended to be executed by the root user, you will have to use something like su -c, as shown in the script
- What miss in this script is a mechanism to forbid to execute several times this script (ans so mounting several times the same filesystems)