\\192.168.1.101\shareにtest1ユーザ、パスワードtest1でアクセスできます。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/ubuntu-16.04"
config.vm.hostname = "ub1604samba"
config.vm.provider :virtualbox do |vbox|
vbox.name = "ub1604samba"
vbox.cpus = 2
vbox.memory = 1024
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
config.vm.network "private_network", ip: "192.168.55.101", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.101", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
# update packages
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
# create a user
useradd test1
echo "test1:test1" | chpasswd
# create a shared directory
mkdir /opt/share
chown test1:test1 /opt/share
apt-get -y install samba
echo -e "test1\\ntest1" | pdbedit -a -t -u test1
mv /etc/samba/smb.conf /etc/samba/smb.conf.org
cat << EOF > /etc/samba/smb.conf
[global]
dos charset = CP932
unix charset = UTF-8
display charset = UTF-8
workgroup = Workgroup
netbios name = ub1604samba
server string = ub1604samba
encrypt passwords = true
passdb backend = tdbsam
log level=2
log file=/var/log/samba/access.log
max log size=500
[share]
path = /opt/share
read only=no
browsable=yes
guest ok = yes
force user = test1
EOF
systemctl enable smbd
systemctl start smbd
systemctl enable nmbd
systemctl start nmbd
echo 'access to \\\\192.168.1.101\\share'
SHELL
end
0 件のコメント:
コメントを投稿