source: client/engine/PostConf.lib @ 91c9921

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 91c9921 was 6dfdc6d, checked in by ramon <ramongomez@…>, 13 years ago

#501: Nueva función ogInstallLinuxClient, que instala el cliente para gestión de sistemas Linux.

git-svn-id: https://opengnsys.es/svn/branches/version1.0@2951 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.8 KB
Line 
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#*/
27function ogInstallLinuxClient ()
28{
29# Variables locales.
30local PART MNTDIR CLIENTFILE i SBINDIR ETCDIR RCLOCAL
31# Si se solicita, mostrar ayuda.
32if [ "$*" == "help" ]; then
33    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys" \
34           "$FUNCNAME 1 1"
35    return
36fi
37
38# Error si no se reciben 2 parámetros.
39[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
40# Obtener sistema de archvios.
41PART="$(ogDiskToDev $1 $2)" || return $?
42# Comprobar si el sistema de archivos no está bloqueado.
43MNTDIR=$(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.
46CLIENTFILE=$OGLIB/ogclient/ogAdmLnxClient
47[ -f $CLIENTFILE ] || ogRaiseError $OG_ERR_FOUND "$CLIENTFILE" || return $?
48for i in /sbin /usr/sbin /usr/local/sbin; do
49    [ -d $MNTDIR/$i ] && SBINDIR=$i
50done
51[ -n "$SBINDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 sbin" || return $?
52for i in /etc /usr/local/etc; do
53    [ -d $MNTDIR/$i ] && ETCDIR=$i
54done
55[ -n "$ETCDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 etc" || return $?
56for i in $ETCDIR/rc.local $ETCDIR/rc.d/rc.local; do
57    [ -f $i ] && RCLOCAL=$i
58done
59[ -n "$RCLOCAL" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 rc.local" || return $?
60# Realizar la instalación en modo uso exclusivo.
61ogLock $1 $2
62# Copiar cliente, generar fichero de configuración e incluir en el arranque.
63cp -a $CLIENTFILE $MNTDIR/$SBINDIR
64cat > $MNTDIR/$ETCDIR/ogAdmLnxClient.cfg << EOT
65ServidorAdm=$(ogGetServerIp)
66PUERTO=2008
67IPLOCAL=$(ogGetIpAddress)
68EOT
69cp -a $MNTDIR/$RCLOCAL /tmp/rclocal
70awk -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
78rm /tmp/rclocal
79ogUnlock $1 $2
80}
81
82
Note: See TracBrowser for help on using the repository browser.