#!/bin/bash
#该脚本适用于Samba v4.1
#Basic Server Settings 基础设置
#Server Description: "test"
#Workgroup Name: "caiwu"
#Server NetBIOS Name: "canway.net"
#Allow Guest Users,Username for Guest: "tom"
#Shared Directories 共享文件
#Share Name: "Share 1"
#File Path: "/shares"
#Description: "share files"
#Volume Label: "/dev/sda"
#permissions: Read Only;Visible;Permit Guest Access
#Shared Printers 共享打印机
#Printers to share: "All"
#Description: "All Printers"
#permissions: Visible;Permit Guest Access
# Make sure samba is installed...
yum -y install samba
# Save any existing configuration file...
cp /etc/samba/smb.conf /etc/samba/smb_original.conf
# Create the new configuration file...
cat <<EOF >/etc/samba/smb.conf
[global]
netbios name = canway.net
server string = test
workgroup = caiwu
security = user
encrypt passwords = yes
map to guest = bad user
guest account = tom
cups options = raw
[Share 1]
path = /shares
comment = share files
volume = /dev/sda
read only = yes
guest ok = yes
[printers]
print ok = yes
printing = cups
path = /var/spool/samba
comment = All Printers
guest ok = yes
EOF
# Make sure shared directories exist...
mkdir -p /shares
# Set permissions for shared directories...
chmod 770 /shares
# Set selinux context for shared directories
if `selinuxenabled`
then
semanage fcontext -a -t samba_share_t '/shares(/.*)?'
restorecon -FRvv /shares
fi
# Enable and start samba service...
systemctl enable smb
systemctl start smb
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有