I've got raspbian installed and need to mount a cifs path after boot is completed. In fstab
I got an entry for this with the noauto
parameter. When using auto
, boot hangs.
So in raspbian, the file is located in /etc/rc.local
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
#mount media storage via cifs
if grep -qs '/media/Seagate' /proc/mounts; then
echo "Seagate already mounted."
else
echo "Mounting Seagate.."
sudo -n mount /media/Seagate
fi
exit 0
According to the man page the -n parameter will suppress a password prompt for the sudo
command. This is not the case, however. So I tried editing the sudoers
file.
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) NOPASSWD: ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
pi ALL=(ALL) NOPASSWD: ALL
Only the %sudo line is changed. I assume root to be in group sudo and since the %sudo line is after the root line, no password should be required. Note that root does not have a password anyways on raspbian, I can fill anything at the password prompt.
Any suggestions? Other approaches like crontab may also be suitable
EDIT 1 Further info: there is
#!/bin/sh -e
on top of the file; the '-e' parameter apparently makes it not halt on errors. The permissions are
drwxr-xr-x 2 root root 4096 Feb 23 12:09