-
Notifications
You must be signed in to change notification settings - Fork 2
/
instalar.sh
executable file
·284 lines (251 loc) · 7.67 KB
/
instalar.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/bin/bash
___OS___=`uname -s`
OS_VERSION=`uname -r`
OS_COMP=`echo $OS_VERSION | cut -d '-' -f 2`
OS_VERSION=`echo $OS_VERSION | cut -d '-' -f 1`
MAJOR=`echo $OS_VERSION | cut -d '.' -f 1`
MINOR=`echo $OS_VERSION | cut -d '.' -f 2`
RELEASE=`echo $OS_VERSION | cut -d '.' -f 3`
BUILD=`echo $OS_VERSION | cut -d '.' -f 4`
#echo $___OS___
#echo $OS_VERSION
#echo $OS_COMP
#echo $MAJOR
#echo $MINOR
#echo $RELEASE
#echo $BUILD
FEDORA=`awk '/Fedora/ { print $0 }' /etc/issue`
UBUNTU=`awk '/buntu/ { print $0 }' /etc/issue`
DEBIAN=`awk '/ebian/ { print $0 }' /etc/issue`
MINT=`awk '/Mint/ { print $0 }' /etc/issue`
OPENSUSE=`awk '/openSUSE/ { print $0 }' /etc/issue`
SLACK=`awk '/elcome to/ { print $0 }' /etc/issue`
GENTOO=`awk '/Base System/ { print $0 }' /etc/gentoo-release > /dev/null 2>&1`
clear
echo
echo
echo "Aker Client - Script de instalacao"
echo "----------------------------------"
echo
echo "Copyright (c) 2012 Aker Security Solutions."
echo "Todos os direitos reservados."
ID=`id -u`
if [ $ID -ne 0 ]
then
echo
echo "ERRO: Este script so' pode ser executado pelo root."
echo
exit
fi
if [ "Linux" != ${___OS___} ]
then
echo
echo "ERRO: Este script pode ser executado apenas em plataformas GNU Linux."
echo
exit
fi
if [ ${MAJOR} -ne 2 ] && [ ${MAJOR} -ne 3 ] && [ ${MAJOR} -ne 4 ]
then
echo
echo "ERRO: As versoes do kernel suportadas são 2.6.x e 3.x.x ."
echo " Versao encontrada: ${OS_VERSION}"
echo
exit
fi
if [ ${MAJOR} -eq 2 ] && [ ${MINOR} -lt 6 ]
then
echo
echo "ERRO: Versoes de kernel inferior a 2.6 nao sao suportadas."
echo " Versao encontrada: ${OS_VERSION}"
echo
exit
fi
echo -n "Verificando dependencias para compilacao do modulo de kernel... "
RET=`gcc --version | grep Copyright`
if [ "${RET}" = "" ]
then
echo "ERRO."
echo "Compilador GCC nao encontrado. Impossivel prosseguir."
echo
if [ -n "${FEDORA}" ]
then
echo "No Fedora instale o seguintes pacote:"
echo "* gcc"
elif [ -n "${UBUNTU}" ] || [ -n "${DEBIAN}" ] || [ -n "${MINT}" ]
then
echo "No Ubuntu e derivados instale o seguinte pacote:"
echo "* build-essencial"
fi
echo
echo -n "Deseja realmente prosseguir? (S/N - N para cancelar) "
read -n 1 A
echo
exit
fi
RET=`make --version | grep Make`
if [ "${RET}" = "" ]
then
echo "ERRO."
echo "Ferramenta 'Make' nao encontrada. Impossivel prosseguir."
echo
exit
fi
if [ -n "${FEDORA}" ]
then
RET=`rpm -qa | grep kernel | grep devel`
if [ -z "${RET}" ]
then
echo "ERRO."
echo "Pacote kernel-devel nao esta' instalado no sistema. Impossivel prosseguir."
echo
exit
fi
elif [ -n "${UBUNTU}" ] || [ -n "${DEBIAN}" ] || [ -n "${MINT}" ]
then
if [ ! -d /usr/src/linux-headers-`uname -r` ]
then
echo "ERRO."
echo "Os headers do kernel nao foram instalados no sistema ou nao batem com o kernel atual. Impossivel processeguir"
echo "Instale e/ou atualize os seguintes pacotes:"
echo " * linux-image-generic"
echo " * linux-image-headers"
echo
exit
fi
elif [ -n "${OPENSUSE}" ]
then
RET=`uname -r | cut -d '-' -f 1`
RET2=`uname -r | cut -d '-' -f 2`
if [ ! -d /usr/src/linux-$RET-$RET2 ]
then
echo "ERRO"
echo "Os headers do kernel nao foram instalados no sistema ou nao batem com o kernel atual. Impossivel processeguir"
echo
exit
fi
elif [ -n "${GENTOO}" ]
then
RET=`uname -r`
if [ ! -d /usr/src/linux-$RET ]
then
echo "ERROR."
echo "Os headers do kernel nao foram instalados no sistema ou nao batem com o kernel atual. Impossivel processeguir"
echo
exit
fi
elif [ -n "${SLACK}" ]
then
RET=`uname -r | cut -d '-' -f 1`
if [ ! -d /usr/src/linux-$RET ]
then
echo "ERROR."
echo "Os headers do kernel nao foram instalados no sistema ou nao batem com o kernel atual. Impossivel processeguir"
echo
exit
fi
fi
echo OK.
echo
echo
echo "Iniciando instalacao do Aker Client... "
INSTALL_DIR=/usr/local/AkerClient
DRIVER_DIR=${INSTALL_DIR}/driver
INIT_DIR=/etc/init.d
SBIN_DIR=/sbin
RC_DIR=/etc
SHARE_DIR=/usr/share
./remover.sh >/dev/null 2>&1
mkdir -p ${INSTALL_DIR}/driver
install -m 755 bin/acservice ${INSTALL_DIR}
install -m 751 scripts/acservice.init ${INSTALL_DIR}
install -m 751 scripts/acservice_env ${INSTALL_DIR}
install -m 751 scripts/acservice_gentoo ${INSTALL_DIR}
install -m 755 bin/akerclient ${INSTALL_DIR}
install -m 755 scripts/akerclient_init.sh ${INSTALL_DIR}
install -m 644 bin/akerclientPT.qm ${INSTALL_DIR}
install -m 444 driver/ak_client_drv.c ${DRIVER_DIR}
install -m 444 driver/ak_client_drv.h ${DRIVER_DIR}
install -m 444 driver/ak_client_hook.c ${DRIVER_DIR}
install -m 444 driver/ak_stand_alone.h ${DRIVER_DIR}
install -m 444 driver/aktypes.h ${DRIVER_DIR}
install -m 444 driver/Makefile ${DRIVER_DIR}
install -m 444 driver/md5.c ${DRIVER_DIR}
install -m 444 driver/md5.h ${DRIVER_DIR}
install -m 744 driver/buildkernelmod.sh ${DRIVER_DIR}
install -m 755 bin/pam_aker_client.so ${INSTALL_DIR}
install -m 744 scripts/pam_ac_install.sh ${INSTALL_DIR}
install -m 744 scripts/pam_ac_install_ubuntu.sh ${INSTALL_DIR}
install -m 644 icons/akerclient.png ${SHARE_DIR}/pixmaps
install -m 644 icons/akerclient.desktop ${SHARE_DIR}/applications
install -m 644 icons/akerclient.desktop ${SHARE_DIR}/autostart
install -m 644 icons/akerclient.desktop ${SHARE_DIR}/gnome/autostart
install -m 751 remover.sh ${INSTALL_DIR}
cp -rf libs ${INSTALL_DIR}
ln -sf libXfixes.so.3 ${INSTALL_DIR}/libs/libXfixes.so
chcon -t textrel_shlib_t ${INSTALL_DIR}/libs/* >/dev/null 2>&1
chcon -t bin_t ${INSTALL_DIR}/pam_aker_client.so >/dev/null 2>&1
chcon -t textrel_shlib_t ${INSTALL_DIR}/pam_aker_client.so >/dev/null 2>&1
#Instala o servico
if [ -n "${OPENSUSE}" ]
then
install -m 751 scripts/acservice.sh ${INIT_DIR}/acservice
insserv ${INIT_DIR}/acservice >> /dev/null 2>> /dev/null
ln -s ${INIT_DIR}/acservice ${SBIN_DIR}/rcacservice
elif [ -n "${GENTOO}" ]
then
install -m 751 scripts/acservice_gentoo ${INIT_DIR}/acservice
rc-update add acservice default
else
install -m 751 scripts/acservice.sh ${INIT_DIR}/acservice
ln -sf ${INIT_DIR}/acservice ${RC_DIR}/rc0.d/K14acservice.sh
ln -sf ${INIT_DIR}/acservice ${RC_DIR}/rc1.d/K14acservice.sh
ln -sf ${INIT_DIR}/acservice ${RC_DIR}/rc2.d/S14acservice.sh
ln -sf ${INIT_DIR}/acservice ${RC_DIR}/rc3.d/S14acservice.sh
ln -sf ${INIT_DIR}/acservice ${RC_DIR}/rc4.d/S14acservice.sh
ln -sf ${INIT_DIR}/acservice ${RC_DIR}/rc5.d/S14acservice.sh
ln -sf ${INIT_DIR}/acservice ${RC_DIR}/rc6.d/K14acservice.sh
#Fedora com systemd tem que incluir o servico atraves do chkconf
if [ -e /etc/systemd ] && [ -n "${FEDORA}" ]
then
chkconfig --add acservice
fi
fi
if [ ! -d /dev/net ]
then
mkdir /dev/net
fi
if [ ! -e /dev/net/tun ]
then
mknod /dev/net/tun c 10 200
chmod 0700 /dev/net/tun
fi
rm -f /dev/acservice
mknod /dev/acservice c 122 0
chmod 644 /dev/acservice
echo
echo -n "Instalando modulo de login transparente... "
if [ -n "${UBUNTU}" ] || [ -n "${OPENSUSE}" ] || [ -n "${MINT}" ]
then
${INSTALL_DIR}/pam_ac_install_ubuntu.sh
else
${INSTALL_DIR}/pam_ac_install.sh
fi
echo "OK."
echo
echo -n "Instalacao do modulo de kernel do Aker Client... "
${DRIVER_DIR}/buildkernelmod.sh
if [ $? = 0 ]
then
echo "OK."
else
echo "Resolva as pendencias e execute ${DRIVER_DIR}/buildkernelmod.sh"
echo "para compilar o modulo."
fi
echo
echo -n "Iniciando o servico... "
${INIT_DIR}/acservice start
echo "OK."
touch /usr/local/AkerClient/configuration.xml
chmod o+w /usr/local/AkerClient/configuration.xml
echo
echo "Execute ${INSTALL_DIR}/akerclient_init.sh para iniciar a GUI do Aker Client."