[6dfdc6d] | 1 | #!/bin/bash |
---|
| 2 | #/** |
---|
| 3 | #@file PostConf.lib |
---|
| 4 | #@brief Librería o clase PostConf |
---|
| 5 | #@class PostConf |
---|
| 6 | #@brief Funciones para la postconfiguración de sistemas operativos. |
---|
| 7 | #@version 1.0.4 |
---|
| 8 | #@warning License: GNU GPLv3+ |
---|
| 9 | #*/ |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | #/** |
---|
| 13 | # ogInstallLinuxClient int_ndisk int_filesys |
---|
| 14 | #@brief Instala el cliente OpenGnSys para sistemas operativos Linux. |
---|
| 15 | #@param int_ndisk nº de orden del disco |
---|
| 16 | #@param int_filesys nº de orden del sistema de archivos |
---|
| 17 | #@return (nada) |
---|
| 18 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 19 | #@exception OG_ERR_NOTFOUND Fichero o dispositivo no encontrado. |
---|
| 20 | #@exception OG_ERR_PARTITION Paritición o sistema de archivos incorrectos. |
---|
| 21 | #@exception OG_ERR_LOCKED Sistema de archivos bloqueado. |
---|
| 22 | #@exception OG_ERR_NOTOS Sin sistema operativo. |
---|
| 23 | #@version 1.0.4 - Primera adaptación para OpenGnSys. |
---|
| 24 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 25 | #@date 2012-04-10 |
---|
| 26 | #*/ |
---|
| 27 | function ogInstallLinuxClient () |
---|
| 28 | { |
---|
| 29 | # Variables locales. |
---|
| 30 | local PART MNTDIR CLIENTFILE i SBINDIR ETCDIR RCLOCAL |
---|
| 31 | # Si se solicita, mostrar ayuda. |
---|
| 32 | if [ "$*" == "help" ]; then |
---|
| 33 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys" \ |
---|
| 34 | "$FUNCNAME 1 1" |
---|
| 35 | return |
---|
| 36 | fi |
---|
| 37 | |
---|
| 38 | # Error si no se reciben 2 parámetros. |
---|
| 39 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 40 | # Obtener sistema de archvios. |
---|
| 41 | PART="$(ogDiskToDev $1 $2)" || return $? |
---|
| 42 | # Comprobar si el sistema de archivos no está bloqueado. |
---|
| 43 | MNTDIR=$(ogMount $1 $2) 2>/dev/null |
---|
| 44 | [ -n "$MNTDIR" ] || ogRaiseError OG_ERR_PARTITION "$1, $2" || return $? |
---|
| 45 | # Comprobar si existe el cliente y los directorios y ficheros destino. |
---|
| 46 | CLIENTFILE=$OGLIB/ogclient/ogAdmLnxClient |
---|
| 47 | [ -f $CLIENTFILE ] || ogRaiseError $OG_ERR_FOUND "$CLIENTFILE" || return $? |
---|
| 48 | for i in /sbin /usr/sbin /usr/local/sbin; do |
---|
| 49 | [ -d $MNTDIR/$i ] && SBINDIR=$i |
---|
| 50 | done |
---|
| 51 | [ -n "$SBINDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 sbin" || return $? |
---|
| 52 | for i in /etc /usr/local/etc; do |
---|
| 53 | [ -d $MNTDIR/$i ] && ETCDIR=$i |
---|
| 54 | done |
---|
| 55 | [ -n "$ETCDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 etc" || return $? |
---|
| 56 | for i in $ETCDIR/rc.local $ETCDIR/rc.d/rc.local; do |
---|
| 57 | [ -f $i ] && RCLOCAL=$i |
---|
| 58 | done |
---|
| 59 | [ -n "$RCLOCAL" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 rc.local" || return $? |
---|
| 60 | # Realizar la instalación en modo uso exclusivo. |
---|
| 61 | ogLock $1 $2 |
---|
| 62 | # Copiar cliente, generar fichero de configuración e incluir en el arranque. |
---|
| 63 | cp -a $CLIENTFILE $MNTDIR/$SBINDIR |
---|
| 64 | cat > $MNTDIR/$ETCDIR/ogAdmLnxClient.cfg << EOT |
---|
| 65 | ServidorAdm=$(ogGetServerIp) |
---|
| 66 | PUERTO=2008 |
---|
| 67 | IPLOCAL=$(ogGetIpAddress) |
---|
| 68 | EOT |
---|
| 69 | cp -a $MNTDIR/$RCLOCAL /tmp/rclocal |
---|
| 70 | awk -v sbin=$SBINDIR -v etc=$ETCDIR \ |
---|
| 71 | '{ if (/^#/) { print; } |
---|
| 72 | else { |
---|
| 73 | if (loc==0) { |
---|
| 74 | printf "%s/ogAdmLnxClient -f %s/ogAdmLnxClient.cfg &\n",sbin,etc; |
---|
| 75 | loc=1; } |
---|
| 76 | print; } |
---|
| 77 | }' /tmp/rclocal > $MNTDIR/$RCLOCAL |
---|
| 78 | rm /tmp/rclocal |
---|
| 79 | ogUnlock $1 $2 |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | |
---|