centos7一键安装samba服务器

一键安装脚本 比较方便 用户名 密码 跟目录的话 自行修改脚本前几行的变量

#!/bin/bash
user="code"
pass="123456"
dir="/root/web"

yum install -y samba samba-client
mkdir -p $dir
chmod 777 $dir
useradd -d $dir -s /sbin/nologin $user

rm -f /etc/samba/smb.conf
cat >/etc/samba/smb.conf<<EOF
[global]
        workgroup = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

[homes]
        comment = Home Directories
        valid users = %S, %D%w%S
        browseable = No
        read only = No
        inherit acls = Yes

[printers]
        comment = All Printers
        path = /var/tmp
        printable = Yes
        create mask = 0600
        browseable = No

[print$]
        comment = Printer Drivers
        path = /var/lib/samba/drivers
        write list = @printadmin root
        force group = @printadmin
        create mask = 0664
        directory mask = 0775

[$user]                                        
       comment = this is the info
       path= $dir
       writable = yes
       public = no
EOF

echo -e "$pass\n$pass\n"| pdbedit -a -u $user -t
chown -Rf $user:$user $dir
systemctl start smb
systemctl enable smb
systemctl restart smb
systemctl status smb

 

上一篇:CentOS6.9下Samba服务器的安装与配置


下一篇:Ambari2.7.3.0添加组件