Changes between Version 2 and Version 3 of DocumentacionUsuario1.0.6/Respaldo


Ignore:
Timestamp:
Nov 17, 2015, 1:56:08 PM (8 years ago)
Author:
irina
Comment:

script sincronizacion_opengnsys: cambios para poder ejecutarlo desde el cron y control de errores al final del script

Legend:

Unmodified
Added
Removed
Modified
  • DocumentacionUsuario1.0.6/Respaldo

    v2 v3  
    273273#!/bin/bash
    274274#/**
    275 #       sincronizacion_og
     275#       sincronizacion_opengnsys
    276276#@brief sincroniza con servidor principal el directorio /opt/opengnsys, la base de datos ogAdmBD, el dhcp y la configuración PXE.
    277277#@param no
     
    412412TIME1=$SECONDS
    413413
    414 if [ "$USER" != "root" ]; then
    415     date +"%b %d %T $PROG: Error: solo ejecutable por root" >&2
     414if [ "$(whoami)" != "root" ]; then
     415    date +"%b %d %T $PROG: Error: solo ejecutable por root" | tee -a $FILESAL
    416416    exit 2
    417417fi
     
    432432echo " * Configuración:  CAMBIOIP: $CAMBIOIP, IPMASTER: $IPMASTER, IPRESPALDO: $IPRESPALDO y USERRESPALDO: $USERRESPALDO"
    433433
    434 sincronizacion_og  || date +"%b %d %T $PROG: Error en sincronizacion_opengnsys" |tee -a  $FILESAL $FILELOG
    435 sincronizacion_dhcp  || date +"%b %d %T $PROG: Error en sincronizacion_dhcp" |tee -a  $FILESAL $FILELOG
    436 sincronizacion_tftp  || date +"%b %d %T $PROG: Error en sincronizacion_tftp" |tee -a  $FILESAL $FILELOG
    437 sincronizacion_mysql  || date +"%b %d %T $PROG: Error en sincronizacion_mysql" |tee -a  $FILESAL $FILELOG
     434CORRECTO=""
     435sincronizacion_og && CORRECTO="og" || date +"%b %d %T $PROG: Error en sincronizacion_opengnsys" |tee -a  $FILESAL
     436sincronizacion_dhcp && CORRECTO="$CORRECTO dhcp" || date +"%b %d %T $PROG: Error en sincronizacion_dhcp" |tee -a  $FILESAL
     437sincronizacion_tftp && CORRECTO="$CORRECTO tftp" || date +"%b %d %T $PROG: Error en sincronizacion_tftp" |tee -a  $FILESAL
     438sincronizacion_mysql && CORRECTO="$CORRECTO mysql" || date +"%b %d %T $PROG: Error en sincronizacion_mysql" |tee -a  $FILESAL
    438439
    439440TIME=$[SECONDS-TIME1]
    440 date +"%b %d %T opengnsys $(basename $0): Respaldo de opengnsys desde servidor principal finalizado." | tee -a $FILESAL $FILELOG
    441 date +"%b %d %T opengnsys $(basename $0): Duracion de la operacion $[TIME/60]m $[TIME%60]s." | tee -a $FILESAL $FILELOG
     441if [ $CORRECTO == "og dhcp tftp mysql" ]; then
     442        date +"%b %d %T opengnsys $(basename $0): Respaldo de opengnsys desde servidor principal finalizado." | tee -a $FILESAL
     443        date +"%b %d %T opengnsys $(basename $0): Duracion de la operacion $[TIME/60]m $[TIME%60]s." | tee -a $FILESAL
     444else
     445        date +"%b %d %T opengnsys $(basename $0):  Respaldo de opengnsys desde servidor principal no realizado correctamente. Ha ocurrido un error." | tee -a $FILESAL
     446        date +"%b %d %T opengnsys $(basename $0): Sí ha ido bien el respaldo de $CORRECTO." | tee -a $FILESAL
     447fi
     448
     449
    442450
    443451# Despues del respaldo apagamos la maquina
     
    490498
    491499# Comprobamos que lo ejecute el usuario root.
    492 if [ "$USER" != "root" ]; then
    493     echo "$PROG: Error: solo ejecutable por root" >&2
     500if [ "$(whoami)" != "root" ]; then
     501    echo "$PROG: Error: solo ejecutable por root" | tee -a $FILESAL
    494502    exit 1
    495503fi