source: installer/opengnsys_update.sh @ c8c720c

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since c8c720c was 5f21d34, checked in by ramon <ramongomez@…>, 10 years ago

Cambios en instalador y actualizador:

  • Activar correctamente módulo Rewrite de Apache.
  • Aplicar nuevo nombre del Proyecto OpenGnsys.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@4683 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 34.0 KB
Line 
1#!/bin/bash
2#/**
3#@file    opengnsys_update.sh
4#@brief   Script actualización de OpenGnsys
5#@version 0.9 - basado en opengnsys_installer.sh
6#@author  Ramón Gómez - ETSII Univ. Sevilla
7#@date    2010/01/27
8#@version 1.0 - adaptación a OpenGnSys 1.0
9#@author  Ramón Gómez - ETSII Univ. Sevilla
10#@date    2011/03/02
11#@version 1.0.1 - control de auto actualización del script
12#@author  Ramón Gómez - ETSII Univ. Sevilla
13#@date    2011/05/17
14#@version 1.0.2a - obtiene valor de dirección IP por defecto
15#@author  Ramón Gómez - ETSII Univ. Sevilla
16#@date    2012/01/18
17#@version 1.0.3 - Compatibilidad con Debian y auto configuración de acceso a BD.
18#@author  Ramón Gómez - ETSII Univ. Sevilla
19#@date    2012/03/12
20#@version 1.0.4 - Detector de distribución y compatibilidad con CentOS.
21#@author  Ramón Gómez - ETSII Univ. Sevilla
22#@date    2012/05/04
23#@version 1.0.5 - Actualizar BD en la misma versión, compatibilidad con Fedora (systemd) y configuración de Rsync.
24#@author  Ramón Gómez - ETSII Univ. Sevilla
25#@date    2014/04/03
26#@version 1.0.6 - Redefinir URLs de ficheros de configuración usando HTTPS.
27#@author  Ramón Gómez - ETSII Univ. Sevilla
28#@date    2015/03/12
29#@version 1.1.0 - Instalación de API REST.
30#@author  Ramón Gómez - ETSII Univ. Sevilla
31#@date    2015/06/18
32#*/
33
34
35####  AVISO: NO EDITAR variables de configuración.
36####  WARNING: DO NOT EDIT configuration variables.
37INSTALL_TARGET=/opt/opengnsys           # Directorio de instalación
38OPENGNSYS_CLIENTUSER="opengnsys"        # Usuario Samba
39
40
41# Sólo ejecutable por usuario root
42if [ "$(whoami)" != 'root' ]; then
43        echo "ERROR: this program must run under root privileges!!"
44        exit 1
45fi
46# Error si OpenGnsys no está instalado (no existe el directorio del proyecto)
47if [ ! -d $INSTALL_TARGET ]; then
48        echo "ERROR: OpenGnsys is not installed, cannot update!!"
49        exit 1
50fi
51# Cargar configuración de acceso a la base de datos.
52if [ -r $INSTALL_TARGET/etc/ogAdmServer.cfg ]; then
53        source $INSTALL_TARGET/etc/ogAdmServer.cfg
54elif [ -r $INSTALL_TARGET/etc/ogAdmAgent.cfg ]; then
55        source $INSTALL_TARGET/etc/ogAdmAgent.cfg
56fi
57OPENGNSYS_DATABASE=${OPENGNSYS_DATABASE:-"$CATALOG"}            # Base de datos
58OPENGNSYS_DBUSER=${OPENGNSYS_DBUSER:-"$USUARIO"}                # Usuario de acceso
59OPENGNSYS_DBPASSWORD=${OPENGNSYS_DBPASSWORD:-"$PASSWORD"}       # Clave del usuario
60if [ -z "$OPENGNSYS_DATABASE" -o -z "$OPENGNSYS_DBUSER" -o -z "$OPENGNSYS_DBPASSWORD" ]; then
61        echo "ERROR: set OPENGNSYS_DATABASE, OPENGNSYS_DBUSER and OPENGNSYS_DBPASSWORD"
62        echo "       variables, and run this script again."
63fi
64
65# Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1).
66PROGRAMDIR=$(readlink -e $(dirname "$0"))
67PROGRAMNAME=$(basename "$0")
68OPENGNSYS_SERVER="www.opengnsys.es"
69if [ -d "$PROGRAMDIR/../installer" ]; then
70        USESVN=0
71else
72        USESVN=1
73fi
74SVN_URL="http://$OPENGNSYS_SERVER/svn/branches/version1.1/"
75
76WORKDIR=/tmp/opengnsys_update
77mkdir -p $WORKDIR
78
79# Registro de incidencias.
80OGLOGFILE=$INSTALL_TARGET/log/${PROGRAMNAME%.sh}.log
81LOG_FILE=/tmp/$(basename $OGLOGFILE)
82
83
84
85#####################################################################
86####### Algunas funciones útiles de propósito general:
87#####################################################################
88
89# Generar variables de configuración del actualizador
90# Variables globales:
91# - OSDISTRIB - distribución Linux
92# - DEPENDENCIES - array de dependencias que deben estar instaladas
93# - UPDATEPKGLIST, INSTALLPKGS, CHECKPKG - comandos para gestión de paquetes
94# - APACHECFGDIR, APACHESERV, DHCPSERV, INETDCFGDIR - configuración y servicios
95function autoConfigure()
96{
97local i
98
99# Detectar sistema operativo del servidor (compatible con fichero os-release y con LSB).
100if [ -f /etc/os-release ]; then
101        source /etc/os-release
102        OSDISTRIB="$ID"
103        OSVERSION="$VERSION_ID"
104else
105        OSDISTRIB=$(lsb_release -is 2>/dev/null)
106        OSVERSION=$(lsb_release -rs 2>/dev/null)
107fi
108# Convertir distribución a minúsculas y obtener solo el 1er número de versión.
109OSDISTRIB="${OSDISTRIB,,}"
110OSVERSION="${OSVERSION%%.*}"
111
112# Configuración según la distribución de Linux.
113case "$OSDISTRIB" in
114        ubuntu|debian|linuxmint)
115                DEPENDENCIES=( php5-ldap xinetd rsync btrfs-tools procps arp-scan )
116                UPDATEPKGLIST="apt-get update"
117                INSTALLPKGS="apt-get -y install --force-yes"
118                CHECKPKG="dpkg -s \$package 2>/dev/null | grep -q \"Status: install ok\""
119                if which service &>/dev/null; then
120                        STARTSERVICE="eval service \$service restart"
121                        STOPSERVICE="eval service \$service stop"
122                else
123                        STARTSERVICE="eval /etc/init.d/\$service restart"
124                        STOPSERVICE="eval /etc/init.d/\$service stop"
125                fi
126                ENABLESERVICE="eval update-rc.d \$service defaults"
127                APACHEUSER="www-data"
128                APACHEGROUP="www-data"
129                INETDCFGDIR=/etc/xinetd.d
130                ;;
131        fedora|centos)
132                DEPENDENCIES=( php-ldap xinetd rsync btrfs-progs procps-ng arp-scan )
133                # En CentOS 7 instalar arp-scan de CentOS 6.
134                [ "$OSDISTRIB$OSVERSION" == "centos7" ] && DEPENDENCIES=( ${DEPENDENCIES[*]/arp-scan/http://dag.wieers.com/redhat/el6/en/$(arch)/dag/RPMS/arp-scan-1.9-1.el6.rf.$(arch).rpm} )
135                INSTALLPKGS="yum install -y"
136                CHECKPKG="rpm -q --quiet \$package"
137                if which systemctl &>/dev/null; then
138                        STARTSERVICE="eval systemctl start \$service.service"
139                        STOPSERVICE="eval systemctl stop \$service.service"
140                        ENABLESERVICE="eval systemctl enable \$service.service"
141                else
142                        STARTSERVICE="eval service \$service start"
143                        STOPSERVICE="eval service \$service stop"
144                        ENABLESERVICE="eval chkconfig \$service on"
145                fi
146                APACHEUSER="apache"
147                APACHEGROUP="apache"
148                INETDCFGDIR=/etc/xinetd.d
149                ;;
150        *)      # Otras distribuciones.
151                ;;
152esac
153for i in apache2 httpd; do
154        [ -f /etc/$i ] && APACHECFGDIR="/etc/$i"
155        [ -f /etc/init.d/$i ] && APACHESERV="/etc/init.d/$i"
156done
157for i in dhcpd dhcpd3-server isc-dhcp-server; do
158        [ -f /etc/init.d/$i ] && DHCPSERV="/etc/init.d/$i"
159done
160}
161
162
163# Comprobar auto-actualización.
164function checkAutoUpdate()
165{
166        local update=0
167
168        # Actaulizar el script si ha cambiado o no existe el original.
169        if [ $USESVN -eq 1 ]; then
170                svn export $SVN_URL/installer/$PROGRAMNAME
171                if ! diff -q $PROGRAMNAME $INSTALL_TARGET/lib/$PROGRAMNAME 2>/dev/null || ! test -f $INSTALL_TARGET/lib/$PROGRAMNAME; then
172                        mv $PROGRAMNAME $INSTALL_TARGET/lib
173                        update=1
174                else
175                        rm -f $PROGRAMNAME
176                fi
177        else
178                if ! diff -q $PROGRAMDIR/$PROGRAMNAME $INSTALL_TARGET/lib/$PROGRAMNAME 2>/dev/null || ! test -f $INSTALL_TARGET/lib/$PROGRAMNAME; then
179                        cp -a $PROGRAMDIR/$PROGRAMNAME $INSTALL_TARGET/lib
180                        update=1
181                fi
182        fi
183
184        return $update
185}
186
187
188function getDateTime()
189{
190        date "+%Y%m%d-%H%M%S"
191}
192
193# Escribe a fichero y muestra por pantalla
194function echoAndLog()
195{
196        echo $1
197        DATETIME=`getDateTime`
198        echo "$DATETIME;$SSH_CLIENT;$1" >> $LOG_FILE
199}
200
201function errorAndLog()
202{
203        echo "ERROR: $1"
204        DATETIME=`getDateTime`
205        echo "$DATETIME;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE
206}
207
208# Escribe a fichero y muestra mensaje de aviso
209function warningAndLog()
210{
211        local DATETIME=`getDateTime`
212        echo "Warning: $1"
213        echo "$DATETIME;$SSH_CLIENT;Warning: $1" >> $LOG_FILE
214}
215
216
217#####################################################################
218####### Funciones de copia de seguridad y restauración de ficheros
219#####################################################################
220
221# Hace un backup del fichero pasado por parámetro
222# deja un -last y uno para el día
223function backupFile()
224{
225        if [ $# -ne 1 ]; then
226                errorAndLog "${FUNCNAME}(): invalid number of parameters"
227                exit 1
228        fi
229
230        local fichero=$1
231        local fecha=`date +%Y%m%d`
232
233        if [ ! -f $fichero ]; then
234                warningAndLog "${FUNCNAME}(): file $fichero doesn't exists"
235                return 1
236        fi
237
238        echoAndLog "${FUNCNAME}(): Making $fichero back-up"
239
240        # realiza una copia de la última configuración como last
241        cp -a $fichero "${fichero}-LAST"
242
243        # si para el día no hay backup lo hace, sino no
244        if [ ! -f "${fichero}-${fecha}" ]; then
245                cp -a $fichero "${fichero}-${fecha}"
246        fi
247}
248
249# Restaura un fichero desde su copia de seguridad
250function restoreFile()
251{
252        if [ $# -ne 1 ]; then
253                errorAndLog "${FUNCNAME}(): invalid number of parameters"
254                exit 1
255        fi
256
257        local fichero=$1
258
259        echoAndLog "${FUNCNAME}(): restoring file $fichero"
260        if [ -f "${fichero}-LAST" ]; then
261                cp -a "$fichero-LAST" "$fichero"
262        fi
263}
264
265
266#####################################################################
267####### Funciones de acceso a base de datos
268#####################################################################
269
270# Actualizar la base datos
271function importSqlFile()
272{
273        if [ $# -ne 4 ]; then
274                errorAndLog "${FNCNAME}(): invalid number of parameters"
275                exit 1
276        fi
277
278        local dbuser="$1"
279        local dbpassword="$2"
280        local database="$3"
281        local sqlfile="$4"
282        local tmpfile=$(mktemp)
283        local mycnf=/tmp/.my.cnf.$$
284        local status
285
286        if [ ! -r $sqlfile ]; then
287                errorAndLog "${FUNCNAME}(): Unable to read $sqlfile!!"
288                return 1
289        fi
290
291        echoAndLog "${FUNCNAME}(): importing SQL file to ${database}..."
292        chmod 600 $tmpfile
293        sed -e "s/SERVERIP/$SERVERIP/g" -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
294            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" $sqlfile > $tmpfile
295        # Componer fichero con credenciales de conexión. 
296        touch $mycnf
297        chmod 600 $mycnf
298        cat << EOT > $mycnf
299[client]
300user=$dbuser
301password=$dbpassword
302EOT
303        # Ejecutar actualización y borrar fichero de credenciales.
304        mysql --defaults-extra-file=$mycnf --default-character-set=utf8 -D "$database" < $tmpfile
305        status=$?
306        rm -f $mycnf $tmpfile
307        if [ $status -ne 0 ]; then
308                errorAndLog "${FUNCNAME}(): error importing $sqlfile in database $database"
309                return 1
310        fi
311        echoAndLog "${FUNCNAME}(): file imported to database $database"
312        return 0
313}
314
315
316#####################################################################
317####### Funciones de instalación de paquetes
318#####################################################################
319
320# Instalar las deependencias necesarias para el actualizador.
321function installDependencies()
322{
323        local package
324
325        if [ $# = 0 ]; then
326                echoAndLog "${FUNCNAME}(): no deps needed."
327        else
328                while [ $# -gt 0 ]; do
329                        package="$1"
330                        eval $CHECKPKG || INSTALLDEPS="$INSTALLDEPS $1"
331                        shift
332                done
333                if [ -n "$INSTALLDEPS" ]; then
334                        $UPDATEPKGLIST
335                        $INSTALLPKGS $INSTALLDEPS
336                        if [ $? -ne 0 ]; then
337                                errorAndLog "${FUNCNAME}(): cannot install some dependencies: $INSTALLDEPS."
338                                return 1
339                        fi
340                fi
341        fi
342}
343
344
345#####################################################################
346####### Funciones para el manejo de Subversion
347#####################################################################
348
349function svnExportCode()
350{
351        if [ $# -ne 1 ]; then
352                errorAndLog "${FUNCNAME}(): invalid number of parameters"
353                exit 1
354        fi
355
356        local url="$1"
357
358        echoAndLog "${FUNCNAME}(): downloading subversion code..."
359
360        svn checkout "${url}" opengnsys
361        if [ $? -ne 0 ]; then
362                errorAndLog "${FUNCNAME}(): error getting code from ${url}, verify your user and password"
363                return 1
364        fi
365        echoAndLog "${FUNCNAME}(): subversion code downloaded"
366        return 0
367}
368
369
370############################################################
371###  Detectar red
372############################################################
373
374# Comprobar si existe conexión.
375function checkNetworkConnection()
376{
377        OPENGNSYS_SERVER=${OPENGNSYS_SERVER:-"www.opengnsys.es"}
378        wget --spider -q $OPENGNSYS_SERVER
379}
380
381# Obtener los parámetros de red del servidor.
382function getNetworkSettings()
383{
384        # Variables globales definidas:
385        # - SERVERIP:   IP local de la interfaz por defecto.
386
387        local DEVICES
388        local dev
389
390        echoAndLog "${FUNCNAME}(): Detecting network parameters."
391        SERVERIP="$ServidorAdm"
392        DEVICES="$(ip -o link show up | awk '!/loopback/ {sub(/:.*/,"",$2); print $2}')"
393        for dev in $DEVICES; do
394                [ -z "$SERVERIP" ] && SERVERIP=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}')
395        done
396}
397
398
399#####################################################################
400####### Funciones específicas de la instalación de Opengnsys
401#####################################################################
402
403# Actualizar cliente OpenGnsys.
404function updateClientFiles()
405{
406        # Actualizar ficheros del cliente.
407        echoAndLog "${FUNCNAME}(): Updating OpenGnsys Client files."
408        rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client
409        if [ $? -ne 0 ]; then
410                errorAndLog "${FUNCNAME}(): error while updating client structure"
411                exit 1
412        fi
413        find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null
414        # Hacer coincidir las versiones de Rsync entre servidor y cliente.
415        if [ -n "$(rsync --version | awk '/version/ {if ($3>="3.1.0") print $3}')" ]; then
416                [ -e $WORKDIR/opengnsys/client/bin/rsync-3.1.0 ] && mv -f $WORKDIR/opengnsys/client/bin/rsync-3.1.0 $WORKDIR/opengnsys/client/bin/rsync
417        else
418                [ -e $WORKDIR/opengnsys/client/bin/rsync ] && mv -f $WORKDIR/opengnsys/client/bin/rsync $WORKDIR/opengnsys/client/bin/rsync-3.1.0
419        fi
420
421        # Actualizar librerías del motor de clonación.
422        echoAndLog "${FUNCNAME}(): Updating OpenGnsys Cloning Engine files."
423        rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
424        if [ $? -ne 0 ]; then
425                errorAndLog "${FUNCNAME}(): error while updating engine files"
426                exit 1
427        fi
428       
429        echoAndLog "${FUNCNAME}(): client files update success."
430}
431
432# Configurar HTTPS y exportar usuario y grupo del servicio Apache.
433function apacheConfiguration ()
434{
435        # Activar HTTPS (solo actualizando desde versiones anteriores a 1.0.2) y
436        #    activar módulo Rewrite (solo actualizaciones desde 1.0.x a 1.1.x).
437        if [ -e $APACHECFGDIR/sites-available/opengnsys.conf ]; then
438                echoAndLog "${FUNCNAME}(): Configuring Apache modules."
439                mv $APACHECFGDIR/sites-available/opengnsys.conf $APACHECFGDIR/sites-available/opengnsys
440                a2ensite default-ssl
441                a2enmod ssl
442                a2enmod rewrite
443                a2dissite opengnsys.conf
444                a2ensite opengnsys
445        elif [ -e $APACHECFGDIR/conf.modules.d ]; then
446                echoAndLog "${FUNCNAME}(): Configuring Apache modules."
447                sed -i '/rewrite/s/^#//' $APACHECFGDIR/*.conf
448        fi
449
450        # Actualizar configuración para acceso a API REST
451        #    (solo actualizaciones de 1.0.x a 1.1.x).
452        for config in $APACHECFGDIR/{,sites-available/}opengnsys.conf ]; do
453                if [ -e $config ] && ! grep -q "/rest" $config; then
454                        cat << EOT >> $config
455<Directory $INSTALL_TARGET/www/rest>
456        RewriteEngine On
457        RewriteBase /opengnsys/rest/
458        RewriteCond %{REQUEST_FILENAME} !-f
459        RewriteRule ^ index.php [QSA,L]
460</Directory>
461EOT
462                fi
463        done
464
465        # Reiniciar Apache.
466        $APACHESERV restart
467
468        # Variables de ejecución de Apache.
469        # - APACHE_RUN_USER
470        # - APACHE_RUN_GROUP
471        if [ -f $APACHECFGDIR/envvars ]; then
472                source $APACHECFGDIR/envvars
473        fi
474        APACHE_RUN_USER=${APACHE_RUN_USER:-"$APACHEUSER"}
475        APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"$APACHEGROUP"}
476}
477
478# Configurar servicio Rsync.
479function rsyncConfigure()
480{
481        local service
482
483        # Configurar acceso a Rsync.
484        if [ ! -f /etc/rsyncd.conf ]; then
485                echoAndLog "${FUNCNAME}(): Configuring Rsync service."
486                NEWFILES="$NEWFILES /etc/rsyncd.conf"
487                sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENTUSER/g" \
488                    $WORKDIR/opengnsys/repoman/etc/rsyncd.conf.tmpl > /etc/rsyncd.conf
489                # Habilitar Rsync.
490                if [ -f /etc/default/rsync ]; then
491                        perl -pi -e 's/RSYNC_ENABLE=.*/RSYNC_ENABLE=inetd/' /etc/default/rsync
492                fi
493                if [ -f $INETDCFGDIR/rsync ]; then
494                        perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/rsync
495                else
496                        cat << EOT > $INETDCFGDIR/rsync
497service rsync
498{
499        disable = no
500        socket_type = stream
501        wait = no
502        user = root
503        server = $(which rsync)
504        server_args = --daemon
505        log_on_failure += USERID
506        flags = IPv6
507}
508EOT
509                fi
510                # Activar e iniciar Rsync.
511                service="rsync"  $ENABLESERVICE
512                service="xinetd"
513                $ENABLESERVICE; $STARTSERVICE
514        fi
515}
516
517# Copiar ficheros del OpenGnsys Web Console.
518function updateWebFiles()
519{
520        local ERRCODE COMPATDIR f
521
522        echoAndLog "${FUNCNAME}(): Updating web files..."
523
524        # Copiar los ficheros nuevos conservando el archivo de configuración de acceso.
525        backupFile $INSTALL_TARGET/www/controlacceso.php
526        mv $INSTALL_TARGET/www $INSTALL_TARGET/WebConsole
527        rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/WebConsole $INSTALL_TARGET
528        ERRCODE=$?
529        mv $INSTALL_TARGET/WebConsole $INSTALL_TARGET/www
530        unzip -o $WORKDIR/opengnsys/admin/xajax_0.5_standard.zip -d $INSTALL_TARGET/www/xajax
531        unzip -o $WORKDIR/opengnsys/admin/slim-2.6.1.zip -d $INSTALL_TARGET/www/rest
532        if [ $ERRCODE != 0 ]; then
533                errorAndLog "${FUNCNAME}(): Error updating web files."
534                exit 1
535        fi
536        restoreFile $INSTALL_TARGET/www/controlacceso.php
537
538        # Cambiar acceso a protocolo HTTPS.
539        if grep -q "http://" $INSTALL_TARGET/www/controlacceso.php 2>/dev/null; then
540                echoAndLog "${FUNCNAME}(): updating web access file"
541                perl -pi -e 's!http://!https://!g' $INSTALL_TARGET/www/controlacceso.php
542                NEWFILES="$NEWFILES $INSTALL_TARGET/www/controlacceso.php"
543        fi
544
545        # Compatibilidad con dispositivos móviles.
546        COMPATDIR="$INSTALL_TARGET/www/principal"
547        for f in acciones administracion aula aulas hardwares imagenes menus repositorios softwares; do
548                sed 's/clickcontextualnodo/clicksupnodo/g' $COMPATDIR/$f.php > $COMPATDIR/$f.device.php
549        done
550        cp -a $COMPATDIR/imagenes.device.php $COMPATDIR/imagenes.device4.php
551
552        # Cambiar permisos para ficheros especiales.
553        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/images/{fotos,iconos}
554        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/tmp/
555
556        echoAndLog "${FUNCNAME}(): Web files updated successfully."
557}
558
559# Copiar carpeta de Interface
560function updateInterfaceAdm()
561{
562        local errcode=0
563
564        # Crear carpeta y copiar Interface
565        echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder"
566        mv $INSTALL_TARGET/client/interfaceAdm $INSTALL_TARGET/client/Interface
567        rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client
568        errcoce=$?
569        mv $INSTALL_TARGET/client/Interface $INSTALL_TARGET/client/interfaceAdm
570        if [ $errcode -ne 0 ]; then
571                echoAndLog "${FUNCNAME}(): error while updating admin interface"
572                exit 1
573        fi
574        chmod -R +x $INSTALL_TARGET/client/interfaceAdm
575        chown $OPENGNSYS_CLIENTUSER:$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
576        chmod 700 $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
577        echoAndLog "${FUNCNAME}(): Admin interface updated successfully."
578}
579
580# Crear documentación Doxygen para la consola web.
581function makeDoxygenFiles()
582{
583        echoAndLog "${FUNCNAME}(): Making Doxygen web files..."
584        $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \
585                        $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www
586        if [ ! -d "$INSTALL_TARGET/www/html" ]; then
587                errorAndLog "${FUNCNAME}(): unable to create Doxygen web files."
588                return 1
589        fi
590        rm -fr "$INSTALL_TARGET/www/api"
591        mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api"
592        rm -fr $INSTALL_TARGET/www/{man,perlmod,rtf}
593        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/api
594        echoAndLog "${FUNCNAME}(): Doxygen web files created successfully."
595}
596
597
598# Crea la estructura base de la instalación de opengnsys
599function createDirs()
600{
601        # Crear estructura de directorios.
602        echoAndLog "${FUNCNAME}(): creating directory paths in ${INSTALL_TARGET}"
603        local dir
604
605        mkdir -p ${INSTALL_TARGET}/{bin,doc,etc,lib,sbin,www}
606        mkdir -p ${INSTALL_TARGET}/{client,images}
607        mkdir -p ${INSTALL_TARGET}/log/clients
608        ln -fs ${INSTALL_TARGET}/log /var/log/opengnsys
609        # Detectar directorio de instalación de TFTP.
610        if [ ! -L ${INSTALL_TARGET}/tftpboot ]; then
611                for dir in /var/lib/tftpboot /srv/tftp; do
612                        [ -d $dir ] && ln -fs $dir ${INSTALL_TARGET}/tftpboot
613                done
614        fi
615        mkdir -p ${INSTALL_TARGET}/tftpboot/menu.lst
616        if [ $? -ne 0 ]; then
617                errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?"
618                return 1
619        fi
620
621        # Crear usuario ficticio.
622        if id -u $OPENGNSYS_CLIENTUSER &>/dev/null; then
623                echoAndLog "${FUNCNAME}(): user \"$OPENGNSYS_CLIENTUSER\" is already created"
624        else
625                echoAndLog "${FUNCNAME}(): creating OpenGnsys user"
626                useradd $OPENGNSYS_CLIENTUSER 2>/dev/null
627                if [ $? -ne 0 ]; then
628                        errorAndLog "${FUNCNAME}(): error creating OpenGnsys user"
629                        return 1
630                fi
631        fi
632
633        # Establecer los permisos básicos.
634        echoAndLog "${FUNCNAME}(): setting directory permissions"
635        chmod -R 775 $INSTALL_TARGET/{log/clients,images,tftpboot/menu.lst}
636        mkdir -p $INSTALL_TARGET/tftpboot/menu.lst/examples
637        ! [ -f $INSTALL_TARGET/tftpboot/menu.lst/templates/00unknown ] && mv $INSTALL_TARGET/tftpboot/menu.lst/templates/* $INSTALL_TARGET/tftpboot/menu.lst/examples
638        chown -R :$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/{log/clients,images,tftpboot/menu.lst}
639        if [ $? -ne 0 ]; then
640                errorAndLog "${FUNCNAME}(): error while setting permissions"
641                return 1
642        fi
643
644        # Mover el fichero de registro al directorio de logs.
645        echoAndLog "${FUNCNAME}(): moving update log file"
646        mv $LOG_FILE $OGLOGFILE && LOG_FILE=$OGLOGFILE
647        chmod 600 $LOG_FILE
648
649        echoAndLog "${FUNCNAME}(): directory paths created"
650        return 0
651}
652
653# Copia ficheros de configuración y ejecutables genéricos del servidor.
654function updateServerFiles()
655{
656        # No copiar ficheros del antiguo cliente Initrd
657        local SOURCES=( repoman/bin \
658                        server/bin \
659                        admin/Sources/Services/ogAdmServerAux \
660                        admin/Sources/Services/ogAdmRepoAux \
661                        server/tftpboot \
662                        installer/opengnsys_uninstall.sh \
663                        doc )
664        local TARGETS=( bin \
665                        bin \
666                        sbin/ogAdmServerAux \
667                        sbin/ogAdmRepoAux \
668                        tftpboot \
669                        lib/opengnsys_uninstall.sh \
670                        doc )
671
672        if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then
673                errorAndLog "${FUNCNAME}(): inconsistent number of array items"
674                exit 1
675        fi
676
677        echoAndLog "${FUNCNAME}(): updating files in server directories"
678        pushd $WORKDIR/opengnsys >/dev/null
679        local i
680        for (( i = 0; i < ${#SOURCES[@]}; i++ )); do
681                if [ -d "$INSTALL_TARGET/${TARGETS[i]}" ]; then
682                        rsync --exclude .svn -irplt "${SOURCES[i]}" $(dirname $(readlink -e "$INSTALL_TARGET/${TARGETS[i]}"))
683                else
684                        rsync -irplt "${SOURCES[i]}" $(readlink -m "$INSTALL_TARGET/${TARGETS[i]}")
685                fi
686        done
687        popd >/dev/null
688        NEWFILES=""             # Ficheros de configuración que han cambiado de formato.
689        if grep -q 'pxelinux.0' /etc/dhcp*/dhcpd*.conf; then
690                echoAndLog "${FUNCNAME}(): updating DHCP files"
691                perl -pi -e 's/pxelinux.0/grldr/' /etc/dhcp*/dhcpd*.conf
692                $DHCPSERV restart
693                NEWFILES="/etc/dhcp*/dhcpd*.conf"
694        fi
695        if ! diff -q $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys 2>/dev/null; then
696                echoAndLog "${FUNCNAME}(): updating new init file"
697                backupFile /etc/init.d/opengnsys
698                cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys
699                NEWFILES="$NEWFILES /etc/init.d/opengnsys"
700        fi
701        if egrep -q "(UrlMsg=.*msgbrowser.php)|(UrlMenu=http://)" $INSTALL_TARGET/client/etc/ogAdmClient.cfg 2>/dev/null; then
702                echoAndLog "${FUNCNAME}(): updating new client config file"
703                backupFile $INSTALL_TARGET/client/etc/ogAdmClient.cfg
704                perl -pi -e 's!UrlMsg=.*msgbrowser\.php!UrlMsg=http://localhost/cgi-bin/httpd-log\.sh!g; s!UrlMenu=http://!UrlMenu=https://!g' $INSTALL_TARGET/client/etc/ogAdmClient.cfg
705                NEWFILES="$NEWFILES $INSTALL_TARGET/client/etc/ogAdmClient.cfg"
706        fi
707        echoAndLog "${FUNCNAME}(): updating cron files"
708        [ ! -f /etc/cron.d/opengnsys ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/opengnsys.cron ] && $INSTALL_TARGET/bin/opengnsys.cron" > /etc/cron.d/opengnsys
709        [ ! -f /etc/cron.d/torrentcreator ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator
710        [ ! -f /etc/cron.d/torrenttracker ] && echo "5 * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-tracker ] && $INSTALL_TARGET/bin/torrent-tracker" > /etc/cron.d/torrenttracker
711        [ ! -f /etc/cron.d/imagedelete ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/deletepreimage ] && $INSTALL_TARGET/bin/deletepreimage" > /etc/cron.d/imagedelete
712        echoAndLog "${FUNCNAME}(): server files updated successfully."
713}
714
715####################################################################
716### Funciones de compilación de código fuente de servicios
717####################################################################
718
719# Mueve el fichero del nuevo servicio si es distinto al del directorio destino.
720function moveNewService()
721{
722        local service
723
724        # Recibe 2 parámetros: fichero origen y directorio destino.
725        [ $# == 2 ] || return 1
726        [ -f  $1 -a -d $2 ] || return 1
727
728        # Comparar los ficheros.
729        if ! diff -q $1 $2/$(basename $1) &>/dev/null; then
730                # Parar los servicios si fuese necesario.
731                [ -z "$NEWSERVICES" ] && service="opengnsys" $STOPSERVICE
732                # Nuevo servicio.
733                NEWSERVICES="$NEWSERVICES $(basename $1)"
734                # Mover el nuevo fichero de servicio
735                mv $1 $2
736        fi
737}
738
739
740# Recompilar y actualiza los serivicios y clientes.
741function compileServices()
742{
743        local hayErrores=0
744
745        # Compilar OpenGnsys Server
746        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Admin Server"
747        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer
748        make && moveNewService ogAdmServer $INSTALL_TARGET/sbin
749        if [ $? -ne 0 ]; then
750                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Admin Server"
751                hayErrores=1
752        fi
753        popd
754        # Compilar OpenGnsys Repository Manager
755        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Repository Manager"
756        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo
757        make && moveNewService ogAdmRepo $INSTALL_TARGET/sbin
758        if [ $? -ne 0 ]; then
759                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Repository Manager"
760                hayErrores=1
761        fi
762        popd
763        # Compilar OpenGnsys Agent
764        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Agent"
765        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent
766        make && moveNewService ogAdmAgent $INSTALL_TARGET/sbin
767        if [ $? -ne 0 ]; then
768                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Agent"
769                hayErrores=1
770        fi
771        popd
772
773        # Compilar OpenGnsys Client
774        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Client"
775        pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient
776        make && mv ogAdmClient $INSTALL_TARGET/client/bin
777        if [ $? -ne 0 ]; then
778                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Client"
779                hayErrores=1
780        fi
781        popd
782
783        return $hayErrores
784}
785
786
787####################################################################
788### Funciones instalacion cliente OpenGnsys
789####################################################################
790
791# Actualizar cliente OpenGnsys
792function updateClient()
793{
794        local DOWNLOADURL="http://$OPENGNSYS_SERVER/downloads"
795        local FILENAME=ogLive-precise-3.2.0-23-generic-r4311.iso        # 1.0.4-rc4
796        #local FILENAME=ogLive-precise-3.11.0-26-generic-r4413.iso      # 1.0.6-rc1
797        local SOURCEFILE=$DOWNLOADURL/$FILENAME
798        local TARGETFILE=$INSTALL_TARGET/lib/$FILENAME
799        local SOURCELENGTH
800        local TARGETLENGTH
801        local TMPDIR=/tmp/${FILENAME%.iso}
802        local OGINITRD=$INSTALL_TARGET/tftpboot/ogclient/oginitrd.img
803        local OGVMLINUZ=$INSTALL_TARGET/tftpboot/ogclient/ogvmlinuz
804        local SAMBAPASS
805        local KERNELVERSION
806        local APIKEY=$(php -r 'echo md5(uniqid(rand(), true));')
807
808        # Comprobar si debe actualizarse el cliente.
809        SOURCELENGTH=$(LANG=C wget --spider $SOURCEFILE 2>&1 | awk '/Length:/ {print $2}')
810        TARGETLENGTH=$(ls -l $TARGETFILE 2>/dev/null | awk '{print $5}')
811        [ -z $TARGETLENGTH ] && TARGETLENGTH=0
812        if [ "$SOURCELENGTH" != "$TARGETLENGTH" ]; then
813                echoAndLog "${FUNCNAME}(): Loading Client"
814                wget $DOWNLOADURL/$FILENAME -O $TARGETFILE
815                if [ ! -s $TARGETFILE ]; then
816                        errorAndLog "${FUNCNAME}(): Error loading OpenGnsys Client"
817                        return 1
818                fi
819                # Obtener la clave actual de acceso a Samba para restaurarla.
820                if [ -f $OGINITRD ]; then
821                        SAMBAPASS=$(gzip -dc $OGINITRD | \
822                                    cpio -i --to-stdout scripts/ogfunctions 2>&1 | \
823                                    grep "^[    ].*OPTIONS=" | \
824                                    sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/')
825                fi
826                # Montar la imagen ISO del ogclient, actualizar ficheros y desmontar.
827                echoAndLog "${FUNCNAME}(): Updatting ogclient files"
828                mkdir -p $TMPDIR
829                mount -o loop,ro $TARGETFILE $TMPDIR
830                rsync -irlt $TMPDIR/ogclient $INSTALL_TARGET/tftpboot
831                umount $TMPDIR
832                rmdir $TMPDIR
833                # Recuperar la clave de acceso a Samba.
834                if [ -n "$SAMBAPASS" ]; then
835                        echoAndLog "${FUNCNAME}(): Restoring client access key"
836                        echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | \
837                                        $INSTALL_TARGET/bin/setsmbpass
838                fi
839                # Establecer los permisos.
840                find -L $INSTALL_TARGET/tftpboot -type d -exec chmod 755 {} \;
841                find -L $INSTALL_TARGET/tftpboot -type f -exec chmod 644 {} \;
842                chown -R :$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/tftpboot/ogclient
843                chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/tftpboot/menu.lst
844               
845                # Ofrecer md5 del kernel y vmlinuz para ogupdateinitrd en cache
846                cp -av $INSTALL_TARGET/tftpboot/ogclient/ogvmlinuz* $INSTALL_TARGET/tftpboot
847                cp -av $INSTALL_TARGET/tftpboot/ogclient/oginitrd.img* $INSTALL_TARGET/tftpboot
848               
849                # Obtiene versión del Kernel del cliente (con 2 decimales).
850                KERNELVERSION=$(file -bkr $OGVMLINUZ 2>/dev/null | \
851                                awk '/Linux/ { for (i=1; i<=NF; i++)
852                                                   if ($i~/version/) {
853                                                      v=$(i+1);
854                                                      printf ("%d",v);
855                                                      sub (/[0-9]*\./,"",v);
856                                                      printf (".%02d",v)
857                                             } }')
858                # Actaulizar la base de datos adaptada al Kernel del cliente.
859                OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-postinst.sql"
860                if [ -f $OPENGNSYS_DBUPDATEFILE ]; then
861                        perl -pi -e "s/KERNELVERSION/$KERNELVERSION/g; s/APIKEY/$APIKEY/g" $OPENGNSYS_DBUPDATEFILE
862                        importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $OPENGNSYS_DBUPDATEFILE
863                fi
864
865                echoAndLog "${FUNCNAME}(): Client update successfully"
866        else
867                # Si no existe, crear el fichero de claves de Rsync.
868                if [ ! -f /etc/rsyncd.secrets ]; then
869                        echoAndLog "${FUNCNAME}(): Restoring client access key"
870                        SAMBAPASS=$(gzip -dc $OGINITRD | \
871                                    cpio -i --to-stdout scripts/ogfunctions 2>&1 | \
872                                    grep "^[    ].*OPTIONS=" | \
873                                    sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/')
874                        echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | \
875                                        $INSTALL_TARGET/bin/setsmbpass
876                else
877                        echoAndLog "${FUNCNAME}(): Client is already updated"
878                fi
879        fi
880}
881
882# Comprobar permisos y ficheros.
883function checkFiles()
884{
885        # Comprobar permisos adecuados.
886        if [ -x $INSTALL_TARGET/bin/checkperms ]; then
887                echoAndLog "${FUNCNAME}(): Checking permissions."
888                OPENGNSYS_DIR="$INSTALL_TARGET" OPENGNSYS_USER="$OPENGNSYS_CLIENTUSER" APACHE_USER="$APACHE_RUN_USER" APACHE_GROUP="$APACHE_RUN_GROUP" $INSTALL_TARGET/bin/checkperms
889        fi
890
891        # Eliminamos el fichero de estado del tracker porque es incompatible entre los distintos paquetes
892        if [ -f /tmp/dstate ]; then
893                echoAndLog "${FUNCNAME}(): Delete unused files."
894                rm -f /tmp/dstate
895        fi
896}
897
898# Resumen de actualización.
899function updateSummary()
900{
901        # Actualizar fichero de versión y revisión.
902        local VERSIONFILE="$INSTALL_TARGET/doc/VERSION.txt"
903        local REVISION=$(LANG=C svn info $SVN_URL|awk '/Rev:/ {print "r"$4}')
904
905        [ -f $VERSIONFILE ] || echo "OpenGnsys" >$VERSIONFILE
906        perl -pi -e "s/($| r[0-9]*)/ $REVISION/" $VERSIONFILE
907
908        echo
909        echoAndLog "OpenGnsys Update Summary"
910        echo       "========================"
911        echoAndLog "Project version:                  $(cat $VERSIONFILE)"
912        echoAndLog "Update log file:                  $LOG_FILE"
913        if [ -n "$NEWFILES" ]; then
914                echoAndLog "Check the new config files:       $(echo $NEWFILES)"
915        fi
916        if [ -n "$NEWSERVICES" ]; then
917                echoAndLog "New compiled services:            $(echo $NEWSERVICES)"
918                # Indicar si se debe reiniciar servicios manualmente o usando el Cron.
919                [ -f /etc/default/opengnsys ] && source /etc/default/opengnsys
920                if [ "$RUN_CRONJOB" == "no" ]; then
921                        echoAndLog "        WARNING: you must restart OpenGnsys services manually."
922                else
923                        echoAndLog "        New OpenGnsys services will be restarted by the cronjob."
924                fi
925        fi
926        echo
927}
928
929
930
931#####################################################################
932####### Proceso de actualización de OpenGnsys
933#####################################################################
934
935
936echoAndLog "OpenGnsys update begins at $(date)"
937
938pushd $WORKDIR
939
940# Comprobar si hay conexión y detectar parámetros de red por defecto.
941checkNetworkConnection
942if [ $? -ne 0 ]; then
943        errorAndLog "Error connecting to server. Causes:"
944        errorAndLog " - Network is unreachable, review devices parameters."
945        errorAndLog " - You are inside a private network, configure the proxy service."
946        errorAndLog " - Server is temporally down, try agian later."
947        exit 1
948fi
949getNetworkSettings
950
951# Comprobar auto-actualización del programa.
952if [ "$PROGRAMDIR" != "$INSTALL_TARGET/bin" ]; then
953        checkAutoUpdate
954        if [ $? -ne 0 ]; then
955                echoAndLog "OpenGnsys updater has been overwritten."
956                echoAndLog "Please, re-execute this script."
957                exit
958        fi
959fi
960
961# Detectar datos de auto-configuración del instalador.
962autoConfigure
963
964# Instalar dependencias.
965installDependencies ${DEPENDENCIES[*]}
966if [ $? -ne 0 ]; then
967        errorAndLog "Error: you may install all needed dependencies."
968        exit 1
969fi
970
971# Arbol de directorios de OpenGnsys.
972createDirs ${INSTALL_TARGET}
973if [ $? -ne 0 ]; then
974        errorAndLog "Error while creating directory paths!"
975        exit 1
976fi
977
978# Si es necesario, descarga el repositorio de código en directorio temporal
979if [ $USESVN -eq 1 ]; then
980        svnExportCode $SVN_URL
981        if [ $? -ne 0 ]; then
982                errorAndLog "Error while getting code from svn"
983                exit 1
984        fi
985else
986        ln -fs "$(dirname $PROGRAMDIR)" opengnsys
987fi
988
989# Si existe fichero de actualización de la base de datos; aplicar cambios.
990INSTVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt)
991REPOVERSION=$(awk '{print $2}' $WORKDIR/opengnsys/doc/VERSION.txt)
992if [ "$INSTVERSION" == "$REPOVERSION" ]; then
993        OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION.sql"
994else
995        OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-$REPOVERSION.sql"
996fi
997if [ -f $OPENGNSYS_DBUPDATEFILE ]; then
998        echoAndLog "Updating tables from file: $(basename $OPENGNSYS_DBUPDATEFILE)"
999        importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $OPENGNSYS_DBUPDATEFILE
1000else
1001        echoAndLog "Database unchanged."
1002fi
1003
1004# Actualizar ficheros complementarios del servidor
1005updateServerFiles
1006if [ $? -ne 0 ]; then
1007        errorAndLog "Error updating OpenGnsys Server files"
1008        exit 1
1009fi
1010
1011# Configurar Rsync.
1012rsyncConfigure
1013
1014# Actualizar ficheros del cliente
1015updateClientFiles
1016updateInterfaceAdm
1017
1018# Actualizar páqinas web
1019apacheConfiguration
1020updateWebFiles
1021if [ $? -ne 0 ]; then
1022        errorAndLog "Error updating OpenGnsys Web Admin files"
1023        exit 1
1024fi
1025# Generar páginas Doxygen para instalar en el web
1026makeDoxygenFiles
1027
1028# Recompilar y actualizar los servicios del sistema
1029compileServices
1030
1031# Actaulizar ficheros auxiliares del cliente
1032updateClient
1033if [ $? -ne 0 ]; then
1034        errorAndLog "Error updating clients"
1035        exit 1
1036fi
1037
1038# Comprobar permisos y ficheros.
1039checkFiles
1040
1041# Mostrar resumen de actualización.
1042updateSummary
1043
1044#rm -rf $WORKDIR
1045echoAndLog "OpenGnsys update finished at $(date)"
1046
1047popd
1048
Note: See TracBrowser for help on using the repository browser.