-
Notifications
You must be signed in to change notification settings - Fork 0
/
SRV_COS_03_SMB_COMP.sh
executable file
·137 lines (94 loc) · 3.95 KB
/
SRV_COS_03_SMB_COMP.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
echo
echo ##########################
echo # Creado por: gomgardav #
echo # [ David Gómez García ] #
echo ##########################
echo
log=./srv_cos_03_salida.sal
cd ~/samba || exit
source ./00_00_VAR.sh
Menu () {
SalidaMenu=$(whiptail --title "Script 03" \
--menu "Selecciona una Opción" 13 35 5 \
1 "Actualizar" \
2 "Generar History" \
3 "Ejecutar Script" \
4 "Reiniciar" \
0 "Salir" 3>&1 1>&2 2>&3)
EstadoSalidaMenu=$?
}
EstadoSalidaMenu=0
while [ "$EstadoSalidaMenu" = 0 ]; do
Menu
Exit=no
case "$SalidaMenu" in
1 ) yum update -y && ym upgrade -y;;
2 ) HISTFILE=~/.bash_history && set -o history && history > ./srv_cos_03-history_"$(date +%F_%H-%M-%S)".his && history -c && set +o history && HISTFILE="";;
3 )
rm /usr/local/samba/var/{lock,locks,cache}/{*.tdb,*.ldb}
rm /usr/local/samba/private/{*.tdb,*.ldb}
\mv /etc/krb5.conf /etc/krb5.conf.old
#rm -rf ./{samba-4*,samba-p*,samba-l*}
#wget https://download.samba.org/pub/samba/samba-pubkey.asc
#wget https://download.samba.org/pub/samba/samba-latest.tar.asc
#wget https://download.samba.org/pub/samba/samba-latest.tar.gz
#cd samba
#gpg --import samba-pubkey.asc
gunzip samba-4.14.12.tar.gz
#gpg --verify samba-latest.tar.asc
tar -xf samba-4.14.12.tar
cd samba-4.14.12 || ( return 1 && exit )
#./configure -j 3 --enable-fhs --libdir=/lib64 --prefix=/usr --sysconfdir=/etc --localstatedir=/var --sbindir=/sbin/ --bindir=/bin/ --mandir=/usr/share/man/ --with-systemd --with-quotas --enable-selftest --progress
./configure -j $Threads --mandir=/usr/share/man/ --with-systemd --with-quotas --enable-selftest --progress &
wait
make -j $Threads & wait
#make -j 3 test
make -j $Threads install & wait
cd ..
cat << EOF >> ~/.bashrc
export PATH=/usr/local/samba/bin/:/usr/local/samba/sbin/:$PATH
EOF
PATH=/usr/local/samba/bin/:/usr/local/samba/sbin/:$PATH
ln -s /usr/local/samba/lib/libnss_winbind.so.2 /lib64/
ln -s /lib64/libnss_winbind.so.2 /lib64/libnss_winbind.so
ldconfig
ln -s /usr/local/samba/lib/security/pam_winbind.so /lib64/security/
firewall-cmd --add-service={dns,ldap,ldaps,kerberos}
firewall-cmd --add-port={88/tcp,88/udp,389/tcp,389/udp,135/tcp,135/udp,53/tcp,53/udp,138/udp,138/tcp,137/tcp,137/udp,139/udp,139/tcp,445/tcp,445/udp,464/tcp,464/udp,636/tcp,3268/udp,3268/tcp,3269/tcp,3269/udp,49152/tcp}
cat << EOF > /etc/systemd/user/samba-ad-dc.service
[Unit]
Description=Samba Active Directory Domain Controller
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/samba/sbin/samba -D
PIDFile=/usr/local/samba/var/run/samba.pid
ExecReload=/bin/kill -HUP \$MAINPID
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable /etc/systemd/user/samba-ad-dc.service
systemctl daemon-reload
test -f /usr/local/samba/etc/smb.conf.org && cp /usr/local/samba/etc/smb.conf /usr/local/samba/etc/smb.conf.bak || mv /usr/local/samba/etc/smb.conf /usr/local/samba/etc/smb.conf.org
rm /usr/local/samba/private/krb5.conf
Enter="Enter"
while [ -n "$Enter" ]; do
echo
read -p "Pulsa Enter para Continuar..." Enter
done
HISTFILE=~/.bash_history && set -o history && history > ./srv_cos_03-history_"$(date +%F_%H-%M-%S)".his && history -c && set +o history && HISTFILE="";;
4 ) reboot; exit;;
0 ) Exit=yes; break;;
* ) echo "Error en el Script !!!";;
esac
done
clear
if [ "$Exit" = "yes" ] && [ "$EstadoSalidaMenu" = "0" ]; then
echo "Has Salido Correctamente !"
elif [ "$EstadoSalidaMenu" = "1" ]; then
echo "Has seleccionado Cancelar !"
else
echo "Ha habido un Error !!!"
fi