Com base na resposta do uSlackr , modifiquei o script mount_shares_locally
(abaixo)
- Eu criei este arquivo como
/etc/init.d/mount_shares_locally
- Em seguida,
chmod 755 /etc/init.d/mount_shares_locally
para torná-lo executável - criei um diretório
sudo mkdir /var/lock/subsys/
- Eu adicionei
noauto
a cada uma das minhas opções de compartilhamentos cifs, para evitar que elas sejam montadas automaticamente durante ummountall
- Garantiu que
sudo service mount_shares_locally restart
não forneceu erros - Por fim, foi adicionado aos níveis de execução de inicialização / desligamento com
sudo update-rc.d mount_shares_locally defaults
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: mount_shares_locally
# Required-Start: $network $local_fs $remote_fs smb mysqld
# Required-Stop: $network $local_fs $remote_fs smb
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mount Samba shares locally
### END INIT INFO
if [ -f /etc/rc.d/init.d/functions ]; then # "/lib/lsb/init-functions" on Ubuntu
. /etc/rc.d/init.d/functions
fi
start () {
echo -n "Mounting Samba shares locally:\n"
cat /etc/fstab | grep 'cifs.*\(password\|credentials\)' | while read -r remoteServer localMount type options;
do
echo Mounting $remoteServer to $localMount
mount $localMount
done
touch /var/lock/subsys/mount_shares_locally
echo
return 0
}
stop () {
echo -n "Unmounting locally mounted Samba shares:\n"
cat /etc/fstab | grep 'cifs.*\(password\|credentials\)' | while read -r remoteServer localMount type options;
do
echo Unmounting $localMount
umount $localMount
done
rm -f /var/lock/subsys/mount_shares_locally
echo
return 0
}
restart () {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $?
Eu também tive que adicionar outro script ao modelo upstart, para que mount_shares_locally seja chamado no momento certo durante a inicialização (depois que a rede estiver ativa):
/etc/init/mount_shares_locally.conf
# mount_shares_locally - Mount any cifs shares in /etc/fstab when network comes online
#
description "Mount CIFS shares"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on (runlevel [!12345] or net-device-down IFACE=eth0)
respawn
console none
pre-start script
mkdir -p -m0755 /var/run/mount_shares_locally
exec /etc/init.d/mount_shares_locally start
end script
post-stop script
mkdir -p -m0755 /var/run/mount_shares_locally
exec /etc/init.d/mount_shares_locally stop
end script