samba/beta-install.sh

raw link view readme
1 yum install policycoreutils-python -y
2
3 yum install firewalld -y
4 systemctl start firewalld
5 systemctl enable firewalld
6 firewall-cmd --permanent --add-service=samba
7 firewall-cmd --reload
8
9 yum install samba -y
10
11 systemctl enable smb nmb
12 systemctl start smb nmb
13
14 sed -E -i.original "s/;([ \t]*)netbios name =.*/ netbios name = beta/" /etc/samba/smb.conf | grep netbios
15 sed -E -i "s/;([ \t]*)interfaces =.*/ interfaces = 10.0.0.0\/8/" /etc/samba/smb.conf
16 sed -E -i "s/;([ \t]*)hosts allow =.*/ hosts allow = 10./" /etc/samba/smb.conf
17 sed -i "/^[ \t]*[#;]/d;/^$/d" /etc/samba/smb.conf
18
19 smbpasswd -a dbetz << EOF
20 hello
21 hello
22 EOF
23
24 groupadd librarian
25 useradd -s /sbin/nologin -G librarian jdoe
26 useradd -s /sbin/nologin -G librarian jsmith
27
28 smbpasswd -a jdoe << EOF
29 hello
30 hello
31 EOF
32
33 smbpasswd -a jsmith << EOF
34 hello
35 hello
36 EOF
37
38 setsebool -P samba_enable_home_dirs 1
39
40 mkdir /var/share
41
42 semanage fcontext -at samba_share_t "/var/share(/.*)?"
43 restorecon -R -v /var/share
44
45 chgrp librarian /var/share
46 chmod 2770 /var/share
47
48 cat >> /etc/samba/smb.conf << EOF
49 [librarian]
50 comment = librarian stuff
51 path = /var/share
52 valid users = @librarian
53 writable = yes
54 EOF
55
56 systemctl reload smb nmb
57