前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >samba服务安装脚本

samba服务安装脚本

作者头像
Eric杂货铺
发布2020-09-24 10:55:17
7350
发布2020-09-24 10:55:17
举报
文章被收录于专栏:Eric杂货铺
代码语言:javascript
复制
#!/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
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档