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

 

posted on 2021-11-09 09:23  弘道者  阅读(303)  评论(0编辑  收藏  举报