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