Page 1 of 3

SOLVED: mount_shares_locally problem

Posted: Thu Aug 29, 2013 4:22 pm
by modem7
Hey guys, I tried running the mount_shares_locally script, but I get these errors......Am I doing something stupid?
[root@AlexServer ~]# /etc/init.d/mount_shares_locally start
Mounting Samba shares locally: ERROR 1054 (42S22) at line 1: Unknown column 'name' in 'field list'
mkdir: missing operand
Try `mkdir --help' for more information.
Retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
[ OK ]

My script is currently as follows:
#!/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

username="alex";

if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi

start () {
uid=`id -u $username`
gid=`id -g $username`

echo -n $"Mounting Samba shares locally: "
mkdir -p /mnt/samba/
cd /mnt/samba/
mysql -u root -phda -e "select name from shares" hda_production | grep -v "^name$" | xargs -d "\n" mkdir -p
sleep 10
ls -1 | while read d; do
/sbin/mount.cifs "//127.0.0.1/$d" "$d" -o credentials=/home/${username}/.smb_credentials,uid=${uid},gid=${gid},file_mode=0660,dir_mode=0770,nobrl,hard,_netdev,iocharset=utf8,noserverino,mfsymlinks
done
touch /var/lock/subsys/mount_shares_locally
success $"$base startup"
echo
return 0
}

stop () {
echo -n $"Unmounting locally mounted Samba shares: "
/bin/umount -l /mnt/samba/*
rm -f /var/lock/subsys/mount_shares_locally
success $"$base shutdown"
echo
return 0
}

restart () {
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
I suspect that the "mysql -u root -phda -e "select name from shares" hda_production | grep -v "^name$" | xargs -d "\n" mkdir -p" line is what the problem is.

Should I just C+P the script (and edit username obviously), that is located in https://wiki.amahi.org/index.php/Mount_Shares_Locally ?
Thank you!

Re: mount_shares_locally problem

Posted: Thu Aug 29, 2013 4:49 pm
by bigfoot65
What OS are you using this on?

Be careful using copy and paste with the wiki. Sometimes hidden characters are picked up and can cause issues. Would recommend you avoid that when possible.

Also do you have all the prerequisites installed?

Re: mount_shares_locally problem

Posted: Thu Aug 29, 2013 5:02 pm
by modem7
What OS are you using this on?

Be careful using copy and paste with the wiki. Sometimes hidden characters are picked up and can cause issues. Would recommend you avoid that when possible.

Also do you have all the prerequisites installed?
Fedora 14 currently, but I used the mount_shares_locally script that was already included within the OS rather than downloading the new one listed in the article.

I've also installed cifs-utils a while back. Also made sure that I didn't C+P directly from the article (at least the commands)

Re: mount_shares_locally problem

Posted: Thu Aug 29, 2013 5:04 pm
by bigfoot65
The one in the wiki is for Fedora 19 only as noted. You might want to try the one located on the Greyhole web site.
https://github.com/gboudreau/Greyhole/w ... resLocally

Since we do not support Fedora 14 any longer, it was removed from the Amahi wiki. Sorry for any inconvenience.

Re: mount_shares_locally problem

Posted: Thu Aug 29, 2013 5:13 pm
by modem7
The one in the wiki is for Fedora 19 only as noted. You might want to try the one located on the Greyhole web site.
https://github.com/gboudreau/Greyhole/w ... resLocally

Since we do not support Fedora 14 any longer, it was removed from the Amahi wiki. Sorry for any inconvenience.
Hmmmm.......even with that, I get:
[root@AlexServer init.d]# /etc/init.d/mount_shares_locally start
Mounting Samba shares locally: Retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Retrying with upper case share name
mount error(6): No such device or address
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Script being:
#!/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

username="alex"

if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi

start () {
uid=`id -u $username`
gid=`id -g $username`

echo -n $"Mounting Samba shares locally: "
mkdir -p /mnt/samba/
cd /mnt/samba/
testparm -s /etc/samba/smb.conf 2>/dev/null | grep "^\[" | grep -v "\[global\]" | grep -v "\[homes\]" | awk -F'[' '{print $2}' | awk -F']' '{print $1}' | xargs -d "\n" mkdir -p
sleep 5
ls -1 | while read d; do
/sbin/mount.cifs "//127.0.0.1/$d" "$d" -o credentials=/home/${username}/.smb_credentials,uid=${uid},gid=${gid},file_mode=0660,dir_mode=0770,nobrl,hard,_netdev,iocharset=utf8,noserverino,mfsymlinks
done
touch /var/lock/subsys/mount_shares_locally
success $"$base startup"
echo
return 0
}

stop () {
echo -n $"Unmounting locally mounted Samba shares: "
/bin/umount -l /mnt/samba/*
rm -f /var/lock/subsys/mount_shares_locally
success $"$base shutdown"
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 $?
And to double check myself, I ran ​yum install cifs-utils​:
Package cifs-utils-4.8.1-7.fc14.x86_64 already installed and latest version

Re: mount_shares_locally problem

Posted: Thu Aug 29, 2013 5:15 pm
by bigfoot65
Might want to double check the steps you took to install the script. Also watch permissions on the script.

Re: mount_shares_locally problem

Posted: Thu Aug 29, 2013 5:17 pm
by modem7
Ran chmod +x /etc/init.d/mount_shares_locally to double check the permissions

ls -l shows:
-rwxr-xr-x 1 root root 1420 Aug 30 01:11 mount_shares_locally
​nano /home/alex/.smb_credentials​:
username=alex
password=password
domain=HOME

Re: mount_shares_locally problem

Posted: Thu Aug 29, 2013 5:28 pm
by bigfoot65
Ensure the credentials file ownership are correct. I presume your shares are in /var/hda/files correct?

Re: mount_shares_locally problem

Posted: Thu Aug 29, 2013 5:31 pm
by modem7
-rwxr-xr-x 1 root root 46 Apr 10 2012 .smb_credentials

and yup, all in /var/hda/files

Re: mount_shares_locally problem

Posted: Thu Aug 29, 2013 5:35 pm
by bigfoot65
Not sure if it should be owned by root or your first admin user:users. Mine is not owned by root and works fine.