1 | #!/bin/bash |
---|
2 | #/** |
---|
3 | #@file opengnsys_update.sh |
---|
4 | #@brief Script actualización de OpenGnSys |
---|
5 | #@warning No se actualiza BD, ni ficheros de configuración. |
---|
6 | #@version 0.9 - basado en opengnsys_installer.sh |
---|
7 | #@author Ramón Gómez - ETSII Univ. Sevilla |
---|
8 | #@date 2010/01/27 |
---|
9 | #@version 1.0 - adaptación a OpenGnSys 1.0 |
---|
10 | #@author Ramón Gómez - ETSII Univ. Sevilla |
---|
11 | #@date 2011/03/02 |
---|
12 | #*/ |
---|
13 | |
---|
14 | |
---|
15 | # Sólo ejecutable por usuario root |
---|
16 | if [ "$(whoami)" != 'root' ] |
---|
17 | then |
---|
18 | echo "ERROR: this program must run under root privileges!!" |
---|
19 | exit 1 |
---|
20 | fi |
---|
21 | |
---|
22 | # Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1). |
---|
23 | PROGRAMDIR=$(readlink -e $(dirname "$0")) |
---|
24 | DEPS="build-essential g++-multilib rsync ctorrent samba unzip netpipes debootstrap schroot squashfs-tools" |
---|
25 | if [ -d "$PROGRAMDIR/../installer" ]; then |
---|
26 | USESVN=0 |
---|
27 | else |
---|
28 | USESVN=1 |
---|
29 | SVN_URL=http://www.opengnsys.es/svn/branches/version1.0 |
---|
30 | DEPS="$DEPS subversion" |
---|
31 | fi |
---|
32 | |
---|
33 | WORKDIR=/tmp/opengnsys_update |
---|
34 | mkdir -p $WORKDIR |
---|
35 | |
---|
36 | INSTALL_TARGET=/opt/opengnsys |
---|
37 | LOG_FILE=/tmp/opengnsys_update.log |
---|
38 | |
---|
39 | |
---|
40 | |
---|
41 | ##################################################################### |
---|
42 | ####### Algunas funciones útiles de propósito general: |
---|
43 | ##################################################################### |
---|
44 | function getDateTime() |
---|
45 | { |
---|
46 | echo `date +%Y%m%d-%H%M%S` |
---|
47 | } |
---|
48 | |
---|
49 | # Escribe a fichero y muestra por pantalla |
---|
50 | function echoAndLog() |
---|
51 | { |
---|
52 | echo $1 |
---|
53 | FECHAHORA=`getDateTime` |
---|
54 | echo "$FECHAHORA;$SSH_CLIENT;$1" >> $LOG_FILE |
---|
55 | } |
---|
56 | |
---|
57 | function errorAndLog() |
---|
58 | { |
---|
59 | echo "ERROR: $1" |
---|
60 | FECHAHORA=`getDateTime` |
---|
61 | echo "$FECHAHORA;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | ##################################################################### |
---|
66 | ####### Funciones de copia de seguridad y restauración de ficheros |
---|
67 | ##################################################################### |
---|
68 | |
---|
69 | # Hace un backup del fichero pasado por parámetro |
---|
70 | # deja un -last y uno para el día |
---|
71 | function backupFile() |
---|
72 | { |
---|
73 | if [ $# -ne 1 ]; then |
---|
74 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
75 | exit 1 |
---|
76 | fi |
---|
77 | |
---|
78 | local fichero=$1 |
---|
79 | local fecha=`date +%Y%m%d` |
---|
80 | |
---|
81 | if [ ! -f $fichero ]; then |
---|
82 | errorAndLog "${FUNCNAME}(): file $fichero doesn't exists" |
---|
83 | return 1 |
---|
84 | fi |
---|
85 | |
---|
86 | echoAndLog "${FUNCNAME}(): Making $fichero back-up" |
---|
87 | |
---|
88 | # realiza una copia de la última configuración como last |
---|
89 | cp -p $fichero "${fichero}-LAST" |
---|
90 | |
---|
91 | # si para el día no hay backup lo hace, sino no |
---|
92 | if [ ! -f "${fichero}-${fecha}" ]; then |
---|
93 | cp -p $fichero "${fichero}-${fecha}" |
---|
94 | fi |
---|
95 | } |
---|
96 | |
---|
97 | # Restaura un fichero desde su copia de seguridad |
---|
98 | function restoreFile() |
---|
99 | { |
---|
100 | if [ $# -ne 1 ]; then |
---|
101 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
102 | exit 1 |
---|
103 | fi |
---|
104 | |
---|
105 | local fichero=$1 |
---|
106 | |
---|
107 | echoAndLog "${FUNCNAME}(): restoring $fichero file" |
---|
108 | if [ -f "${fichero}-LAST" ]; then |
---|
109 | cp -p "$fichero-LAST" "$fichero" |
---|
110 | fi |
---|
111 | } |
---|
112 | |
---|
113 | |
---|
114 | ##################################################################### |
---|
115 | ####### Funciones de instalación de paquetes |
---|
116 | ##################################################################### |
---|
117 | |
---|
118 | # Instalar las deependencias necesarias para el actualizador. |
---|
119 | function installDependencies () |
---|
120 | { |
---|
121 | if [ $# = 0 ]; then |
---|
122 | echoAndLog "${FUNCNAME}(): no deps needed." |
---|
123 | else |
---|
124 | while [ $# -gt 0 ]; do |
---|
125 | dpkg -s $1 &>/dev/null | grep Status | grep -qw install |
---|
126 | if [ $? -ne 0 ]; then |
---|
127 | INSTALLDEPS="$INSTALLDEPS $1" |
---|
128 | fi |
---|
129 | shift |
---|
130 | done |
---|
131 | if [ -n "$INSTALLDEPS" ]; then |
---|
132 | apt-get update && apt-get install $INSTALLDEPS |
---|
133 | if [ $? -ne 0 ]; then |
---|
134 | errorAndLog "${FUNCNAME}(): cannot install some dependencies: $INSTALLDEPS." |
---|
135 | return 1 |
---|
136 | fi |
---|
137 | fi |
---|
138 | fi |
---|
139 | } |
---|
140 | |
---|
141 | |
---|
142 | ##################################################################### |
---|
143 | ####### Funciones para el manejo de Subversion |
---|
144 | ##################################################################### |
---|
145 | |
---|
146 | function svnExportCode() |
---|
147 | { |
---|
148 | if [ $# -ne 1 ]; then |
---|
149 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
150 | exit 1 |
---|
151 | fi |
---|
152 | |
---|
153 | local url=$1 |
---|
154 | |
---|
155 | echoAndLog "${FUNCNAME}(): downloading subversion code..." |
---|
156 | |
---|
157 | svn checkout "${url}" opengnsys |
---|
158 | if [ $? -ne 0 ]; then |
---|
159 | errorAndLog "${FUNCNAME}(): error getting code from ${url}, verify your user and password" |
---|
160 | return 1 |
---|
161 | fi |
---|
162 | echoAndLog "${FUNCNAME}(): subversion code downloaded" |
---|
163 | return 0 |
---|
164 | } |
---|
165 | |
---|
166 | |
---|
167 | ############################################################ |
---|
168 | ### Detectar red |
---|
169 | ############################################################ |
---|
170 | |
---|
171 | function getNetworkSettings() |
---|
172 | { |
---|
173 | local MAINDEV |
---|
174 | |
---|
175 | echoAndLog "getNetworkSettings(): Detecting default network parameters." |
---|
176 | MAINDEV=$(ip -o link show up | awk '!/loopback/ {d=d$2} END {sub(/:.*/,"",d); print d}') |
---|
177 | if [ -z "$MAINDEV" ]; then |
---|
178 | errorAndLog "${FUNCNAME}(): Network device not detected." |
---|
179 | return 1 |
---|
180 | fi |
---|
181 | |
---|
182 | # Variables de ejecución de Apache |
---|
183 | # - APACHE_RUN_USER |
---|
184 | # - APACHE_RUN_GROUP |
---|
185 | if [ -f /etc/apache2/envvars ]; then |
---|
186 | source /etc/apache2/envvars |
---|
187 | fi |
---|
188 | APACHE_RUN_USER=${APACHE_RUN_USER:-"www-data"} |
---|
189 | APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"www-data"} |
---|
190 | } |
---|
191 | |
---|
192 | |
---|
193 | ##################################################################### |
---|
194 | ####### Funciones específicas de la instalación de Opengnsys |
---|
195 | ##################################################################### |
---|
196 | |
---|
197 | # Copiar ficheros de arranque de los servicios del sistema de OpenGnSys |
---|
198 | |
---|
199 | function updateServicesStart(){ |
---|
200 | echoAndLog "${FUNCNAME}(): Updating /etc/init.d/opengnsys ..." |
---|
201 | cp -p $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys |
---|
202 | if [ $? != 0 ]; then |
---|
203 | errorAndLog "${FUNCNAME}(): Error updating /etc/init.d/opengnsys" |
---|
204 | exit 1 |
---|
205 | fi |
---|
206 | echoAndLog "${FUNCNAME}(): /etc/init.d/opengnsys updated successfully." |
---|
207 | } |
---|
208 | |
---|
209 | # Actualizar cliente OpenGnSys |
---|
210 | function openGnsysCopyClientFiles() |
---|
211 | { |
---|
212 | local hayErrores=0 |
---|
213 | |
---|
214 | echoAndLog "${FUNCNAME}(): Updating OpenGnSys Client files." |
---|
215 | #cp -ar $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client |
---|
216 | rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client |
---|
217 | if [ $? -ne 0 ]; then |
---|
218 | errorAndLog "${FUNCNAME}(): error while updating client structure" |
---|
219 | hayErrores=1 |
---|
220 | fi |
---|
221 | find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null |
---|
222 | |
---|
223 | echoAndLog "${FUNCNAME}(): Updating OpenGnSys Cloning Engine files." |
---|
224 | #mkdir -p $INSTALL_TARGET/client/lib/engine/bin |
---|
225 | #cp -ar $WORKDIR/opengnsys/client/engine/*.lib $INSTALL_TARGET/client/lib/engine/bin |
---|
226 | rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/engine/*.lib $INSTALL_TARGET/client/lib/engine/bin |
---|
227 | if [ $? -ne 0 ]; then |
---|
228 | errorAndLog "${FUNCNAME}(): error while updating engine files" |
---|
229 | hayErrores=1 |
---|
230 | fi |
---|
231 | |
---|
232 | if [ $hayErrores -eq 0 ]; then |
---|
233 | echoAndLog "${FUNCNAME}(): client files update success." |
---|
234 | else |
---|
235 | errorAndLog "${FUNCNAME}(): client files update with errors" |
---|
236 | fi |
---|
237 | |
---|
238 | return $hayErrores |
---|
239 | } |
---|
240 | # Copiar ficheros del OpenGnSys Web Console. |
---|
241 | function updateWebFiles() |
---|
242 | { |
---|
243 | local ERRCODE |
---|
244 | echoAndLog "${FUNCNAME}(): Updating web files..." |
---|
245 | backupFile $INSTALL_TARGET/www/controlacceso.php |
---|
246 | mv $INSTALL_TARGET/www $INSTALL_TARGET/WebConsole |
---|
247 | rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/WebConsole $INSTALL_TARGET |
---|
248 | ERRCODE=$? |
---|
249 | mv $INSTALL_TARGET/WebConsole $INSTALL_TARGET/www |
---|
250 | unzip -o $WORKDIR/opengnsys/admin/xajax_0.5_standard.zip -d $INSTALL_TARGET/www/xajax |
---|
251 | if [ $ERRCODE != 0 ]; then |
---|
252 | errorAndLog "${FUNCNAME}(): Error updating web files." |
---|
253 | exit 1 |
---|
254 | fi |
---|
255 | restoreFile $INSTALL_TARGET/www/controlacceso.php |
---|
256 | # Cambiar permisos para ficheros especiales. |
---|
257 | chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/includes $INSTALL_TARGET/www/images/iconos |
---|
258 | echoAndLog "${FUNCNAME}(): Web files updated successfully." |
---|
259 | |
---|
260 | } |
---|
261 | |
---|
262 | # Copiar carpeta de Interface |
---|
263 | function updateInterfaceAdm () |
---|
264 | { |
---|
265 | local hayErrores=0 |
---|
266 | |
---|
267 | # Crear carpeta y copiar Interface |
---|
268 | echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder" |
---|
269 | mv $INSTALL_TARGET/client/interfaceAdm $INSTALL_TARGET/client/Interface |
---|
270 | rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client |
---|
271 | ERRCODE=$? |
---|
272 | mv $INSTALL_TARGET/client/Interface $INSTALL_TARGET/client/interfaceAdm |
---|
273 | if [ $? -ne 0 ]; then |
---|
274 | echoAndLog "${FUNCNAME}(): error while updating admin interface" |
---|
275 | exit 1 |
---|
276 | fi |
---|
277 | chmod -R +x $INSTALL_TARGET/client/interfaceAdm |
---|
278 | echoAndLog "${FUNCNAME}(): Admin interface updated successfully." |
---|
279 | } |
---|
280 | |
---|
281 | # Crear documentación Doxygen para la consola web. |
---|
282 | function makeDoxygenFiles() |
---|
283 | { |
---|
284 | echoAndLog "${FUNCNAME}(): Making Doxygen web files..." |
---|
285 | $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \ |
---|
286 | $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www |
---|
287 | if [ ! -d "$INSTALL_TARGET/www/html" ]; then |
---|
288 | errorAndLog "${FUNCNAME}(): unable to create Doxygen web files." |
---|
289 | return 1 |
---|
290 | fi |
---|
291 | rm -fr "$INSTALL_TARGET/www/api" |
---|
292 | mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api" |
---|
293 | rm -fr $INSTALL_TARGET/www/{man,perlmod,rtf} |
---|
294 | chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/api |
---|
295 | echoAndLog "${FUNCNAME}(): Doxygen web files created successfully." |
---|
296 | } |
---|
297 | |
---|
298 | |
---|
299 | # Crea la estructura base de la instalación de opengnsys |
---|
300 | function createDirs() |
---|
301 | { |
---|
302 | echoAndLog "${FUNCNAME}(): creating directory paths in ${INSTALL_TARGET}" |
---|
303 | |
---|
304 | mkdir -p ${INSTALL_TARGET} |
---|
305 | mkdir -p ${INSTALL_TARGET}/bin |
---|
306 | mkdir -p ${INSTALL_TARGET}/client |
---|
307 | mkdir -p ${INSTALL_TARGET}/doc |
---|
308 | mkdir -p ${INSTALL_TARGET}/etc |
---|
309 | mkdir -p ${INSTALL_TARGET}/lib |
---|
310 | mkdir -p ${INSTALL_TARGET}/log/clients |
---|
311 | mkdir -p ${INSTALL_TARGET}/sbin |
---|
312 | mkdir -p ${INSTALL_TARGET}/www |
---|
313 | mkdir -p ${INSTALL_TARGET}/images |
---|
314 | ln -fs /var/lib/tftpboot ${INSTALL_TARGET} |
---|
315 | ln -fs ${INSTALL_TARGET}/log /var/log/opengnsys |
---|
316 | |
---|
317 | if [ $? -ne 0 ]; then |
---|
318 | errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?" |
---|
319 | return 1 |
---|
320 | fi |
---|
321 | |
---|
322 | echoAndLog "${FUNCNAME}(): directory paths created" |
---|
323 | return 0 |
---|
324 | } |
---|
325 | |
---|
326 | # Copia ficheros de configuración y ejecutables genéricos del servidor. |
---|
327 | function updateServerFiles () { |
---|
328 | |
---|
329 | # No copiar ficheros del antiguo cliente Initrd |
---|
330 | local SOURCES=( repoman/bin \ |
---|
331 | server/bin \ |
---|
332 | doc ) |
---|
333 | local TARGETS=( bin \ |
---|
334 | bin \ |
---|
335 | doc ) |
---|
336 | |
---|
337 | if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then |
---|
338 | errorAndLog "${FUNCNAME}(): inconsistent number of array items" |
---|
339 | exit 1 |
---|
340 | fi |
---|
341 | |
---|
342 | echoAndLog "${FUNCNAME}(): updating files in server directories" |
---|
343 | pushd $WORKDIR/opengnsys >/dev/null |
---|
344 | local i |
---|
345 | for (( i = 0; i < ${#SOURCES[@]}; i++ )); do |
---|
346 | rsync --exclude .svn -irplt "${SOURCES[$i]}" "${INSTALL_TARGET}/${TARGETS[$i]}" |
---|
347 | done |
---|
348 | popd >/dev/null |
---|
349 | echoAndLog "${FUNCNAME}(): updating cron files" |
---|
350 | echo "* * * * * root [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator |
---|
351 | echoAndLog "${FUNCNAME}(): server files updated successfully." |
---|
352 | } |
---|
353 | |
---|
354 | #################################################################### |
---|
355 | ### Funciones de compilación de código fuente de servicios |
---|
356 | #################################################################### |
---|
357 | |
---|
358 | # Recompilar y actualiza el binario del clinete |
---|
359 | function recompileClient () |
---|
360 | { |
---|
361 | # Compilar OpenGnSys Client |
---|
362 | echoAndLog "${FUNCNAME}(): recompiling OpenGnSys Client" |
---|
363 | pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient |
---|
364 | make && mv ogAdmClient $INSTALL_TARGET/client/bin |
---|
365 | if [ $? -ne 0 ]; then |
---|
366 | echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Client" |
---|
367 | hayErrores=1 |
---|
368 | fi |
---|
369 | popd |
---|
370 | |
---|
371 | return $hayErrores |
---|
372 | } |
---|
373 | |
---|
374 | |
---|
375 | #################################################################### |
---|
376 | ### Funciones instalacion cliente opengnsys |
---|
377 | #################################################################### |
---|
378 | |
---|
379 | # Actualizar antiguo cliente Initrd. |
---|
380 | function updateOldClient() |
---|
381 | { |
---|
382 | local OSDISTRIB OSCODENAME |
---|
383 | |
---|
384 | local hayErrores=0 |
---|
385 | |
---|
386 | echoAndLog "${FUNCNAME}(): Copying OpenGnSys Client files." |
---|
387 | rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/nfsexport/* $INSTALL_TARGET/client |
---|
388 | echoAndLog "${FUNCNAME}(): Copying OpenGnSys Cloning Engine files." |
---|
389 | mkdir -p $INSTALL_TARGET/client/lib/engine/bin |
---|
390 | rsync -iplt $WORKDIR/opengnsys/client/engine/*.lib $INSTALL_TARGET/client/lib/engine/bin |
---|
391 | if [ $? -ne 0 ]; then |
---|
392 | errorAndLog "${FUNCNAME}(): error while copying engine files" |
---|
393 | hayErrores=1 |
---|
394 | fi |
---|
395 | |
---|
396 | # Cargar Kernel, Initrd y paquetes udeb para la distribución del servidor (o por defecto). |
---|
397 | OSDISTRIB=$(lsb_release -is) 2>/dev/null |
---|
398 | OSCODENAME=$(lsb_release -cs) 2>/dev/null |
---|
399 | if [ "$OSDISTRIB" = "Ubuntu" -a -n "$OSCODENAME" ]; then |
---|
400 | echoAndLog "${FUNCNAME}(): Loading Kernel and Initrd files for $OSDISTRIB $OSCODENAME." |
---|
401 | $INSTALL_TARGET/bin/initrd-generator -t $INSTALL_TARGET/tftpboot -v $OSCODENAME 2>&1 | tee -a $LOG_FILE |
---|
402 | if [ $? -ne 0 ]; then |
---|
403 | errorAndLog "${FUNCNAME}(): error while generating initrd OpenGnSys Admin Client" |
---|
404 | hayErrores=1 |
---|
405 | fi |
---|
406 | echoAndLog "${FUNCNAME}(): Loading udeb files for $OSDISTRIB $OSCODENAME." |
---|
407 | $INSTALL_TARGET/bin/upgrade-clients-udeb.sh $OSCODENAME 2>&1 | tee -a $LOG_FILE |
---|
408 | if [ $? -ne 0 ]; then |
---|
409 | errorAndLog "${FUNCNAME}(): error while upgrading udeb files OpenGnSys Admin Client" |
---|
410 | hayErrores=1 |
---|
411 | fi |
---|
412 | else |
---|
413 | echoAndLog "${FUNCNAME}(): Loading default Kernel and Initrd files." |
---|
414 | $INSTALL_TARGET/bin/initrd-generator -t $INSTALL_TARGET/tftpboot 2>&1 | tee -a $LOG_FILE |
---|
415 | if [ $? -ne 0 ]; then |
---|
416 | errorAndLog "${FUNCNAME}(): error while generating initrd OpenGnSys Admin Client" |
---|
417 | hayErrores=1 |
---|
418 | fi |
---|
419 | echoAndLog "${FUNCNAME}(): Loading default udeb files." |
---|
420 | $INSTALL_TARGET/bin/upgrade-clients-udeb.sh 2>&1 | tee -a $LOG_FILE |
---|
421 | if [ $? -ne 0 ]; then |
---|
422 | errorAndLog "${FUNCNAME}(): error while upgrading udeb files OpenGnSys Admin Client" |
---|
423 | hayErrores=1 |
---|
424 | fi |
---|
425 | fi |
---|
426 | |
---|
427 | if [ $hayErrores -eq 0 ]; then |
---|
428 | echoAndLog "${FUNCNAME}(): Client generation success." |
---|
429 | else |
---|
430 | errorAndLog "${FUNCNAME}(): Client generation with errors" |
---|
431 | fi |
---|
432 | |
---|
433 | return $hayErrores |
---|
434 | } |
---|
435 | |
---|
436 | # Actualizar nuevo cliente para OpenGnSys 1.0 |
---|
437 | function updateClient() |
---|
438 | { |
---|
439 | local DOWNLOADURL=http://www.opengnsys.es/downloads |
---|
440 | local FILENAME=ogclient-1.0-lucid-32bit.tar.gz |
---|
441 | local TMPFILE=/tmp/$FILENAME |
---|
442 | |
---|
443 | echoAndLog "${FUNCNAME}(): Loading Client" |
---|
444 | # Descargar y descomprimir cliente ogclient |
---|
445 | wget $DOWNLOADURL/$FILENAME -O $TMPFILE |
---|
446 | if [ ! -s $TMPFILE ]; then |
---|
447 | errorAndLog "${FUNCNAME}(): Error loading OpenGnSys Client" |
---|
448 | return 1 |
---|
449 | fi |
---|
450 | echoAndLog "${FUNCNAME}(): Extracting Client files" |
---|
451 | tar xzvf $TMPFILE -C $INSTALL_TARGET/tftpboot |
---|
452 | rm -f $TMPFILE |
---|
453 | # Usar la versión más reciente del Kernel y del Initrd para el cliente. |
---|
454 | ln $(ls $INSTALL_TARGET/tftpboot/ogclient/vmlinuz-*|tail -1) $INSTALL_TARGET/tftpboot/ogclient/ogvmlinuz |
---|
455 | ln $(ls $INSTALL_TARGET/tftpboot/ogclient/initrd.img-*|tail -1) $INSTALL_TARGET/tftpboot/ogclient/oginitrd.img |
---|
456 | # Establecer los permisos. |
---|
457 | chmod -R 755 $INSTALL_TARGET/tftpboot/ogclient |
---|
458 | chown -R :$OPENGNSYS_CLIENT_USER $INSTALL_TARGET/tftpboot/ogclient |
---|
459 | echoAndLog "${FUNCNAME}(): Client update successfully" |
---|
460 | } |
---|
461 | |
---|
462 | |
---|
463 | ##################################################################### |
---|
464 | ####### Proceso de actualización de OpenGnSys |
---|
465 | ##################################################################### |
---|
466 | |
---|
467 | |
---|
468 | echoAndLog "OpenGnSys update begins at $(date)" |
---|
469 | |
---|
470 | # Instalar dependencia. |
---|
471 | installDependencies $DEPS |
---|
472 | if [ $? -ne 0 ]; then |
---|
473 | errorAndLog "Error: you may install all needed dependencies." |
---|
474 | exit 1 |
---|
475 | fi |
---|
476 | |
---|
477 | pushd $WORKDIR |
---|
478 | |
---|
479 | # Detectar parámetros de red por defecto |
---|
480 | getNetworkSettings |
---|
481 | if [ $? -ne 0 ]; then |
---|
482 | errorAndLog "Error reading default network settings." |
---|
483 | exit 1 |
---|
484 | fi |
---|
485 | |
---|
486 | # Arbol de directorios de OpenGnSys. |
---|
487 | createDirs ${INSTALL_TARGET} |
---|
488 | if [ $? -ne 0 ]; then |
---|
489 | errorAndLog "Error while creating directory paths!" |
---|
490 | exit 1 |
---|
491 | fi |
---|
492 | |
---|
493 | # Si es necesario, descarga el repositorio de código en directorio temporal |
---|
494 | if [ $USESVN -eq 1 ]; then |
---|
495 | svnExportCode $SVN_URL |
---|
496 | if [ $? -ne 0 ]; then |
---|
497 | errorAndLog "Error while getting code from svn" |
---|
498 | exit 1 |
---|
499 | fi |
---|
500 | else |
---|
501 | ln -fs "$(dirname $PROGRAMDIR)" opengnsys |
---|
502 | fi |
---|
503 | |
---|
504 | # Copiando ficheros complementarios del servidor |
---|
505 | updateServerFiles |
---|
506 | if [ $? -ne 0 ]; then |
---|
507 | errorAndLog "Error updating OpenGnSys Server files" |
---|
508 | exit 1 |
---|
509 | fi |
---|
510 | |
---|
511 | # Actualizando cliente |
---|
512 | openGnsysCopyClientFiles |
---|
513 | |
---|
514 | # Copiando paqinas web |
---|
515 | updateWebFiles |
---|
516 | if [ $? -ne 0 ]; then |
---|
517 | errorAndLog "Error updating OpenGnSys Web Admin files" |
---|
518 | exit 1 |
---|
519 | fi |
---|
520 | # Generar páginas Doxygen para instalar en el web |
---|
521 | makeDoxygenFiles |
---|
522 | |
---|
523 | # Creando la estructura del cliente |
---|
524 | recompileClient |
---|
525 | # NO se actualiza el antiguo cliente Initrd |
---|
526 | #updateOldClient |
---|
527 | updateClient |
---|
528 | if [ $? -ne 0 ]; then |
---|
529 | errorAndLog "Error updating clients" |
---|
530 | exit 1 |
---|
531 | fi |
---|
532 | updateInterfaceAdm |
---|
533 | |
---|
534 | # Actualizamos el fichero que arranca los servicios de OpenGnSys |
---|
535 | updateServicesStart |
---|
536 | |
---|
537 | # Eliminamos el fichero de estado del tracker porque es incompatible entre los distintos paquetes |
---|
538 | if [ -r /tmp/dstate ] |
---|
539 | then |
---|
540 | rm /tmp/dstate |
---|
541 | fi |
---|
542 | |
---|
543 | #rm -rf $WORKDIR |
---|
544 | echoAndLog "OpenGnSys update finished at $(date)" |
---|
545 | |
---|
546 | popd |
---|
547 | |
---|