refs 310 273 adds ogadmclient compiltation and ipxe script generation
parent
e1f4a96ccf
commit
bb6a73ed36
|
@ -436,28 +436,10 @@ function servicesCompilation ()
|
|||
{
|
||||
local hayErrores=0
|
||||
|
||||
# Compilar OpenGnsys Server
|
||||
echoAndLog "${FUNCNAME}(): Compiling OpenGnsys Admin Server"
|
||||
pushd $WORKDIR/ogboot/admin/Sources/Services/ogAdmServer
|
||||
make && mv ogAdmServer $INSTALL_TARGET/sbin
|
||||
if [ $? -ne 0 ]; then
|
||||
echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Admin Server"
|
||||
hayErrores=1
|
||||
fi
|
||||
popd
|
||||
# Compilar OpenGnsys Agent
|
||||
echoAndLog "${FUNCNAME}(): Compiling OpenGnsys Agent"
|
||||
pushd $WORKDIR/ogboot/admin/Sources/Services/ogAdmAgent
|
||||
make && mv ogAdmAgent $INSTALL_TARGET/sbin
|
||||
if [ $? -ne 0 ]; then
|
||||
echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Agent"
|
||||
hayErrores=1
|
||||
fi
|
||||
popd
|
||||
# Compilar OpenGnsys Client
|
||||
echoAndLog "${FUNCNAME}(): Compiling OpenGnsys Admin Client"
|
||||
pushd $WORKDIR/ogboot/admin/Sources/Clients/ogAdmClient
|
||||
make && mv ogAdmClient ../../../../client/shared/bin
|
||||
pushd $WORKDIR/ogboot/sources/clients/ogAdmClient
|
||||
make && mv ogAdmClient ../../client/shared/bin
|
||||
if [ $? -ne 0 ]; then
|
||||
echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Admin Client"
|
||||
hayErrores=1
|
||||
|
@ -475,7 +457,7 @@ function copyClientFiles()
|
|||
local errstatus=0
|
||||
|
||||
echoAndLog "${FUNCNAME}(): Copying OpenGnsys Client files."
|
||||
cp -a $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client
|
||||
cp -a $WORKDIR/ogboot/client/shared/* $INSTALL_TARGET/client
|
||||
if [ $? -ne 0 ]; then
|
||||
errorAndLog "${FUNCNAME}(): error while copying client estructure"
|
||||
errstatus=1
|
||||
|
@ -483,7 +465,7 @@ function copyClientFiles()
|
|||
|
||||
echoAndLog "${FUNCNAME}(): Copying OpenGnsys Cloning Engine files."
|
||||
mkdir -p $INSTALL_TARGET/client/lib/engine/bin
|
||||
cp -a $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
|
||||
cp -a $WORKDIR/ogboot/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
|
||||
if [ $? -ne 0 ]; then
|
||||
errorAndLog "${FUNCNAME}(): error while copying engine files"
|
||||
errstatus=1
|
||||
|
@ -503,7 +485,7 @@ generate_ipxe_script() {
|
|||
|
||||
echo "Generando script IPXE..."
|
||||
ip_address_server=$(ifconfig eth0 | awk '/inet / {print $2}')
|
||||
template="etc/dhcp_boot.ipxe.tmpl"
|
||||
template="$WORKDIR/ogboot/etc/dhcp_boot.ipxe.tmpl"
|
||||
|
||||
ipxe_output="/opt/opengnsys/tftpboot/ipxe_scripts/dhcp_boot.ipxe"
|
||||
|
||||
|
@ -518,19 +500,6 @@ generate_ipxe_script() {
|
|||
|
||||
sed "s/SERVERIP/$ip_address_server/g" "$template_default" > "$default_output"
|
||||
echo "Creando ficheros MAC script"
|
||||
for client_declaration in "${CLIENTS[@]}"; do
|
||||
# Evaluar la cadena para reconstruir el array asociativo del cliente
|
||||
eval "$client_declaration"
|
||||
|
||||
hostname="${CLIENT[hostname]}"
|
||||
mac_address="${CLIENT[mac_address]}"
|
||||
ip_address="${CLIENT[ip_address]}"
|
||||
mac_address_lower=$(echo "$mac_address" | tr '[:upper:]' '[:lower:]')
|
||||
filename="01-${mac_address_lower}"
|
||||
sed "s/SERVERIP/$ip_address_server/g; s/IP_ADDRESS/$ip_address/g; s/HOSTNAME/$hostname/g; s/MAC_ADDRESS/$mac_address/g" $mac_script_template > "/opt/opengnsys/tftpboot/ipxe_scripts/$filename"
|
||||
echo "Archivo $filename creado con los parámetros modificados."
|
||||
done
|
||||
|
||||
|
||||
echo "Archivos creados correctamente."
|
||||
|
||||
|
@ -568,6 +537,46 @@ function testPxe ()
|
|||
rm -f $TFTPCFGDIR/testpxe /tmp/testpxe
|
||||
}
|
||||
|
||||
mount_NFS() {
|
||||
if sudo mount -t nfs ognartefactos.evlt.uma.es:/ /mnt; then
|
||||
echo "Sistema NFS montado correctamente."
|
||||
else
|
||||
echo "Error: No se pudo montar el sistema NFS."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ls /mnt/
|
||||
|
||||
sudo cp -r /mnt/srv/artefactos/ipxe/ /tmp
|
||||
|
||||
cd /tmp/ipxe/src
|
||||
if sudo make -j 4; then
|
||||
echo "Directorio /tmp/ipxe/src montado correctamente."
|
||||
else
|
||||
echo "Error: No se pudo montar el directorio /tmp/ipxe/src."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if sudo make bin/undionly.kpxe EMBED=/opt/opengnsys/tftpboot/ipxe_scripts/dhcp_boot.ipxe; then
|
||||
echo "Fichero de arranque montado correctamente."
|
||||
else
|
||||
echo "Error: No se pudo montar el fichero de arranque."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo cp bin/undionly.kpxe /opt/opengnsys/tftpboot
|
||||
|
||||
if sudo make bin-x86_64-efi/ipxe.efi EMBED=/opt/opengnsys/tftpboot/ipxe_scripts/dhcp_boot.ipxe; then
|
||||
echo "Fichero EFI construido correctamente."
|
||||
else
|
||||
echo "Error: No se pudo construir el fichero EFI."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo cp bin-x86_64-efi/ipxe.efi /opt/opengnsys/tftpboot
|
||||
|
||||
}
|
||||
|
||||
########################################################################
|
||||
## Configuración servicio Samba
|
||||
########################################################################
|
||||
|
@ -898,6 +907,19 @@ fi
|
|||
# Configuración de TFTP.
|
||||
tftpConfigure
|
||||
|
||||
generate_ipxe_script
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error en la generación de scripts IPXE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
mount_NFS
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error en el montaje NFS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Configuración de Samba.
|
||||
smbConfigure
|
||||
if [ $? -ne 0 ]; then
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
OpenGnsys Services for Clients README
|
||||
=======================================
|
||||
|
||||
|
||||
Este directorio contiene el código fuente de los servicios OpenGnsys específicos para clientes.
|
||||
|
||||
- ogAdmClient servicio para cliente ogLive que atiende peticiones de OpenGnsys Server
|
||||
- ogagent OGAgent: agente modular para sistemas operativos con API REST
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# makefile
|
||||
|
||||
# Nombre del proyecto
|
||||
PROYECTO := ogAdmClient
|
||||
|
||||
# Directorios y librerias
|
||||
DIRS :=
|
||||
LIBS := -static
|
||||
|
||||
# Opciones de compilacion
|
||||
OPCS := -m32 -O0 -g -Wall # Depuracion
|
||||
#OPCS := -m32 -O3 -Wall # Optimizacion
|
||||
|
||||
# Ficheros objetos
|
||||
OBJS := sources/ogAdmClient.o
|
||||
|
||||
all: $(PROYECTO)
|
||||
|
||||
$(PROYECTO): $(OBJS)
|
||||
gcc $(OPCS) $(DIRS) $(LIBS) $(OBJS) -o $(PROYECTO)
|
||||
# strip $(PROYECTO) # Optimizacion
|
||||
|
||||
clean:
|
||||
rm -f $(PROYECTO) $(OBJS)
|
||||
|
||||
sources/%.o: sources/%.c
|
||||
gcc $(OPCS) -I ../../Includes -c -o"$@" "$<"
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
ServidorAdm=SERVERIP
|
||||
PUERTO=2008
|
||||
PATHINTERFACE=/opt/opengnsys/interfaceAdm
|
||||
UrlMenu=OPENGNSYSURL/varios/menubrowser.php
|
||||
UrlMsg=http://localhost/cgi-bin/httpd-log.sh
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,183 @@
|
|||
// ********************************************************************************************************
|
||||
// Cliernte: ogAdmClient
|
||||
// Autor: José Manuel Alonso (E.T.S.I.I.) Universidad de Sevilla
|
||||
// Fecha Creación: Marzo-2010
|
||||
// Fecha Última modificación: Marzo-2010
|
||||
// Nombre del fichero: ogAdmClient.h
|
||||
// Descripción :Este fichero implementa el cliente general del sistema
|
||||
// ********************************************************************************************************
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <signal.h>
|
||||
#include "ogAdmLib.h"
|
||||
// ________________________________________________________________________________________________________
|
||||
// Variables globales
|
||||
// ________________________________________________________________________________________________________
|
||||
char *idordenador; // Identificador del ordenador
|
||||
char *nombreordenador; // Nombre del ordenador
|
||||
char *cache; // Tamaño de la caché
|
||||
char *idproautoexec; // Identificador del procedimiento de autoexec
|
||||
char *idcentro; // Identificador de la Unidad Organizativa
|
||||
char *idaula; // Identificador del aula
|
||||
char IPlocal[LONIP]; // Ip local
|
||||
|
||||
char servidoradm[LONPRM]; // Dirección IP del servidor de administración
|
||||
char puerto[LONPRM]; // Puerto de comunicación
|
||||
char pathinterface[LONPRM]; // Path donde está la interface entre la administración y el módulo de clonación
|
||||
|
||||
char interface[LONFUN]; // Nombre del módulo,función o script de la interface con el módulo de administración
|
||||
char parametros[LONSTD]; // Parámetros para la llamada
|
||||
int herror;
|
||||
|
||||
BOOLEAN CMDPTES; // Para bucle de comandos pendientes
|
||||
|
||||
|
||||
char urlmenu[MAXLONURL]; // Url de la pagina de menu para el browser
|
||||
char urlmsg[MAXLONURL]; // Url de la página de mensajed para el browser
|
||||
|
||||
|
||||
typedef struct{ // Estructura usada para referenciar las funciones que procesan las tramas
|
||||
char nf[LONFUN]; // Nombre de la función
|
||||
BOOLEAN (*fptr)(TRAMA*); // Puntero a la función que procesa la trama
|
||||
}MSGFUN;
|
||||
MSGFUN tbfuncionesClient[MAXIMAS_FUNCIONES];
|
||||
// ________________________________________________________________________________________________________
|
||||
// Tabla de errores de la ejecución de los scripts
|
||||
// ________________________________________________________________________________________________________
|
||||
char* tbErroresScripts[]={"Se han generado errores desconocidos. No se puede continuar la ejecución de este módulo",\
|
||||
"001-Formato de ejecución incorrecto.",\
|
||||
"002-Fichero o dispositivo no encontrado",\
|
||||
"003-Error en partición de disco",\
|
||||
"004-Partición o fichero bloqueado",\
|
||||
"005-Error al crear o restaurar una imagen",\
|
||||
"006-Sin sistema operativo",\
|
||||
"007-Programa o función BOOLEAN no ejecutable",\
|
||||
"008-Error en la creación del archivo de eco para consola remota",\
|
||||
"009-Error en la lectura del archivo temporal de intercambio",\
|
||||
"010-Error al ejecutar la llamada a la interface de administración",\
|
||||
"011-La información retornada por la interface de administración excede de la longitud permitida",\
|
||||
"012-Error en el envío de fichero por la red",\
|
||||
"013-Error en la creación del proceso hijo",\
|
||||
"014-Error de escritura en destino",\
|
||||
"015-Sin Cache en el Cliente",\
|
||||
"016-No hay espacio en la cache para almacenar fichero-imagen",\
|
||||
"017-Error al Reducir el Sistema Archivos",\
|
||||
"018-Error al Expandir el Sistema Archivos",\
|
||||
"019-Valor fuera de rango o no válido.",\
|
||||
"020-Sistema de archivos desconocido o no se puede montar",\
|
||||
"021-Error en partición de caché local",\
|
||||
"022-El disco indicado no contiene una particion GPT",\
|
||||
"023-Error no definido",\
|
||||
"024-Error no definido",\
|
||||
"025-Error no definido",\
|
||||
"026-Error no definido",\
|
||||
"027-Error no definido",\
|
||||
"028-Error no definido",\
|
||||
"029-Error no definido",\
|
||||
"030-Error al restaurar imagen - Imagen mas grande que particion",\
|
||||
"031-Error al realizar el comando updateCache",\
|
||||
"032-Error al formatear",\
|
||||
"033-Archivo de imagen corrupto o de otra versión de partclone",\
|
||||
"034-Error no definido",\
|
||||
"035-Error no definido",\
|
||||
"036-Error no definido",\
|
||||
"037-Error no definido",\
|
||||
"038-Error no definido",\
|
||||
"039-Error no definido",\
|
||||
"040-Error imprevisto no definido",\
|
||||
"041-Error no definido",\
|
||||
"042-Error no definido",\
|
||||
"043-Error no definido",\
|
||||
"044-Error no definido",\
|
||||
"045-Error no definido",\
|
||||
"046-Error no definido",\
|
||||
"047-Error no definido",\
|
||||
"048-Error no definido",\
|
||||
"049-Error no definido",\
|
||||
"050-Error en la generación de sintaxis de transferenica unicast",\
|
||||
"051-Error en envio UNICAST de una particion",\
|
||||
"052-Error en envio UNICAST de un fichero",\
|
||||
"053-Error en la recepcion UNICAST de una particion",\
|
||||
"054-Error en la recepcion UNICAST de un fichero",\
|
||||
"055-Error en la generacion de sintaxis de transferenica Multicast",\
|
||||
"056-Error en envio MULTICAST de un fichero",\
|
||||
"057-Error en la recepcion MULTICAST de un fichero",\
|
||||
"058-Error en envio MULTICAST de una particion",\
|
||||
"059-Error en la recepcion MULTICAST de una particion",\
|
||||
"060-Error en la conexion de una sesion UNICAST|MULTICAST con el MASTER",\
|
||||
"061-Error no definido",\
|
||||
"062-Error no definido",\
|
||||
"063-Error no definido",\
|
||||
"064-Error no definido",\
|
||||
"065-Error no definido",\
|
||||
"066-Error no definido",\
|
||||
"067-Error no definido",\
|
||||
"068-Error no definido",\
|
||||
"069-Error no definido",\
|
||||
"070-Error al montar una imagen sincronizada.",\
|
||||
"071-Imagen no sincronizable (es monolitica).",\
|
||||
"072-Error al desmontar la imagen.",\
|
||||
"073-No se detectan diferencias entre la imagen basica y la particion.",\
|
||||
"074-Error al sincronizar, puede afectar la creacion/restauracion de la imagen.",\
|
||||
"Error desconocido "
|
||||
};
|
||||
#define MAXERRORSCRIPT 74 // Error máximo cometido
|
||||
// ________________________________________________________________________________________________________
|
||||
// Prototipo de funciones
|
||||
// ________________________________________________________________________________________________________
|
||||
BOOLEAN autoexecCliente(TRAMA*);
|
||||
BOOLEAN RESPUESTA_AutoexecCliente(TRAMA*);
|
||||
void procesaComandos(TRAMA*);
|
||||
|
||||
BOOLEAN tomaConfiguracion(char*);
|
||||
BOOLEAN tomaIPlocal(void);
|
||||
void scriptLog(const char *,int );
|
||||
|
||||
BOOLEAN gestionaTrama(TRAMA *);
|
||||
BOOLEAN inclusionCliente();
|
||||
char* LeeConfiguracion();
|
||||
BOOLEAN RESPUESTA_InclusionCliente(TRAMA *);
|
||||
|
||||
BOOLEAN comandosPendientes(TRAMA*);
|
||||
BOOLEAN NoComandosPtes(TRAMA *);
|
||||
|
||||
BOOLEAN respuestaEjecucionComando(TRAMA *,int,char*);
|
||||
BOOLEAN Sondeo(TRAMA *);
|
||||
BOOLEAN Actualizar(TRAMA *);
|
||||
int Purgar(TRAMA* );
|
||||
|
||||
BOOLEAN ConsolaRemota(TRAMA*);
|
||||
|
||||
BOOLEAN Arrancar(TRAMA *);
|
||||
BOOLEAN Apagar(TRAMA *);
|
||||
BOOLEAN Reiniciar(TRAMA *);
|
||||
BOOLEAN IniciarSesion(TRAMA *);
|
||||
BOOLEAN CrearImagen(TRAMA *);
|
||||
BOOLEAN CrearImagenBasica(TRAMA *);
|
||||
BOOLEAN CrearSoftIncremental(TRAMA*);
|
||||
|
||||
BOOLEAN InventarioHardware(TRAMA *);
|
||||
BOOLEAN InventariandoSoftware(TRAMA *,BOOLEAN,char*);
|
||||
BOOLEAN EjecutarScript(TRAMA *);
|
||||
BOOLEAN ejecutaArchivo(char*,TRAMA*);
|
||||
|
||||
BOOLEAN cuestionCache(char*);
|
||||
int cargaPaginaWeb(char *);
|
||||
void muestraMenu(void);
|
||||
void muestraMensaje(int idx,char*);
|
||||
|
||||
BOOLEAN enviaMensajeServidor(SOCKET *,TRAMA *,char);
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue