I'm just getting to grips with FreeBSD so I may well be missing something very obvious so apologies in advance for that!
So I'm trying to mount a Windows share at boot time. I've created an rc script in /usr/local/etc/rc.d/ as I gather this is the proper way to do it, but it fails.
My /usr/local/etc/rc.d/mounts script is this:
I have put details into /root/.nsmbrc as follows:
Running the command:
..at the command line as root works fine. When run in the script though I get the error:
It seems like it's a mount_smbfs(8) thing where it's not reading the /root/.nsmbrc file for some reason. Any ideas?
Thanks in advance.
Chris
So I'm trying to mount a Windows share at boot time. I've created an rc script in /usr/local/etc/rc.d/ as I gather this is the proper way to do it, but it fails.
My /usr/local/etc/rc.d/mounts script is this:
Code:
#!/bin/sh
# PROVIDE: mounts
# REQUIRE: NETWORKING
. /etc/rc.subr
name="mounts"
rcvar=`set_rcvar`
start_cmd="mount_all"
stop_cmd=":"
load_rc_config $name
mount_all()
{
if checkyesno ${rcvar}
then
NETWORK_OK=$(ping -c 3 hq | grep ' 0.0% packet loss')
if [ "x${NETWORK_OK}" == "x" ]
then
echo "$(date '+%a %d %T') $(basename $0) Could not ping hq, so hq_store not mounted." >> /var/log/messages
exit 1;
else
mount_smbfs -N -I hq //administrator@hq/store /mounts/hq_store/
fi
fi
}
run_rc_command "$1"
I have put details into /root/.nsmbrc as follows:
Code:
[HQ:USERNAME]
addr=hq.laputa
user=username
password=foobar
Running the command:
Code:
mount_smbfs -N -I hq //administrator@hq/store /mounts/hq_store/
..at the command line as root works fine. When run in the script though I get the error:
Code:
[root@misspiggy /usr/local/etc/rc.d]# service mounts start
/usr/local/etc/rc.d/mounts: DEBUG: checkyesno: mounts_enable is set to YES.
/usr/local/etc/rc.d/mounts: DEBUG: run_rc_command: doit: mount_all
/usr/local/etc/rc.d/mounts: DEBUG: checkyesno: mounts_enable is set to YES.
mount_smbfs: unable to open connection: syserr = Authentication error
It seems like it's a mount_smbfs(8) thing where it's not reading the /root/.nsmbrc file for some reason. Any ideas?
Thanks in advance.
Chris