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 | #@version 1.0.4 - Primera adaptación para OpenGnSys. |
---|
23 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
24 | #@date 2012-04-10 |
---|
25 | #*/ |
---|
26 | function ogInstallLinuxClient () |
---|
27 | { |
---|
28 | # Variables locales. |
---|
29 | local PART MNTDIR CLIENTFILE i SBINDIR ETCDIR RCLOCAL |
---|
30 | # Si se solicita, mostrar ayuda. |
---|
31 | if [ "$*" == "help" ]; then |
---|
32 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys" \ |
---|
33 | "$FUNCNAME 1 1" |
---|
34 | return |
---|
35 | fi |
---|
36 | |
---|
37 | # Error si no se reciben 2 parámetros. |
---|
38 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
39 | # Obtener sistema de archvios. |
---|
40 | PART="$(ogDiskToDev $1 $2)" || return $? |
---|
41 | # Comprobar si el sistema de archivos no está bloqueado. |
---|
42 | MNTDIR=$(ogMount $1 $2) 2>/dev/null |
---|
43 | [ -n "$MNTDIR" ] || ogRaiseError OG_ERR_PARTITION "$1, $2" || return $? |
---|
44 | # Comprobar si existe el cliente y los directorios y ficheros destino. |
---|
45 | CLIENTFILE=$OGLIB/ogclient/ogAdmLnxClient |
---|
46 | [ -f $CLIENTFILE ] || ogRaiseError $OG_ERR_FOUND "$CLIENTFILE" || return $? |
---|
47 | for i in /sbin /usr/sbin /usr/local/sbin; do |
---|
48 | [ -d $MNTDIR/$i ] && SBINDIR=$i |
---|
49 | done |
---|
50 | [ -n "$SBINDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 sbin" || return $? |
---|
51 | for i in /etc /usr/local/etc; do |
---|
52 | [ -d $MNTDIR/$i ] && ETCDIR=$i |
---|
53 | done |
---|
54 | [ -n "$ETCDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 etc" || return $? |
---|
55 | for i in $ETCDIR/rc.local $ETCDIR/rc.d/rc.local; do |
---|
56 | [ -f $i ] && RCLOCAL=$i |
---|
57 | done |
---|
58 | [ -n "$RCLOCAL" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 rc.local" || return $? |
---|
59 | # Realizar la instalación en modo uso exclusivo. |
---|
60 | ogLock $1 $2 |
---|
61 | # Copiar cliente, generar fichero de configuración e incluir en el arranque. |
---|
62 | cp -a $CLIENTFILE $MNTDIR/$SBINDIR |
---|
63 | cat > $MNTDIR/$ETCDIR/ogAdmLnxClient.cfg << EOT |
---|
64 | ServidorAdm=$(ogGetServerIp) |
---|
65 | PUERTO=2008 |
---|
66 | IPLOCAL=$(ogGetIpAddress) |
---|
67 | EOT |
---|
68 | cp -a $MNTDIR/$RCLOCAL /tmp/rclocal |
---|
69 | awk -v sbin=$SBINDIR -v etc=$ETCDIR \ |
---|
70 | '{ if (/^#/) { print; } |
---|
71 | else { |
---|
72 | if (loc==0) { |
---|
73 | printf "%s/ogAdmLnxClient -f %s/ogAdmLnxClient.cfg &\n",sbin,etc; |
---|
74 | loc=1; } |
---|
75 | print; } |
---|
76 | }' /tmp/rclocal > $MNTDIR/$RCLOCAL |
---|
77 | rm /tmp/rclocal |
---|
78 | ogUnlock $1 $2 |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | #/** |
---|
83 | # ogInstallWindowsClient int_ndisk int_filesys |
---|
84 | #@brief Instala el cliente OpenGnSys para sistemas operativos Windows. |
---|
85 | #@param int_ndisk nº de orden del disco |
---|
86 | #@param int_filesys nº de orden del sistema de archivos |
---|
87 | #@return (nada) |
---|
88 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
89 | #@exception OG_ERR_NOTFOUND Fichero o dispositivo no encontrado. |
---|
90 | #@exception OG_ERR_PARTITION Paritición o sistema de archivos incorrectos. |
---|
91 | #@exception OG_ERR_LOCKED Sistema de archivos bloqueado. |
---|
92 | #@version 1.0.4 - Primera adaptación para OpenGnSys. |
---|
93 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
94 | #@date 2012-04-11 |
---|
95 | #*/ |
---|
96 | function ogInstallWindowsClient () |
---|
97 | { |
---|
98 | # Variables locales. |
---|
99 | local PART MNTDIR CLIENTFILE i SBINDIR ETCDIR RCLOCAL |
---|
100 | # Si se solicita, mostrar ayuda. |
---|
101 | if [ "$*" == "help" ]; then |
---|
102 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys" \ |
---|
103 | return |
---|
104 | fi |
---|
105 | |
---|
106 | # Error si no se reciben 2 parámetros. |
---|
107 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
108 | # Obtener sistema de archvios. |
---|
109 | PART="$(ogDiskToDev $1 $2)" || return $? |
---|
110 | # Comprobar si el sistema de archivos no está bloqueado. |
---|
111 | MNTDIR=$(ogMount $1 $2) 2>/dev/null |
---|
112 | [ -n "$MNTDIR" ] || ogRaiseError OG_ERR_PARTITION "$1, $2" || return $? |
---|
113 | # Comprobar si existe el cliente y los directorios y ficheros destino. |
---|
114 | CLIENTFILE=$OGLIB/ogclient/ogAdmWinClient.exe |
---|
115 | [ -f $CLIENTFILE ] || ogRaiseError $OG_ERR_FOUND "$CLIENTFILE" || return $? |
---|
116 | for i in winnt windows; do |
---|
117 | DIR=$(ogGetPath $MNTDIR/$i) |
---|
118 | [ -n "$DIR" ] && WINDIR=$DIR |
---|
119 | done |
---|
120 | [ -n "$WINDIR " ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 windows" || return $? |
---|
121 | # Realizar la instalación en modo uso exclusivo. |
---|
122 | ogLock $1 $2 |
---|
123 | # Copiar cliente, generar fichero de configuración e incluir en el arranque. |
---|
124 | cp -a $CLIENTFILE "$WINDIR" |
---|
125 | ogInstallMiniSetup $MNTDIR ogclient.cmd |
---|
126 | ogAddCmd $MNTDIR ogclient.cmd "ogAdmWinClient -install -s $(ogGetServerIp) -p 2008 -i $(ogGetIpAddress)" |
---|
127 | ogUnlock $1 $2 |
---|
128 | } |
---|
129 | |
---|