-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02.nas.sh
100 lines (82 loc) · 2.6 KB
/
02.nas.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
clear
echo -e "\e[1mCreando estructura de directorios\e[0m\n"
mkdir -p /mnt/NAS
cd /mnt/NAS
mkdir -p Publico Departamentos Usuarios Backup TimeCapsule Musica Soporte SquidCache
touch ./TimeCapsule/.com.apple.timemachine.supported
touch ./.workbox.compatible.drive
chmod -R 777 /mnt/NAS
echo -e "\e[4mListo.\n\e[0m"
echo -e "\e[1mActualizando paquetes\e[0m\n"
apt-get update
echo -e "\e[4mListo.\n\e[0m"
echo -e "\n\e[1mInstalando Samba\e[0m\n"
apt-get --assume-yes install samba samba-common-bin
echo -e "\e[4mListo.\n\e[0m"
echo -e "\n\e[1mSeteando config global Samba\e[0m\n"
cd /etc/samba
if ! grep -q Publico smb.conf; then
mv smb.conf smb.conf.orig
testparm -s smb.conf.orig > smb.conf
sed -i "s/\[global\]/\[global\]\\n guest account = ${SUDO_USER}\\n create mask = 0777\\n directory mask = 0777/g" smb.conf
echo -e "
[Publico]
comment = Guest access here
path = /mnt/NAS/Publico
browseable = Yes
read only = No
guest ok = Yes
[Usuarios]
comment = Carpetas de usuario
path = /mnt/NAS/Usuarios
browseable = Yes
read only = No
guest ok = Yes
[Departamentos]
comment = Carpetas de departamentos
path = /mnt/NAS/Departamentos
browseable = Yes
read only = No
guest ok = Yes
[Backup]
comment = Backups de informacion
path = /mnt/NAS/Backup
browseable = Yes
read only = Yes
guest ok = Yes
" >> smb.conf
echo -e "\e[4mListo.\n\e[0m"
else
echo -e "\e[4mNo se han hecho cambios (archivo ya modificado).\n\e[0m"
fi
echo -e "\n\e[1mInstalando Netatalk\e[0m\n"
apt-get --assume-yes install netatalk avahi-daemon avahi-utils
echo -e "\e[4mListo.\n\e[0m"
echo -e "\n\e[1mSeteando config global Netatalk\e[0m\n"
if ! grep -q Publico /etc/netatalk/afp.conf; then
cp /etc/netatalk/afp.conf /etc/netatalk/afp.conf.orig
sed -i "s/\[Global\]/\[Global\]\\nuam list = uams_guest.so, uams_dhx.so, uams_dhx2.so\\nguest account = ${SUDO_USER}\\nmimic model = RackMac/g" /etc/netatalk/afp.conf
echo -e "
[Publico]
path = /mnt/NAS/Publico
rwlist = ${SUDO_USER}
[Usuarios]
path = /mnt/NAS/Usuarios
rwlist = ${SUDO_USER}
[Departamentos]
path = /mnt/NAS/Departamentos
rwlist = ${SUDO_USER}
[Backup]
path = /mnt/NAS/Backup
[Time Capsule]
path = /mnt/NAS/TimeCapsule
rwlist = ${SUDO_USER}
time machine = yes" >> /etc/netatalk/afp.conf
echo -e "\e[4mListo.\n\e[0m"
else
echo -e "\e[4mNo se han hecho cambios (archivo ya modificado).\n\e[0m"
fi
echo -e "\n\e[1mReiniciando servicios...\e[0m\n"
service smbd restart && service netatalk restart
echo -e "\e[4mListo.\n\e[0m"