-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.sh
executable file
·60 lines (49 loc) · 1.26 KB
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
if [[ -z "${WORKGROUP}" ]]
then
export WORKGROUP="WORKGROUP"
fi
if [[ -z "${USERS}" ]]
then
echo '[-] Please inform the users in the USER variable'
echo '[-] Creating a default username, this is dangerous'
export USERS=admin
export admin=admin
fi
for username in $(echo $USERS | tr ',' '\n')
do
password=${!username}
(sleep 1;echo "$password"; sleep 1;echo "$password") | adduser $username
(sleep 1;echo "$password"; sleep 1;echo "$password") | smbpasswd -a -s -c /etc/samba/smb.conf $username
done
cat > "/etc/samba/smb.conf" <<EOF
[global]
workgroup = ${WORKGROUP}
netbios name = ${HOSTNAME}
server string = ${HOSTNAME}
security = user
create mask = 0664
directory mask = 0775
force create mode = 0664
force directory mode = 0775
load printers = no
printing = bsd
printcap name = /dev/null
guest account = nobody
max log size = 50
map to guest = bad user
dns proxy = yes
vfs objects = fruit streams_xattr
local master = yes
read raw = yes
socket options = TCP_NODELAY SO_KEEPALIVE SO_RCVBUF=131072 SO_SNDBUF=131072
aio read size = 16384
aio write size = 16384
case sensitive = no
getwd cache = yes
preserve case = yes
short preserve case = yes
${SHARES_CONF}
EOF
nmbd -D
exec ionice -c 3 smbd -FS --configfile=/etc/samba/smb.conf < /dev/null