Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

...

Для использования этого способа должны быть установленв установлены пакеты smbclient и cifs-utils:

...

Информация

#!/bin/bash
# This file must be executable to work! chmod 755!
key="$1"

credfile="/etc/user-cifs"
user_password=$(cat $credfile | grep "$key" | awk -F ":" '{print $2}')
#echo "key=$1 credfile=$credfile user=$user_password" > /tmp/auto.smb.log
#opts="-fstype=cifs,file_mode=0644,dir_mode=0755,codepage=866,iocharset=utf8,user=$user_password"
opts="-fstype=cifs,file_mode=0644,dir_mode=0755,codepage=1251,iocharset=utf8,user=$user_password"
for P in /bin /sbin /usr/bin /usr/sbin

do
if [ -x $P/smbclient ]
then
SMBCLIENT=$P/smbclient
break
fi
done

[ -x $SMBCLIENT ] || exit 1

$SMBCLIENT --user=$user_password -gL $key 2>/dev/null| awk -v key="$key" -v opts="$opts" -F'|' -- '
BEGIN { ORS=""; first=1 }
/Disk/ {
if (first)
print opts; first=0
dir = $2
loc = $2
# Enclose mount dir and location in quotes
# Double quote "$" in location as it is special
gsub(/\$$/, "\\$", loc);
print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
}
END { if (!first) print "\n"; else exit 1 }
'

Комментарии к файлу

  • < opts="-fstype=cifs,file_mode=0644,dir_mode=0755,codepage=866,iocharset=utf8,user=$user_password" > : строка для обеспечения просмотра русских букв на ресурсах windows
  • < $SMBCLIENT --user=$user_password -gL $key 2>/dev/null| awk -v key="$key" -v opts="$opts" -F'|' -- ' >  : строка <$SMBCLIENT ...> изменена для обеспечения возможности подключения к samba-ресурсам windows
  • < user_password=$(cat $credfile | grep "$key" | awk -F ":" '{print $2}') > : строка добавлена для получения из файла пароля доступа к ресурсу cifs

...