Thread: Samba?
View Single Post
Posts: 2,152 | Thanked: 1,490 times | Joined on Jan 2006 @ Czech Republic
#34
here is my mount script, it is probably too complex for this simple task first part is generic way of executing itself as root via sudo gainroot so you don't need to do it before executing it. In second part I tried to prompt for password without showing it on display but it doesn't work, it is shown, read command is too limited, there is no -s (silent) option in n770 version. But at least it is not remembered in shell history. Too bad it is still in /proc/mounts and /etc/mtab when share is mounted. Removing it would require mount.cifs helper executable which takes special care of the password.
Code:
#!/bin/sh
# use gainroot to become root and relaunch itself and remember original tty device
if [ `id -u` != 0 ] ; then
TTY=`tty`
#if not already root, call itself as root
sudo gainroot <<EOF
export TTY=$TTY
$0 $*
EOF
exit
fi
TTY=${TTY:-`tty`} #set also if called directly as root
# real script follows

grep -q cifs /proc/modules || insmod /root/cifs.ko
echo -n >$TTY "Password:"
read <$TTY >/dev/null 2>&1 pass
mount -t cifs //192.168.2.1/win_c$ /home/user/MyDocs/network/franta_c -o domain=FRANTA,user=Administrator,password=$pass,uid=29999,gid=29999
More details about cifs module is here http://linux-cifs.samba.org/