[a0867b37] | 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 |
---|
[c1e00e4] | 9 | #@version 1.0 - adaptación a OpenGnSys 1.0 |
---|
| 10 | #@author Ramón Gómez - ETSII Univ. Sevilla |
---|
| 11 | #@date 2011/03/02 |
---|
[64dd765] | 12 | #@version 1.0.1 - control de auto actualización del script |
---|
| 13 | #@author Ramón Gómez - ETSII Univ. Sevilla |
---|
| 14 | #@date 2011/05/17 |
---|
[739fb00] | 15 | #@version 1.0.2a - obtiene valor de dirección IP por defecto |
---|
| 16 | #@author Ramón Gómez - ETSII Univ. Sevilla |
---|
| 17 | #@date 2012/01/18 |
---|
[1175096] | 18 | #@version 1.0.3 - Compatibilidad con Debian y auto configuración de acceso a BD. |
---|
[7bb72f7] | 19 | #@author Ramón Gómez - ETSII Univ. Sevilla |
---|
[1175096] | 20 | #@date 2012/03/12 |
---|
[db9e706] | 21 | #@version 1.0.4 - Detector de distribución y compatibilidad con CentOS. |
---|
| 22 | #@author Ramón Gómez - ETSII Univ. Sevilla |
---|
| 23 | #@date 2012/05/04 |
---|
[a0867b37] | 24 | #*/ |
---|
| 25 | |
---|
| 26 | |
---|
[1175096] | 27 | #### AVISO: NO EDITAR variables de configuración. |
---|
| 28 | #### WARNING: DO NOT EDIT configuration variables. |
---|
| 29 | INSTALL_TARGET=/opt/opengnsys # Directorio de instalación |
---|
[295b4ab] | 30 | OPENGNSYS_CLIENTUSER="opengnsys" # Usuario Samba |
---|
| 31 | |
---|
| 32 | |
---|
[a0867b37] | 33 | # Sólo ejecutable por usuario root |
---|
[6ef01d9] | 34 | if [ "$(whoami)" != 'root' ]; then |
---|
[a0867b37] | 35 | echo "ERROR: this program must run under root privileges!!" |
---|
| 36 | exit 1 |
---|
| 37 | fi |
---|
[4e51cb0] | 38 | # Error si OpenGnSys no está instalado (no existe el directorio del proyecto) |
---|
| 39 | if [ ! -d $INSTALL_TARGET ]; then |
---|
| 40 | echo "ERROR: OpenGnSys is not installed, cannot update!!" |
---|
| 41 | exit 1 |
---|
| 42 | fi |
---|
[1175096] | 43 | # Cargar configuración de acceso a la base de datos. |
---|
| 44 | if [ -r $INSTALL_TARGET/etc/ogAdmServer.cfg ]; then |
---|
| 45 | source $INSTALL_TARGET/etc/ogAdmServer.cfg |
---|
| 46 | elif [ -r $INSTALL_TARGET/etc/ogAdmAgent.cfg ]; then |
---|
| 47 | source $INSTALL_TARGET/etc/ogAdmAgent.cfg |
---|
| 48 | fi |
---|
| 49 | OPENGNSYS_DATABASE=${OPENGNSYS_DATABASE:-"$CATALOG"} # Base datos |
---|
| 50 | OPENGNSYS_DBUSER=${OPENGNSYS_DBUSER:-"$USUARIO"} # Usuario de acceso |
---|
| 51 | OPENGNSYS_DBPASSWORD=${OPENGNSYS_DBPASSWORD:-"$PASSWORD"} # Clave del usuario |
---|
| 52 | if [ -z "$OPENGNSYS_DATABASE" -o -z "$OPENGNSYS_DBUSER" -o -z "$OPENGNSYS_DBPASSWORD" ]; then |
---|
| 53 | echo "ERROR: set OPENGNSYS_DATABASE, OPENGNSYS_DBUSER and OPENGNSYS_DBPASSWORD" |
---|
| 54 | echo " variables, and run this script again." |
---|
| 55 | fi |
---|
[a0867b37] | 56 | |
---|
| 57 | # Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1). |
---|
| 58 | PROGRAMDIR=$(readlink -e $(dirname "$0")) |
---|
[64dd765] | 59 | PROGRAMNAME=$(basename "$0") |
---|
[07c3a59] | 60 | OPENGNSYS_SERVER="www.opengnsys.es" |
---|
[a0867b37] | 61 | if [ -d "$PROGRAMDIR/../installer" ]; then |
---|
[6ef01d9] | 62 | USESVN=0 |
---|
[a0867b37] | 63 | else |
---|
[6ef01d9] | 64 | USESVN=1 |
---|
[a0867b37] | 65 | fi |
---|
[eb9424f] | 66 | SVN_URL="http://$OPENGNSYS_SERVER/svn/branches/version1.0/" |
---|
[a0867b37] | 67 | |
---|
| 68 | WORKDIR=/tmp/opengnsys_update |
---|
| 69 | mkdir -p $WORKDIR |
---|
| 70 | |
---|
| 71 | LOG_FILE=/tmp/opengnsys_update.log |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | ##################################################################### |
---|
| 76 | ####### Algunas funciones útiles de propósito general: |
---|
| 77 | ##################################################################### |
---|
[295b4ab] | 78 | |
---|
[db9e706] | 79 | # Generar variables de configuración del actualizador |
---|
| 80 | # Variables globales: |
---|
[2e38f60] | 81 | # - OSDISTRIB - distribución Linux |
---|
[db9e706] | 82 | # - DEPENDENCIES - array de dependencias que deben estar instaladas |
---|
| 83 | # - UPDATEPKGLIST, INSTALLPKGS, CHECKPKG - comandos para gestión de paquetes |
---|
[2e38f60] | 84 | # - APACHECFGDIR, APACHESERV, DHCPSERV - configuración y servicios |
---|
[db9e706] | 85 | function autoConfigure() |
---|
| 86 | { |
---|
[2e38f60] | 87 | local i |
---|
| 88 | |
---|
[db9e706] | 89 | # Detectar sistema operativo del servidor (debe soportar LSB). |
---|
| 90 | OSDISTRIB=$(lsb_release -is 2>/dev/null) |
---|
| 91 | |
---|
| 92 | # Configuración según la distribución de Linux. |
---|
| 93 | case "$OSDISTRIB" in |
---|
| 94 | Ubuntu|Debian|LinuxMint) |
---|
| 95 | DEPENDENCIES= |
---|
| 96 | UPDATEPKGLIST="apt-get update" |
---|
| 97 | INSTALLPKGS="apt-get -y install --force-yes" |
---|
| 98 | CHECKPKG="dpkg -s \$package 2>/dev/null | grep -q \"Status: install ok\"" |
---|
[2e38f60] | 99 | APACHEUSER="www-data" |
---|
| 100 | APACHEGROUP="www-data" |
---|
[db9e706] | 101 | ;; |
---|
| 102 | Fedora|CentOS) |
---|
| 103 | DEPENDENCIES= |
---|
| 104 | INSTALLPKGS="yum install -y" |
---|
| 105 | CHECKPKG="rpm -q --quiet \$package" |
---|
[2a5c1a4] | 106 | APACHEUSER="apache" |
---|
| 107 | APACHEGROUP="apache" |
---|
[db9e706] | 108 | ;; |
---|
[de8bbb1] | 109 | *) # Otras distribuciones. |
---|
[0b6304e] | 110 | ;; |
---|
[db9e706] | 111 | esac |
---|
[2e38f60] | 112 | for i in apache2 httpd; do |
---|
| 113 | [ -f /etc/$i ] && APACHECFGDIR="/etc/$i" |
---|
| 114 | [ -f /etc/init.d/$i ] && APACHESERV="/etc/init.d/$i" |
---|
| 115 | done |
---|
| 116 | for i in dhcpd dhcpd3-server isc-dhcp-server; do |
---|
| 117 | [ -f /etc/init.d/$i ] && DHCPSERV="/etc/init.d/$i" |
---|
| 118 | done |
---|
[db9e706] | 119 | } |
---|
| 120 | |
---|
| 121 | |
---|
[64dd765] | 122 | # Comprobar auto-actualización. |
---|
| 123 | function checkAutoUpdate() |
---|
| 124 | { |
---|
| 125 | local update=0 |
---|
| 126 | |
---|
| 127 | # Actaulizar el script si ha cambiado o no existe el original. |
---|
| 128 | if [ $USESVN -eq 1 ]; then |
---|
[7b0c6ff] | 129 | svn export $SVN_URL/installer/$PROGRAMNAME |
---|
[d372e6e] | 130 | if ! diff -q $PROGRAMNAME $INSTALL_TARGET/lib/$PROGRAMNAME 2>/dev/null || ! test -f $INSTALL_TARGET/lib/$PROGRAMNAME; then |
---|
[64dd765] | 131 | mv $PROGRAMNAME $INSTALL_TARGET/lib |
---|
| 132 | update=1 |
---|
| 133 | else |
---|
| 134 | rm -f $PROGRAMNAME |
---|
| 135 | fi |
---|
| 136 | else |
---|
[d372e6e] | 137 | if ! diff -q $PROGRAMDIR/$PROGRAMNAME $INSTALL_TARGET/lib/$PROGRAMNAME 2>/dev/null || ! test -f $INSTALL_TARGET/lib/$PROGRAMNAME; then |
---|
[64dd765] | 138 | cp -a $PROGRAMDIR/$PROGRAMNAME $INSTALL_TARGET/lib |
---|
| 139 | update=1 |
---|
| 140 | fi |
---|
| 141 | fi |
---|
| 142 | |
---|
| 143 | return $update |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | |
---|
[a0867b37] | 147 | function getDateTime() |
---|
| 148 | { |
---|
[5eb61a6] | 149 | date "+%Y%m%d-%H%M%S" |
---|
[a0867b37] | 150 | } |
---|
| 151 | |
---|
| 152 | # Escribe a fichero y muestra por pantalla |
---|
| 153 | function echoAndLog() |
---|
| 154 | { |
---|
[5eb61a6] | 155 | echo $1 |
---|
[6ef01d9] | 156 | DATETIME=`getDateTime` |
---|
| 157 | echo "$DATETIME;$SSH_CLIENT;$1" >> $LOG_FILE |
---|
[a0867b37] | 158 | } |
---|
| 159 | |
---|
| 160 | function errorAndLog() |
---|
| 161 | { |
---|
[5eb61a6] | 162 | echo "ERROR: $1" |
---|
| 163 | DATETIME=`getDateTime` |
---|
[6ef01d9] | 164 | echo "$DATETIME;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE |
---|
[a0867b37] | 165 | } |
---|
| 166 | |
---|
| 167 | |
---|
| 168 | ##################################################################### |
---|
| 169 | ####### Funciones de copia de seguridad y restauración de ficheros |
---|
| 170 | ##################################################################### |
---|
| 171 | |
---|
| 172 | # Hace un backup del fichero pasado por parámetro |
---|
| 173 | # deja un -last y uno para el día |
---|
| 174 | function backupFile() |
---|
| 175 | { |
---|
| 176 | if [ $# -ne 1 ]; then |
---|
| 177 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
| 178 | exit 1 |
---|
| 179 | fi |
---|
| 180 | |
---|
| 181 | local fichero=$1 |
---|
| 182 | local fecha=`date +%Y%m%d` |
---|
| 183 | |
---|
| 184 | if [ ! -f $fichero ]; then |
---|
| 185 | errorAndLog "${FUNCNAME}(): file $fichero doesn't exists" |
---|
| 186 | return 1 |
---|
| 187 | fi |
---|
| 188 | |
---|
[ebbbfc01] | 189 | echoAndLog "${FUNCNAME}(): Making $fichero back-up" |
---|
[a0867b37] | 190 | |
---|
| 191 | # realiza una copia de la última configuración como last |
---|
[6ef01d9] | 192 | cp -a $fichero "${fichero}-LAST" |
---|
[a0867b37] | 193 | |
---|
| 194 | # si para el día no hay backup lo hace, sino no |
---|
| 195 | if [ ! -f "${fichero}-${fecha}" ]; then |
---|
[6ef01d9] | 196 | cp -a $fichero "${fichero}-${fecha}" |
---|
[a0867b37] | 197 | fi |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | # Restaura un fichero desde su copia de seguridad |
---|
| 201 | function restoreFile() |
---|
| 202 | { |
---|
| 203 | if [ $# -ne 1 ]; then |
---|
| 204 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
| 205 | exit 1 |
---|
| 206 | fi |
---|
| 207 | |
---|
| 208 | local fichero=$1 |
---|
| 209 | |
---|
[ebbbfc01] | 210 | echoAndLog "${FUNCNAME}(): restoring file $fichero" |
---|
[a0867b37] | 211 | if [ -f "${fichero}-LAST" ]; then |
---|
[6ef01d9] | 212 | cp -a "$fichero-LAST" "$fichero" |
---|
[a0867b37] | 213 | fi |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | |
---|
| 217 | ##################################################################### |
---|
[295b4ab] | 218 | ####### Funciones de acceso a base de datos |
---|
| 219 | ##################################################################### |
---|
| 220 | |
---|
| 221 | # Actualizar la base datos |
---|
| 222 | function importSqlFile() |
---|
| 223 | { |
---|
| 224 | if [ $# -ne 4 ]; then |
---|
| 225 | errorAndLog "${FNCNAME}(): invalid number of parameters" |
---|
| 226 | exit 1 |
---|
| 227 | fi |
---|
| 228 | |
---|
| 229 | local dbuser="$1" |
---|
| 230 | local dbpassword="$2" |
---|
| 231 | local database="$3" |
---|
| 232 | local sqlfile="$4" |
---|
| 233 | local tmpfile=$(mktemp) |
---|
| 234 | local status |
---|
| 235 | |
---|
| 236 | if [ ! -r $sqlfile ]; then |
---|
| 237 | errorAndLog "${FUNCNAME}(): Unable to read $sqlfile!!" |
---|
| 238 | return 1 |
---|
| 239 | fi |
---|
| 240 | |
---|
| 241 | echoAndLog "${FUNCNAME}(): importing SQL file to ${database}..." |
---|
| 242 | chmod 600 $tmpfile |
---|
| 243 | sed -e "s/SERVERIP/$SERVERIP/g" -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \ |
---|
| 244 | -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" $sqlfile > $tmpfile |
---|
| 245 | mysql -u$dbuser -p"$dbpassword" --default-character-set=utf8 "$database" < $tmpfile |
---|
| 246 | status=$? |
---|
| 247 | rm -f $tmpfile |
---|
| 248 | if [ $status -ne 0 ]; then |
---|
| 249 | errorAndLog "${FUNCNAME}(): error importing $sqlfile in database $database" |
---|
| 250 | return 1 |
---|
| 251 | fi |
---|
| 252 | echoAndLog "${FUNCNAME}(): file imported to database $database" |
---|
| 253 | return 0 |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | |
---|
| 257 | ##################################################################### |
---|
[a0867b37] | 258 | ####### Funciones de instalación de paquetes |
---|
| 259 | ##################################################################### |
---|
| 260 | |
---|
| 261 | # Instalar las deependencias necesarias para el actualizador. |
---|
[64dd765] | 262 | function installDependencies() |
---|
[a0867b37] | 263 | { |
---|
[db9e706] | 264 | local package |
---|
| 265 | |
---|
[a0867b37] | 266 | if [ $# = 0 ]; then |
---|
| 267 | echoAndLog "${FUNCNAME}(): no deps needed." |
---|
[c1e00e4] | 268 | else |
---|
| 269 | while [ $# -gt 0 ]; do |
---|
[db9e706] | 270 | package="$1" |
---|
| 271 | eval $CHECKPKG || INSTALLDEPS="$INSTALLDEPS $1" |
---|
[c1e00e4] | 272 | shift |
---|
| 273 | done |
---|
| 274 | if [ -n "$INSTALLDEPS" ]; then |
---|
[db9e706] | 275 | $UPDATEPKGLIST |
---|
| 276 | $INSTALLPKGS $INSTALLDEPS |
---|
[c1e00e4] | 277 | if [ $? -ne 0 ]; then |
---|
| 278 | errorAndLog "${FUNCNAME}(): cannot install some dependencies: $INSTALLDEPS." |
---|
| 279 | return 1 |
---|
| 280 | fi |
---|
| 281 | fi |
---|
| 282 | fi |
---|
[a0867b37] | 283 | } |
---|
| 284 | |
---|
| 285 | |
---|
| 286 | ##################################################################### |
---|
| 287 | ####### Funciones para el manejo de Subversion |
---|
| 288 | ##################################################################### |
---|
| 289 | |
---|
| 290 | function svnExportCode() |
---|
| 291 | { |
---|
| 292 | if [ $# -ne 1 ]; then |
---|
| 293 | errorAndLog "${FUNCNAME}(): invalid number of parameters" |
---|
| 294 | exit 1 |
---|
| 295 | fi |
---|
| 296 | |
---|
[27dc5ff] | 297 | local url="$1" |
---|
[a0867b37] | 298 | |
---|
| 299 | echoAndLog "${FUNCNAME}(): downloading subversion code..." |
---|
| 300 | |
---|
[7ad4465] | 301 | svn checkout "${url}" opengnsys |
---|
[a0867b37] | 302 | if [ $? -ne 0 ]; then |
---|
| 303 | errorAndLog "${FUNCNAME}(): error getting code from ${url}, verify your user and password" |
---|
| 304 | return 1 |
---|
| 305 | fi |
---|
| 306 | echoAndLog "${FUNCNAME}(): subversion code downloaded" |
---|
| 307 | return 0 |
---|
| 308 | } |
---|
| 309 | |
---|
| 310 | |
---|
| 311 | ############################################################ |
---|
| 312 | ### Detectar red |
---|
| 313 | ############################################################ |
---|
| 314 | |
---|
[07c3a59] | 315 | # Comprobar si existe conexión. |
---|
| 316 | function checkNetworkConnection() |
---|
| 317 | { |
---|
| 318 | OPENGNSYS_SERVER=${OPENGNSYS_SERVER:-"www.opengnsys.es"} |
---|
| 319 | wget --spider -q $OPENGNSYS_SERVER |
---|
| 320 | } |
---|
| 321 | |
---|
[739fb00] | 322 | # Obtener los parámetros de red del servidor. |
---|
| 323 | function getNetworkSettings() |
---|
| 324 | { |
---|
| 325 | # Variables globales definidas: |
---|
| 326 | # - SERVERIP: IP local de la interfaz por defecto. |
---|
| 327 | |
---|
| 328 | local DEVICES |
---|
| 329 | local dev |
---|
| 330 | |
---|
| 331 | echoAndLog "${FUNCNAME}(): Detecting network parameters." |
---|
| 332 | DEVICES="$(ip -o link show up | awk '!/loopback/ {sub(/:.*/,"",$2); print $2}')" |
---|
| 333 | for dev in $DEVICES; do |
---|
| 334 | [ -z "$SERVERIP" ] && SERVERIP=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}') |
---|
| 335 | done |
---|
| 336 | } |
---|
| 337 | |
---|
[a0867b37] | 338 | |
---|
| 339 | ##################################################################### |
---|
| 340 | ####### Funciones específicas de la instalación de Opengnsys |
---|
| 341 | ##################################################################### |
---|
| 342 | |
---|
[45f1fe8] | 343 | # Actualizar cliente OpenGnSys |
---|
[295b4ab] | 344 | function updateClientFiles() |
---|
[45f1fe8] | 345 | { |
---|
| 346 | echoAndLog "${FUNCNAME}(): Updating OpenGnSys Client files." |
---|
| 347 | rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client |
---|
| 348 | if [ $? -ne 0 ]; then |
---|
| 349 | errorAndLog "${FUNCNAME}(): error while updating client structure" |
---|
[51b179a] | 350 | exit 1 |
---|
[45f1fe8] | 351 | fi |
---|
| 352 | find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null |
---|
| 353 | |
---|
| 354 | echoAndLog "${FUNCNAME}(): Updating OpenGnSys Cloning Engine files." |
---|
[51b179a] | 355 | rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin |
---|
[45f1fe8] | 356 | if [ $? -ne 0 ]; then |
---|
| 357 | errorAndLog "${FUNCNAME}(): error while updating engine files" |
---|
[51b179a] | 358 | exit 1 |
---|
[45f1fe8] | 359 | fi |
---|
| 360 | |
---|
[51b179a] | 361 | echoAndLog "${FUNCNAME}(): client files update success." |
---|
[45f1fe8] | 362 | } |
---|
[4e51cb0] | 363 | |
---|
[3ce53a7] | 364 | # Configurar HTTPS y exportar usuario y grupo del servicio Apache. |
---|
| 365 | function apacheConfiguration () |
---|
[4e51cb0] | 366 | { |
---|
[2e38f60] | 367 | # Activar HTTPS (solo actualizando desde versiones anteriores a 1.0.2). |
---|
| 368 | if [ -e $APACHECFGDIR/sites-available/opengnsys.conf ]; then |
---|
[3ce53a7] | 369 | echoAndLog "${FUNCNAME}(): Configuring HTTPS access..." |
---|
[2e38f60] | 370 | mv $APACHECFGDIR/sites-available/opengnsys.conf $APACHECFGDIR/sites-available/opengnsys |
---|
[3ce53a7] | 371 | a2ensite default-ssl |
---|
| 372 | a2enmod ssl |
---|
[3e24aa5] | 373 | a2dissite opengnsys.conf |
---|
[3ce53a7] | 374 | a2ensite opengnsys |
---|
[2e38f60] | 375 | $APACHESERV restart |
---|
[3ce53a7] | 376 | fi |
---|
| 377 | |
---|
| 378 | # Variables de ejecución de Apache. |
---|
[4e51cb0] | 379 | # - APACHE_RUN_USER |
---|
| 380 | # - APACHE_RUN_GROUP |
---|
[2e38f60] | 381 | if [ -f $APACHECFGDIR/envvars ]; then |
---|
| 382 | source $APACHECFGDIR/envvars |
---|
[4e51cb0] | 383 | fi |
---|
[2e38f60] | 384 | APACHE_RUN_USER=${APACHE_RUN_USER:-"$APACHEUSER"} |
---|
[de8bbb1] | 385 | APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"$APACHEGROUP"} |
---|
[4e51cb0] | 386 | } |
---|
| 387 | |
---|
[a0867b37] | 388 | # Copiar ficheros del OpenGnSys Web Console. |
---|
| 389 | function updateWebFiles() |
---|
| 390 | { |
---|
[d655cc4] | 391 | local ERRCODE |
---|
[a0867b37] | 392 | echoAndLog "${FUNCNAME}(): Updating web files..." |
---|
[d655cc4] | 393 | backupFile $INSTALL_TARGET/www/controlacceso.php |
---|
| 394 | mv $INSTALL_TARGET/www $INSTALL_TARGET/WebConsole |
---|
[1db2ed8] | 395 | rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/WebConsole $INSTALL_TARGET |
---|
[d655cc4] | 396 | ERRCODE=$? |
---|
| 397 | mv $INSTALL_TARGET/WebConsole $INSTALL_TARGET/www |
---|
[c1e00e4] | 398 | unzip -o $WORKDIR/opengnsys/admin/xajax_0.5_standard.zip -d $INSTALL_TARGET/www/xajax |
---|
[d655cc4] | 399 | if [ $ERRCODE != 0 ]; then |
---|
[a0867b37] | 400 | errorAndLog "${FUNCNAME}(): Error updating web files." |
---|
| 401 | exit 1 |
---|
| 402 | fi |
---|
[d655cc4] | 403 | restoreFile $INSTALL_TARGET/www/controlacceso.php |
---|
[a0867b37] | 404 | # Cambiar permisos para ficheros especiales. |
---|
[ebbbfc01] | 405 | chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/includes $INSTALL_TARGET/www/images/iconos |
---|
[a0867b37] | 406 | echoAndLog "${FUNCNAME}(): Web files updated successfully." |
---|
| 407 | } |
---|
| 408 | |
---|
[72134d5] | 409 | # Copiar carpeta de Interface |
---|
[64dd765] | 410 | function updateInterfaceAdm() |
---|
[72134d5] | 411 | { |
---|
[27dc5ff] | 412 | local errcode=0 |
---|
[72134d5] | 413 | |
---|
| 414 | # Crear carpeta y copiar Interface |
---|
| 415 | echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder" |
---|
| 416 | mv $INSTALL_TARGET/client/interfaceAdm $INSTALL_TARGET/client/Interface |
---|
| 417 | rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client |
---|
[27dc5ff] | 418 | errcoce=$? |
---|
[72134d5] | 419 | mv $INSTALL_TARGET/client/Interface $INSTALL_TARGET/client/interfaceAdm |
---|
[27dc5ff] | 420 | if [ $errcode -ne 0 ]; then |
---|
[72134d5] | 421 | echoAndLog "${FUNCNAME}(): error while updating admin interface" |
---|
| 422 | exit 1 |
---|
| 423 | fi |
---|
| 424 | chmod -R +x $INSTALL_TARGET/client/interfaceAdm |
---|
[b6f1726] | 425 | chown $OPENGNSYS_CLIENTUSER:$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso |
---|
[f6c1d2b] | 426 | chmod 700 $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso |
---|
[72134d5] | 427 | echoAndLog "${FUNCNAME}(): Admin interface updated successfully." |
---|
| 428 | } |
---|
[a0867b37] | 429 | |
---|
[5d6bf97] | 430 | # Crear documentación Doxygen para la consola web. |
---|
| 431 | function makeDoxygenFiles() |
---|
| 432 | { |
---|
| 433 | echoAndLog "${FUNCNAME}(): Making Doxygen web files..." |
---|
| 434 | $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \ |
---|
| 435 | $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www |
---|
| 436 | if [ ! -d "$INSTALL_TARGET/www/html" ]; then |
---|
| 437 | errorAndLog "${FUNCNAME}(): unable to create Doxygen web files." |
---|
| 438 | return 1 |
---|
| 439 | fi |
---|
[45f1fe8] | 440 | rm -fr "$INSTALL_TARGET/www/api" |
---|
[15b2a4e] | 441 | mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api" |
---|
| 442 | rm -fr $INSTALL_TARGET/www/{man,perlmod,rtf} |
---|
[5d6bf97] | 443 | chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/api |
---|
| 444 | echoAndLog "${FUNCNAME}(): Doxygen web files created successfully." |
---|
| 445 | } |
---|
| 446 | |
---|
| 447 | |
---|
[a0867b37] | 448 | # Crea la estructura base de la instalación de opengnsys |
---|
| 449 | function createDirs() |
---|
| 450 | { |
---|
[eb9424f] | 451 | # Crear estructura de directorios. |
---|
[a0867b37] | 452 | echoAndLog "${FUNCNAME}(): creating directory paths in ${INSTALL_TARGET}" |
---|
[7bb72f7] | 453 | local dir |
---|
| 454 | |
---|
[cfad47b] | 455 | mkdir -p ${INSTALL_TARGET}/{bin,doc,etc,lib,sbin,www} |
---|
| 456 | mkdir -p ${INSTALL_TARGET}/{client,images} |
---|
[a0867b37] | 457 | mkdir -p ${INSTALL_TARGET}/log/clients |
---|
[eb9424f] | 458 | ln -fs ${INSTALL_TARGET}/log /var/log/opengnsys |
---|
[7bb72f7] | 459 | # Detectar directorio de instalación de TFTP. |
---|
| 460 | if [ ! -L ${INSTALL_TARGET}/tftpboot ]; then |
---|
| 461 | for dir in /var/lib/tftpboot /srv/tftp; do |
---|
| 462 | [ -d $dir ] && ln -fs $dir ${INSTALL_TARGET}/tftpboot |
---|
| 463 | done |
---|
| 464 | fi |
---|
[cfad47b] | 465 | mkdir -p ${INSTALL_TARGET}/tftpboot/{pxelinux.cfg,menu.lst} |
---|
[a0867b37] | 466 | if [ $? -ne 0 ]; then |
---|
| 467 | errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?" |
---|
| 468 | return 1 |
---|
| 469 | fi |
---|
| 470 | |
---|
[eb9424f] | 471 | # Crear usuario ficticio. |
---|
| 472 | if id -u $OPENGNSYS_CLIENTUSER &>/dev/null; then |
---|
| 473 | echoAndLog "${FUNCNAME}(): user \"$OPENGNSYS_CLIENTUSER\" is already created" |
---|
| 474 | else |
---|
| 475 | echoAndLog "${FUNCNAME}(): creating OpenGnSys user" |
---|
| 476 | useradd $OPENGNSYS_CLIENTUSER 2>/dev/null |
---|
| 477 | if [ $? -ne 0 ]; then |
---|
| 478 | errorAndLog "${FUNCNAME}(): error creating OpenGnSys user" |
---|
| 479 | return 1 |
---|
| 480 | fi |
---|
| 481 | fi |
---|
| 482 | |
---|
| 483 | # Establecer los permisos básicos. |
---|
| 484 | echoAndLog "${FUNCNAME}(): setting directory permissions" |
---|
[cfad47b] | 485 | chmod -R 775 $INSTALL_TARGET/{log/clients,images,tftpboot/pxelinux.cfg,tftpboot/menu.lst} |
---|
| 486 | chown -R :$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/{log/clients,images,tftpboot/pxelinux.cfg,tftpboot/menu.lst} |
---|
[eb9424f] | 487 | if [ $? -ne 0 ]; then |
---|
| 488 | errorAndLog "${FUNCNAME}(): error while setting permissions" |
---|
| 489 | return 1 |
---|
| 490 | fi |
---|
| 491 | |
---|
[a0867b37] | 492 | echoAndLog "${FUNCNAME}(): directory paths created" |
---|
| 493 | return 0 |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | # Copia ficheros de configuración y ejecutables genéricos del servidor. |
---|
[64dd765] | 497 | function updateServerFiles() |
---|
[bb30a50] | 498 | { |
---|
[c1e00e4] | 499 | # No copiar ficheros del antiguo cliente Initrd |
---|
[873cf1e] | 500 | local SOURCES=( repoman/bin \ |
---|
[c1e00e4] | 501 | server/bin \ |
---|
[873cf1e] | 502 | server/tftpboot \ |
---|
[bb30a50] | 503 | installer/opengnsys_uninstall.sh \ |
---|
[873cf1e] | 504 | doc ) |
---|
| 505 | local TARGETS=( bin \ |
---|
| 506 | bin \ |
---|
| 507 | tftpboot \ |
---|
[4057c5d] | 508 | lib/opengnsys_uninstall.sh \ |
---|
[873cf1e] | 509 | doc ) |
---|
[a0867b37] | 510 | |
---|
| 511 | if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then |
---|
| 512 | errorAndLog "${FUNCNAME}(): inconsistent number of array items" |
---|
| 513 | exit 1 |
---|
| 514 | fi |
---|
| 515 | |
---|
| 516 | echoAndLog "${FUNCNAME}(): updating files in server directories" |
---|
| 517 | pushd $WORKDIR/opengnsys >/dev/null |
---|
| 518 | local i |
---|
| 519 | for (( i = 0; i < ${#SOURCES[@]}; i++ )); do |
---|
[27dc5ff] | 520 | if [ -d "$INSTALL_TARGET/${TARGETS[i]}" ]; then |
---|
[4057c5d] | 521 | rsync --exclude .svn -irplt "${SOURCES[i]}" $(dirname $(readlink -e "$INSTALL_TARGET/${TARGETS[i]}")) |
---|
[aa36857] | 522 | else |
---|
[4057c5d] | 523 | rsync --exclude .svn -irplt "${SOURCES[i]}" $(readlink -e "$INSTALL_TARGET/${TARGETS[i]}") |
---|
[aa36857] | 524 | fi |
---|
[a0867b37] | 525 | done |
---|
| 526 | popd >/dev/null |
---|
[df3cd7f] | 527 | NEWFILES="" # Ficheros de configuración que han cambiado de formato. |
---|
[f80f839] | 528 | if grep -q 'pxelinux.0' /etc/dhcp*/dhcpd*.conf; then |
---|
[df3cd7f] | 529 | echoAndLog "${FUNCNAME}(): updating DHCP files" |
---|
[f80f839] | 530 | perl -pi -e 's/pxelinux.0/grldr/' /etc/dhcp*/dhcpd*.conf |
---|
[2e38f60] | 531 | $DHCPSERV restart |
---|
[df3cd7f] | 532 | NEWFILES="/etc/dhcp*/dhcpd*.conf" |
---|
| 533 | fi |
---|
[d372e6e] | 534 | if ! diff -q $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys 2>/dev/null; then |
---|
[df3cd7f] | 535 | echoAndLog "${FUNCNAME}(): updating new init file" |
---|
| 536 | backupFile /etc/init.d/opengnsys |
---|
| 537 | cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys |
---|
| 538 | NEWFILES="$NEWFILES /etc/init.d/opengnsys" |
---|
| 539 | fi |
---|
[984093e] | 540 | if grep -q "UrlMsg=.*msgbrowser.php" $INSTALL_TARGET/client/etc/ogAdmClient.cfg 2>/dev/null; then |
---|
[df3cd7f] | 541 | echoAndLog "${FUNCNAME}(): updating new client config file" |
---|
| 542 | backupFile $INSTALL_TARGET/client/etc/ogAdmClient.cfg |
---|
| 543 | perl -pi -e 's!UrlMsg=.*msgbrowser\.php!UrlMsg=http://localhost/cgi-bin/httpd-log\.sh!g' $INSTALL_TARGET/client/etc/ogAdmClient.cfg |
---|
| 544 | NEWFILES="$NEWFILES $INSTALL_TARGET/client/etc/ogAdmClient.cfg" |
---|
[f80f839] | 545 | fi |
---|
[9ee62ad] | 546 | echoAndLog "${FUNCNAME}(): updating cron files" |
---|
[db9e706] | 547 | [ ! -f /etc/cron.d/opengnsys ] && echo "* * * * * root [ -x $INSTALL_TARGET/bin/opengnsys.cron ] && $INSTALL_TARGET/bin/opengnsys.cron" > /etc/cron.d/opengnsys |
---|
| 548 | [ ! -f /etc/cron.d/torrentcreator ] && echo "* * * * * root [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator |
---|
| 549 | [ ! -f /etc/cron.d/torrenttracker ] && echo "5 * * * * root [ -x $INSTALL_TARGET/bin/torrent-tracker ] && $INSTALL_TARGET/bin/torrent-tracker" > /etc/cron.d/torrenttracker |
---|
[da8db11] | 550 | echoAndLog "${FUNCNAME}(): server files updated successfully." |
---|
[a0867b37] | 551 | } |
---|
| 552 | |
---|
| 553 | #################################################################### |
---|
| 554 | ### Funciones de compilación de código fuente de servicios |
---|
| 555 | #################################################################### |
---|
| 556 | |
---|
[bb30a50] | 557 | # Recompilar y actualiza los serivicios y clientes. |
---|
[64dd765] | 558 | function compileServices() |
---|
[a0867b37] | 559 | { |
---|
[bb30a50] | 560 | local hayErrores=0 |
---|
| 561 | |
---|
| 562 | # Compilar OpenGnSys Server |
---|
| 563 | echoAndLog "${FUNCNAME}(): Recompiling OpenGnSys Admin Server" |
---|
| 564 | pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer |
---|
| 565 | make && mv ogAdmServer $INSTALL_TARGET/sbin |
---|
| 566 | if [ $? -ne 0 ]; then |
---|
| 567 | echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Admin Server" |
---|
| 568 | hayErrores=1 |
---|
| 569 | fi |
---|
| 570 | popd |
---|
| 571 | # Compilar OpenGnSys Repository Manager |
---|
| 572 | echoAndLog "${FUNCNAME}(): Recompiling OpenGnSys Repository Manager" |
---|
| 573 | pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo |
---|
| 574 | make && mv ogAdmRepo $INSTALL_TARGET/sbin |
---|
| 575 | if [ $? -ne 0 ]; then |
---|
| 576 | echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Repository Manager" |
---|
| 577 | hayErrores=1 |
---|
| 578 | fi |
---|
| 579 | popd |
---|
| 580 | # Compilar OpenGnSys Agent |
---|
| 581 | echoAndLog "${FUNCNAME}(): Recompiling OpenGnSys Agent" |
---|
| 582 | pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent |
---|
| 583 | make && mv ogAdmAgent $INSTALL_TARGET/sbin |
---|
| 584 | if [ $? -ne 0 ]; then |
---|
| 585 | echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Agent" |
---|
| 586 | hayErrores=1 |
---|
| 587 | fi |
---|
| 588 | popd |
---|
| 589 | |
---|
[a0867b37] | 590 | # Compilar OpenGnSys Client |
---|
[bb30a50] | 591 | echoAndLog "${FUNCNAME}(): Recompiling OpenGnSys Client" |
---|
[72134d5] | 592 | pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient |
---|
[e473667] | 593 | make && mv ogAdmClient $INSTALL_TARGET/client/bin |
---|
[a0867b37] | 594 | if [ $? -ne 0 ]; then |
---|
| 595 | echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Client" |
---|
| 596 | hayErrores=1 |
---|
| 597 | fi |
---|
| 598 | popd |
---|
| 599 | |
---|
| 600 | return $hayErrores |
---|
| 601 | } |
---|
| 602 | |
---|
| 603 | |
---|
| 604 | #################################################################### |
---|
[4e51cb0] | 605 | ### Funciones instalacion cliente OpenGnSys |
---|
[a0867b37] | 606 | #################################################################### |
---|
| 607 | |
---|
[c1e00e4] | 608 | # Actualizar nuevo cliente para OpenGnSys 1.0 |
---|
| 609 | function updateClient() |
---|
| 610 | { |
---|
[df3cd7f] | 611 | local DOWNLOADURL="http://$OPENGNSYS_SERVER/downloads" |
---|
[739fb00] | 612 | local FILENAME=ogLive-oneiric-3.0.0-14-generic-r2439.iso |
---|
[0b85cc93] | 613 | local SOURCEFILE=$DOWNLOADURL/$FILENAME |
---|
| 614 | local TARGETFILE=$INSTALL_TARGET/lib/$FILENAME |
---|
| 615 | local SOURCELENGTH |
---|
| 616 | local TARGETLENGTH |
---|
| 617 | local TMPDIR=/tmp/${FILENAME%.iso} |
---|
[a63345ac] | 618 | local OGINITRD=$INSTALL_TARGET/tftpboot/ogclient/oginitrd.img |
---|
| 619 | local SAMBAPASS |
---|
[0b85cc93] | 620 | |
---|
| 621 | # Comprobar si debe actualizarse el cliente. |
---|
[c3cc6b0] | 622 | SOURCELENGTH=$(LANG=C wget --spider $SOURCEFILE 2>&1 | awk '/Length:/ {print $2}') |
---|
[d168a46] | 623 | TARGETLENGTH=$(ls -l $TARGETFILE 2>/dev/null | awk '{print $5}') |
---|
[d4e90c1] | 624 | [ -z $TARGETLENGTH ] && TARGETLENGTH=0 |
---|
[0b85cc93] | 625 | if [ "$SOURCELENGTH" != "$TARGETLENGTH" ]; then |
---|
| 626 | echoAndLog "${FUNCNAME}(): Loading Client" |
---|
| 627 | wget $DOWNLOADURL/$FILENAME -O $TARGETFILE |
---|
| 628 | if [ ! -s $TARGETFILE ]; then |
---|
| 629 | errorAndLog "${FUNCNAME}(): Error loading OpenGnSys Client" |
---|
| 630 | return 1 |
---|
| 631 | fi |
---|
[a63345ac] | 632 | # Obtener la clave actual de acceso a Samba para restaurarla. |
---|
| 633 | if [ -f $OGINITRD ]; then |
---|
| 634 | SAMBAPASS=$(gzip -dc $OGINITRD | \ |
---|
| 635 | cpio -i --to-stdout scripts/ogfunctions 2>&1 | \ |
---|
[c3cc6b0] | 636 | grep "^[ ]*OPTIONS=" | \ |
---|
[a63345ac] | 637 | sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/') |
---|
| 638 | fi |
---|
| 639 | # Montar la imagen ISO del ogclient, actualizar ficheros y desmontar. |
---|
| 640 | echoAndLog "${FUNCNAME}(): Updatting ogclient files" |
---|
| 641 | mkdir -p $TMPDIR |
---|
| 642 | mount -o loop,ro $TARGETFILE $TMPDIR |
---|
| 643 | rsync -irlt $TMPDIR/ogclient $INSTALL_TARGET/tftpboot |
---|
| 644 | umount $TMPDIR |
---|
| 645 | rmdir $TMPDIR |
---|
| 646 | # Recuperar la clave de acceso a Samba. |
---|
| 647 | if [ -n "$SAMBAPASS" ]; then |
---|
| 648 | echoAndLog "${FUNCNAME}(): Restoring client access key" |
---|
| 649 | echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | \ |
---|
| 650 | $INSTALL_TARGET/bin/setsmbpass |
---|
| 651 | fi |
---|
| 652 | # Establecer los permisos. |
---|
| 653 | find -L $INSTALL_TARGET/tftpboot -type d -exec chmod 755 {} \; |
---|
| 654 | find -L $INSTALL_TARGET/tftpboot -type f -exec chmod 644 {} \; |
---|
| 655 | chown -R :$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/tftpboot/ogclient |
---|
| 656 | chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/tftpboot/{menu.lst,pxelinux.cfg} |
---|
[e1c01217] | 657 | |
---|
[e8963d0] | 658 | # Ofrecer md5 del kernel y vmlinuz para ogupdateinitrd en cache |
---|
[7bb72f7] | 659 | cp -av $INSTALL_TARGET/tftpboot/ogclient/ogvmlinuz* $INSTALL_TARGET/tftpboot |
---|
| 660 | cp -av $INSTALL_TARGET/tftpboot/ogclient/oginitrd.img* $INSTALL_TARGET/tftpboot |
---|
[e1c01217] | 661 | |
---|
[a63345ac] | 662 | echoAndLog "${FUNCNAME}(): Client update successfully" |
---|
[0b85cc93] | 663 | else |
---|
[a63345ac] | 664 | echoAndLog "${FUNCNAME}(): Client is already updated" |
---|
[c1e00e4] | 665 | fi |
---|
| 666 | } |
---|
[a0867b37] | 667 | |
---|
[eb9424f] | 668 | # Resumen de actualización. |
---|
| 669 | function updateSummary() |
---|
| 670 | { |
---|
| 671 | # Actualizar fichero de versión y revisión. |
---|
| 672 | local VERSIONFILE="$INSTALL_TARGET/doc/VERSION.txt" |
---|
| 673 | local REVISION=$(LANG=C svn info $SVN_URL|awk '/Revision:/ {print "r"$2}') |
---|
| 674 | |
---|
| 675 | [ -f $VERSIONFILE ] || echo "OpenGnSys" >$VERSIONFILE |
---|
| 676 | perl -pi -e "s/($| r[0-9]*)/ $REVISION/" $VERSIONFILE |
---|
| 677 | |
---|
| 678 | echo |
---|
| 679 | echoAndLog "OpenGnSys Update Summary" |
---|
[df3cd7f] | 680 | echo "========================" |
---|
| 681 | echoAndLog "Project version: $(cat $VERSIONFILE)" |
---|
| 682 | if [ -n "$NEWFILES" ]; then |
---|
| 683 | echoAndLog "Check the new config files: $(echo $NEWFILES)" |
---|
| 684 | fi |
---|
[eb9424f] | 685 | echo |
---|
| 686 | } |
---|
| 687 | |
---|
| 688 | |
---|
[a0867b37] | 689 | |
---|
| 690 | ##################################################################### |
---|
[3320409] | 691 | ####### Proceso de actualización de OpenGnSys |
---|
[a0867b37] | 692 | ##################################################################### |
---|
| 693 | |
---|
| 694 | |
---|
| 695 | echoAndLog "OpenGnSys update begins at $(date)" |
---|
| 696 | |
---|
[bb30a50] | 697 | pushd $WORKDIR |
---|
| 698 | |
---|
[27dc5ff] | 699 | # Comprobar si hay conexión y detectar parámetros de red por defecto. |
---|
| 700 | checkNetworkConnection |
---|
| 701 | if [ $? -ne 0 ]; then |
---|
| 702 | errorAndLog "Error connecting to server. Causes:" |
---|
| 703 | errorAndLog " - Network is unreachable, review devices parameters." |
---|
| 704 | errorAndLog " - You are inside a private network, configure the proxy service." |
---|
| 705 | errorAndLog " - Server is temporally down, try agian later." |
---|
| 706 | exit 1 |
---|
| 707 | fi |
---|
[739fb00] | 708 | getNetworkSettings |
---|
[27dc5ff] | 709 | |
---|
[64dd765] | 710 | # Comprobar auto-actualización del programa. |
---|
| 711 | if [ "$PROGRAMDIR" != "$INSTALL_TARGET/bin" ]; then |
---|
| 712 | checkAutoUpdate |
---|
| 713 | if [ $? -ne 0 ]; then |
---|
[f580c51] | 714 | echoAndLog "OpenGnSys updater has been overwritten." |
---|
| 715 | echoAndLog "Please, re-execute this script." |
---|
[64dd765] | 716 | exit |
---|
| 717 | fi |
---|
| 718 | fi |
---|
| 719 | |
---|
[db9e706] | 720 | # Detectar datos de auto-configuración del instalador. |
---|
| 721 | autoConfigure |
---|
| 722 | |
---|
[bb30a50] | 723 | # Instalar dependencias. |
---|
[db9e706] | 724 | installDependencies $DEPENDENCIES |
---|
[a0867b37] | 725 | if [ $? -ne 0 ]; then |
---|
| 726 | errorAndLog "Error: you may install all needed dependencies." |
---|
| 727 | exit 1 |
---|
| 728 | fi |
---|
| 729 | |
---|
| 730 | # Arbol de directorios de OpenGnSys. |
---|
| 731 | createDirs ${INSTALL_TARGET} |
---|
| 732 | if [ $? -ne 0 ]; then |
---|
| 733 | errorAndLog "Error while creating directory paths!" |
---|
| 734 | exit 1 |
---|
| 735 | fi |
---|
| 736 | |
---|
| 737 | # Si es necesario, descarga el repositorio de código en directorio temporal |
---|
| 738 | if [ $USESVN -eq 1 ]; then |
---|
| 739 | svnExportCode $SVN_URL |
---|
| 740 | if [ $? -ne 0 ]; then |
---|
| 741 | errorAndLog "Error while getting code from svn" |
---|
| 742 | exit 1 |
---|
| 743 | fi |
---|
| 744 | else |
---|
| 745 | ln -fs "$(dirname $PROGRAMDIR)" opengnsys |
---|
| 746 | fi |
---|
| 747 | |
---|
[295b4ab] | 748 | # Si existe fichero de actualización de la base de datos; aplicar cambios. |
---|
| 749 | INSTVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt) |
---|
| 750 | REPOVERSION=$(awk '{print $2}' $WORKDIR/opengnsys/doc/VERSION.txt) |
---|
| 751 | OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-$REPOVERSION.sql" |
---|
| 752 | if [ -f $OPENGNSYS_DBUPDATEFILE ]; then |
---|
| 753 | echoAndLog "Updating tables from version $INSTVERSION to $REPOVERSION" |
---|
| 754 | importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $OPENGNSYS_DBUPDATEFILE |
---|
| 755 | else |
---|
| 756 | echoAndLog "Database unchanged." |
---|
| 757 | fi |
---|
| 758 | |
---|
| 759 | # Actualizar ficheros complementarios del servidor |
---|
[a0867b37] | 760 | updateServerFiles |
---|
| 761 | if [ $? -ne 0 ]; then |
---|
[da8db11] | 762 | errorAndLog "Error updating OpenGnSys Server files" |
---|
[a0867b37] | 763 | exit 1 |
---|
| 764 | fi |
---|
| 765 | |
---|
[295b4ab] | 766 | # Actualizar ficheros del cliente |
---|
| 767 | updateClientFiles |
---|
| 768 | updateInterfaceAdm |
---|
[45f1fe8] | 769 | |
---|
[295b4ab] | 770 | # Actualizar páqinas web |
---|
[3ce53a7] | 771 | apacheConfiguration |
---|
[a0867b37] | 772 | updateWebFiles |
---|
| 773 | if [ $? -ne 0 ]; then |
---|
[da8db11] | 774 | errorAndLog "Error updating OpenGnSys Web Admin files" |
---|
[a0867b37] | 775 | exit 1 |
---|
| 776 | fi |
---|
[5d6bf97] | 777 | # Generar páginas Doxygen para instalar en el web |
---|
| 778 | makeDoxygenFiles |
---|
[a0867b37] | 779 | |
---|
[bb30a50] | 780 | # Recompilar y actualizar los servicios del sistema |
---|
| 781 | compileServices |
---|
| 782 | |
---|
| 783 | # Actaulizar ficheros auxiliares del cliente |
---|
[a0867b37] | 784 | updateClient |
---|
| 785 | if [ $? -ne 0 ]; then |
---|
| 786 | errorAndLog "Error updating clients" |
---|
| 787 | exit 1 |
---|
| 788 | fi |
---|
| 789 | |
---|
[3320409] | 790 | # Eliminamos el fichero de estado del tracker porque es incompatible entre los distintos paquetes |
---|
[ebbbfc01] | 791 | if [ -f /tmp/dstate ]; then |
---|
| 792 | rm -f /tmp/dstate |
---|
[3320409] | 793 | fi |
---|
| 794 | |
---|
[eb9424f] | 795 | # Mostrar resumen de actualización. |
---|
| 796 | updateSummary |
---|
| 797 | |
---|
[a0867b37] | 798 | #rm -rf $WORKDIR |
---|
| 799 | echoAndLog "OpenGnSys update finished at $(date)" |
---|
| 800 | |
---|
| 801 | popd |
---|
| 802 | |
---|