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