Compare commits
32 Commits
jenkins_up
...
main
Author | SHA1 | Date |
---|---|---|
|
29376ab546 | |
|
14c1c4d54b | |
|
1223a6d829 | |
|
ca779b2a65 | |
|
e248b328c7 | |
|
a2c7501384 | |
|
0b86d36c20 | |
|
05540ffc61 | |
|
63df8ff854 | |
|
c60c14ea97 | |
|
283b836a07 | |
|
383b47798f | |
|
0976f50056 | |
|
8987169aab | |
|
2af4b40d22 | |
|
7025eebc52 | |
|
e872dd0c82 | |
|
b7f7915d18 | |
|
1c7dbcbcd9 | |
|
3d8f0c967d | |
|
b9e200a391 | |
|
975dfef76f | |
|
bffdaeae79 | |
|
d95a956972 | |
|
599c0d0428 | |
|
54582427ad | |
|
b25c336359 | |
|
226fd17763 | |
|
6691845345 | |
|
8b4feb1e46 | |
|
e522ce29b1 | |
|
14f1fb4076 |
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -2,6 +2,17 @@
|
|||
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
## [0.7.0] - 2024-03-26
|
||||
### Changed
|
||||
- Updated files location
|
||||
|
||||
## [0.6.3] - 2025-03-19
|
||||
### Changed
|
||||
- Jenkinsfile to upload debian packages
|
||||
|
||||
## [0.6.2] - 2025-03-19
|
||||
### Changed
|
||||
- Jenkinsfile to upload debian packages
|
||||
|
||||
## [0.6.1] - 2025-02-25
|
||||
|
||||
|
@ -54,4 +65,4 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
- Añade logs para todos los endpoints siguiendo un formato JSON preestablecido.
|
||||
|
||||
### Changed
|
||||
- Actualiza `monolog.yaml` para enviar logs al `journal` de la máquina.
|
||||
- Actualiza `monolog.yaml` para enviar logs al `journal` de la máquina.
|
||||
|
|
|
@ -48,16 +48,50 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Generate Changelog (Nightly)'){
|
||||
when {
|
||||
branch 'main'
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
def devName = params.DEV_NAME ? params.DEV_NAME : env.DEFAULT_DEV_NAME
|
||||
def devEmail = params.DEV_EMAIL ? params.DEV_EMAIL : env.DEFAULT_DEV_EMAIL
|
||||
generateDebianChangelog(env.BUILD_DIR, devName, devEmail,'nightly')
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
steps {
|
||||
dir("${env.BUILD_DIR}") {
|
||||
sh '''
|
||||
dpkg-buildpackage -us -uc
|
||||
mkdir -p ../artifacts && mv ../*.deb ../*.changes ../*.buildinfo ../artifacts/
|
||||
ssh aptly@172.17.8.68 "rm -rf /var/tmp/opengnsys/debian-repo && mkdir -p /var/tmp/opengnsys/debian-repo"
|
||||
scp -r ../artifacts/* aptly@172.17.8.68:/var/tmp/opengnsys/debian-repo/
|
||||
'''
|
||||
script {
|
||||
construirPaquete(env.BUILD_DIR, "../artifacts", "172.17.8.68", "/var/tmp/opengnsys/debian-repo/ogboot")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ('Publish to Debian Repository') {
|
||||
when {
|
||||
expression {
|
||||
return env.TAG_NAME != null
|
||||
}
|
||||
}
|
||||
agent { label 'debian-repo' }
|
||||
steps {
|
||||
script {
|
||||
// Construir el patrón de versión esperado en el nombre del paquete
|
||||
def versionPattern = "${env.TAG_NAME}-${env.BUILD_NUMBER}"
|
||||
publicarEnAptly('/var/tmp/opengnsys/debian-repo/ogboot', 'opengnsys-devel', versionPattern)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ('Publish to Debian Repository (Nightly)') {
|
||||
when {
|
||||
branch 'main'
|
||||
}
|
||||
agent { label 'debian-repo' }
|
||||
steps {
|
||||
script {
|
||||
// Construir el patrón de versión esperado en el nombre del paquete
|
||||
def versionPattern = "-${env.BUILD_NUMBER}~nightly"
|
||||
publicarEnAptly('/var/tmp/opengnsys/debian-repo/ogboot', 'nightly', versionPattern)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,10 +102,3 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
// stage ('Publish to Debian Repository') {
|
||||
// agent { label 'debian-repo' }
|
||||
// steps {
|
||||
// sh "aptly repo add opengnsys-devel /var/tmp/opengnsys/debian-repo/*.deb"
|
||||
// }
|
||||
// }
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
|
||||
parameters:
|
||||
tftpboot_dir: '%kernel.project_dir%/tftpboot'
|
||||
tftpboot_dir: '%kernel.project_dir%/../tftpboot'
|
||||
services:
|
||||
# default configuration for services in *this* file
|
||||
_defaults:
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
use App\Kernel;
|
||||
|
||||
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
|
||||
|
||||
return function (array $context) {
|
||||
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
|
||||
};
|
Binary file not shown.
|
@ -1484,7 +1484,6 @@ public function createBootFile(Request $request): JsonResponse
|
|||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
$templateName = $data['template_name'] ?? null;
|
||||
$mac = $this->validateAndFormatMac($data['mac'] ?? null);
|
||||
//Si nos pasan el puerto se lo quitamos ya que server_ip siempre tirara por Samba
|
||||
|
@ -1642,6 +1641,49 @@ public function createBootFile(Request $request): JsonResponse
|
|||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
return new JsonResponse(['error' => 'FAILED_TO_CREATE_PXE_FILE', 'message' => 'Error al crear el archivo PXE'], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
// Sustituir en la plantilla los marcadores
|
||||
$templateCacheDir = $this->tftpbootDir . '/menu.lst';
|
||||
$templateCachePath = $templateCacheDir . '/templateCache';
|
||||
$templateCacheContent = file_get_contents($templateCachePath);
|
||||
$grubContent = str_replace(
|
||||
['__INFOHOST__', '__OGLIVE__'],
|
||||
[$kernelArgs, basename($ogLiveDir)],
|
||||
$templateCacheContent
|
||||
);
|
||||
|
||||
// Nombre del archivo de arranque por cache
|
||||
$pxeFileNameCache = '01-' . $mac;
|
||||
$pxeFilePathCache = $templateCacheDir . '/' . $pxeFileNameCache;
|
||||
// Crear el archivo de arranque por cache
|
||||
if (file_put_contents($pxeFilePathCache, $grubContent) === false) {
|
||||
$httpCode = '500';
|
||||
$this->logger->error(json_encode([
|
||||
'severity' => 'ERROR',
|
||||
'operation' => $operation,
|
||||
'component' => $component,
|
||||
'http_code' => $httpCode,
|
||||
'desc' => 'Failed to create cache PXE file.'
|
||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
return new JsonResponse(['error' => 'FAILED_TO_CREATE_CACHE_PXE_FILE', 'message' => 'Error al crear el archivo de caché PXE'], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
// Creación de fichero de arranque por cache
|
||||
$cacheFilePath = $this->tftpbootDir . '/menu.lst/' . $pxeFileName;
|
||||
if (file_put_contents($cacheFilePath, $grubContent) === false) {
|
||||
$httpCode = '500';
|
||||
$this->logger->error(json_encode([
|
||||
'severity' => 'ERROR',
|
||||
'operation' => $operation,
|
||||
'component' => $component,
|
||||
'http_code' => $httpCode,
|
||||
'desc' => 'Failed to create cache PXE file.'
|
||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
return new JsonResponse(['error' => 'FAILED_TO_CREATE_CACHE_PXE_FILE', 'message' => 'Error al crear el archivo de caché PXE'], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
$httpCode = '200';
|
||||
$this->logger->info(json_encode([
|
||||
'severity' => 'INFO',
|
|
@ -30,8 +30,8 @@ class CurlRequestService
|
|||
public function callOgLive($parameter)
|
||||
{
|
||||
// Ruta completa al script oglivecli
|
||||
$ogLiveCliPath = sprintf("%s/bin/oglivecli", dirname(dirname(dirname(__DIR__))));
|
||||
|
||||
// $ogLiveCliPath = sprintf("%s/bin/oglivecli", dirname(dirname(dirname(__DIR__))));
|
||||
$ogLiveCliPath = sprintf("%s/../../../../bin/oglivecli", __DIR__);
|
||||
// Dividir el parámetro en acción y argumentos
|
||||
$args = array_map('trim', explode(' ', $parameter));
|
||||
$action = array_shift($args);
|
|
@ -1,85 +0,0 @@
|
|||
import os
|
||||
import socket
|
||||
import json
|
||||
import subprocess
|
||||
import logging
|
||||
import stat
|
||||
|
||||
# Configuración de logging
|
||||
logging.basicConfig(level=logging.INFO, filename='/var/log/oglive_daemon.log', filemode='a', format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
def handle_command(command):
|
||||
action = command.get('action')
|
||||
args = command.get('args', [])
|
||||
cleaned_args = [arg.strip('\'"') for arg in args]
|
||||
logging.info(f'Handling command: {action} with args: {cleaned_args}')
|
||||
|
||||
try:
|
||||
if action in ['config', 'install', 'download', 'show', 'check', 'uninstall', 'disk_usage','list_installed_oglives','get_info','get_default','set_default','check_services_status']:
|
||||
command_to_run = ['sudo', '/opt/ogboot/bin/oglivecli', action] + cleaned_args
|
||||
logging.info(f'Running command: {" ".join(command_to_run)}')
|
||||
process = subprocess.Popen(command_to_run, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
stdout, stderr = process.communicate()
|
||||
logging.info(f'Command stdout: {stdout}')
|
||||
logging.error(f'Command stderr: {stderr}')
|
||||
|
||||
# Asumimos que `stdout` contendrá el JSON válido
|
||||
try:
|
||||
json_output = json.loads(stdout)
|
||||
return {"success": True, "output": json_output}
|
||||
except json.JSONDecodeError as e:
|
||||
logging.error(f'Error parsing JSON: {e} - Raw output: {stdout}')
|
||||
return {"success": False, "error": f'Error parsing JSON: {str(e)} - Raw output: {stdout}'}
|
||||
|
||||
else:
|
||||
return {"success": False, "error": "Unknown command"}
|
||||
except Exception as e:
|
||||
logging.error(f'Error handling command {action}: {e}')
|
||||
return {"success": False, "error": str(e)}
|
||||
|
||||
def main():
|
||||
# Crea el directorio si no existe
|
||||
if not os.path.exists('/var/run/oglive'):
|
||||
os.makedirs('/var/run/oglive', exist_ok=True)
|
||||
|
||||
socket_path = '/var/run/oglive/oglive_daemon.sock'
|
||||
|
||||
# Elimina el socket si existe
|
||||
if os.path.exists(socket_path):
|
||||
os.remove(socket_path)
|
||||
|
||||
server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
server.bind(socket_path)
|
||||
|
||||
# Establece los permisos del socket
|
||||
os.chmod(socket_path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # Permisos para todos los usuarios
|
||||
|
||||
server.listen()
|
||||
|
||||
try:
|
||||
while True:
|
||||
logging.info('Daemon ready to accept connections')
|
||||
conn, _ = server.accept()
|
||||
with conn:
|
||||
logging.info('Accepted connection')
|
||||
data = conn.recv(1024)
|
||||
if not data:
|
||||
continue
|
||||
try:
|
||||
command = json.loads(data.decode('utf-8'))
|
||||
logging.info(f'Received command: {command}')
|
||||
except json.JSONDecodeError:
|
||||
logging.error('Failed to decode JSON')
|
||||
conn.sendall(json.dumps({"success": False, "error": "Invalid JSON"}).encode('utf-8'))
|
||||
continue
|
||||
|
||||
response = handle_command(command)
|
||||
conn.sendall(json.dumps(response).encode('utf-8'))
|
||||
finally:
|
||||
server.close()
|
||||
if os.path.exists(socket_path):
|
||||
os.remove(socket_path)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,2 +1,3 @@
|
|||
/opt/opengnsys/ogboot/client_log
|
||||
/opt/opengnsys/ogboot/mnt
|
||||
/opt/opengnsys/ogboot/tftpboot
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
bin /opt/opengnsys/ogboot
|
||||
config /opt/opengnsys/ogboot/
|
||||
doc /opt/opengnsys/ogboot/
|
||||
docs /opt/opengnsys/ogboot/
|
||||
api /opt/opengnsys/ogboot
|
||||
etc /opt/opengnsys/ogboot
|
||||
lib /opt/opengnsys/ogboot
|
||||
public /opt/opengnsys/ogboot/
|
||||
src /opt/opengnsys/ogboot/
|
||||
templates /opt/opengnsys/ogboot/
|
||||
bin /opt/opengnsys/ogboot
|
||||
tftpboot /opt/opengnsys/ogboot/
|
||||
var /opt/opengnsys/ogboot/
|
||||
vendor /opt/opengnsys/ogboot/
|
||||
composer.json /opt/opengnsys/ogboot/
|
||||
composer.lock /opt/opengnsys/ogboot/
|
||||
.env.local.php /opt/opengnsys/ogboot/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@ set -e
|
|||
. /usr/share/debconf/confmodule
|
||||
|
||||
# Leer las variables de configuración
|
||||
OGBOOT_DIR="/opt/opengnsys/ogboot"
|
||||
OGBOOT_ROOT="/opt/opengnsys/ogboot"
|
||||
OGBOOT_API_DIR="/opt/opengnsys/ogboot/api"
|
||||
db_get opengnsys/ogboot_ip
|
||||
OGBOOT_IP="$RET"
|
||||
db_get opengnsys/ogboot_port
|
||||
|
@ -22,13 +23,14 @@ OGCORE_OGLIVE_URL="$RET"
|
|||
# SAMBA_PASS="$RET"
|
||||
|
||||
|
||||
IPXE_REPO="https://github.com/ipxe/ipxe.git"
|
||||
# IPXE_REPO="https://github.com/ipxe/ipxe.git"
|
||||
IPXE_REPO="https://ognproject.evlt.uma.es/gitea/narenas/opengnsys_ipxe.git"
|
||||
|
||||
# Asegurarse de que el usuario exista
|
||||
USER="opengnsys"
|
||||
USER_INFO=$(getent passwd "$USER")
|
||||
DEFAULT_OGLIVE=$OGCORE_OGLIVE_URL
|
||||
ENV_FILE=/opt/opengnsys/ogboot/.env.local.php
|
||||
ENV_FILE=/opt/opengnsys/ogboot/api/.env
|
||||
if [ -z "$USER_INFO" ]; then
|
||||
echo "Error: El usuario '$USER' no existe." >&2
|
||||
exit 1
|
||||
|
@ -50,7 +52,7 @@ configure_sudo() {
|
|||
if [ ! -f /etc/sudoers.d/opengnsys ]; then
|
||||
cp /opt/opengnsys/ogboot/etc/ogboot.sudoers /etc/sudoers.d/opengnsys
|
||||
chmod 440 /etc/sudoers.d/opengnsys
|
||||
sed -i "s|__OGBOOT_TARGET__|$OGBOOT_DIR|g" /etc/sudoers.d/opengnsys
|
||||
sed -i "s|__OGBOOT_TARGET__|$OGBOOT_ROOT|g" /etc/sudoers.d/opengnsys
|
||||
else
|
||||
echo "El archivo /etc/sudoers.d/opengnsys ya existe."
|
||||
fi
|
||||
|
@ -98,34 +100,34 @@ install_oglive(){
|
|||
|
||||
configure_ipxe(){
|
||||
echo "Configure ipxe templates"
|
||||
cp $OGBOOT_DIR/etc/dhcp_boot.ipxe.tmpl $OGBOOT_DIR/tftpboot/ipxe_scripts/dhcp_boot.ipxe
|
||||
cp $OGBOOT_DIR/etc/default.ipxe.tmpl $OGBOOT_DIR/tftpboot/ipxe_scripts/default.ipxe
|
||||
sed -i "s|__SERVERIP__|$OGBOOT_IP|g" $OGBOOT_DIR/tftpboot/ipxe_scripts/dhcp_boot.ipxe
|
||||
sed -i "s|__SERVERIP__|$OGBOOT_IP|g" $OGBOOT_DIR/tftpboot/ipxe_scripts/default.ipxe
|
||||
cp $OGBOOT_ROOT/etc/dhcp_boot.ipxe.tmpl $OGBOOT_ROOT/tftpboot/ipxe_scripts/dhcp_boot.ipxe
|
||||
cp $OGBOOT_ROOT/etc/default.ipxe.tmpl $OGBOOT_ROOT/tftpboot/ipxe_scripts/default.ipxe
|
||||
sed -i "s|__SERVERIP__|$OGBOOT_IP|g" $OGBOOT_ROOT/tftpboot/ipxe_scripts/dhcp_boot.ipxe
|
||||
sed -i "s|__SERVERIP__|$OGBOOT_IP|g" $OGBOOT_ROOT/tftpboot/ipxe_scripts/default.ipxe
|
||||
|
||||
echo "Instalando ipxe"
|
||||
rm -rf /tmp/ipxe_repo
|
||||
git clone $IPXE_REPO /tmp/ipxe_repo
|
||||
if [ ! -f $OGBOOT_DIR/tftpboot/undionly.kpxe ]; then
|
||||
if [ ! -f $OGBOOT_ROOT/tftpboot/undionly.kpxe ]; then
|
||||
cd /tmp/ipxe_repo/src
|
||||
make -s bin/undionly.kpxe EMBED=$OGBOOT_DIR/tftpboot/ipxe_scripts/dhcp_boot.ipxe
|
||||
make -s bin-x86_64-efi/ipxe.efi EMBED=$OGBOOT_DIR/tftpboot/ipxe_scripts/dhcp_boot.ipxe
|
||||
cp bin/undionly.kpxe $OGBOOT_DIR/tftpboot/
|
||||
cp bin-x86_64-efi/ipxe.efi $OGBOOT_DIR/tftpboot/
|
||||
make -j4 -s bin/undionly.kpxe EMBED=$OGBOOT_ROOT/tftpboot/ipxe_scripts/dhcp_boot.ipxe
|
||||
make -j4 -s bin-x86_64-efi/ipxe.efi EMBED=$OGBOOT_ROOT/tftpboot/ipxe_scripts/dhcp_boot.ipxe
|
||||
cp bin/undionly.kpxe $OGBOOT_ROOT/tftpboot/
|
||||
cp bin-x86_64-efi/ipxe.efi $OGBOOT_ROOT/tftpboot/
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
configure_api(){
|
||||
echo "Modify env.local.php"
|
||||
if ! dpkg-divert --list /opt/opengnsys/ogboot/.env.local.php >/dev/null 2>&1; then
|
||||
dpkg-divert --add --rename --divert /opt/opengnsys/ogboot/.env.local.php.orig /opt/opengnsys/ogboot/.env.local.php
|
||||
if ! grep -q "OGCORE_API_URL" $ENV_FILE; then
|
||||
echo "OGCORE_API_URL=$OGCORE_API_URL" >> $ENV_FILE
|
||||
fi
|
||||
if [ ! -f "/opt/opengnsys/ogboot/.env.local.php" ] && [ -f "/opt/opengnsys/ogboot/.env.local.php.orig" ]; then
|
||||
cp "/opt/opengnsys/ogboot/.env.local.php.orig" "/opt/opengnsys/ogboot/.env.local.php"
|
||||
if ! grep -q "OGBOOT_IP" $ENV_FILE; then
|
||||
echo "OGBOOT_IP=$OGBOOT_IP" >> $ENV_FILE
|
||||
fi
|
||||
if ! grep -q "OGBOOT_PORT" $ENV_FILE; then
|
||||
echo "OGBOOT_PORT=$OGBOOT_PORT" >> $ENV_FILE
|
||||
fi
|
||||
sed -i "s|'OGBOOT_IP' => '.*'|'OGBOOT_IP' => '$OGBOOT_IP'|" "$ENV_FILE"
|
||||
sed -i "s|'OGBOOT_PORT' => '.*'|'OGBOOT_PORT' => '$OGBOOT_PORT'|" "$ENV_FILE"
|
||||
sed -i "s|'OGCORE_API_URL' => '.*'|'OGCORE_API_URL' => '$OGCORE_API_URL'|" "$ENV_FILE"
|
||||
}
|
||||
|
||||
configure_nginx_and_fpm() {
|
||||
|
@ -133,11 +135,11 @@ configure_nginx_and_fpm() {
|
|||
PHP_VERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')
|
||||
if [ ! -f /etc/nginx/sites-available/ogboot.conf ]; then
|
||||
cp /opt/opengnsys/ogboot/etc/nginxServer.conf.tmpl /etc/nginx/sites-available/ogboot.conf
|
||||
sed -i "s|__ROOT__|$OGBOOT_DIR|g" /etc/nginx/sites-available/ogboot.conf
|
||||
sed -i "s|__ROOT__|$OGBOOT_API_DIR|g" /etc/nginx/sites-available/ogboot.conf
|
||||
sed -i "s|__PHPVERSION__|$PHP_VERSION|g" /etc/nginx/sites-available/ogboot.conf
|
||||
sed -i "s|__SERVERIP__|$OGBOOT_IP|g" /etc/nginx/sites-available/ogboot.conf
|
||||
sed -i "s|__PORT__|$OGBOOT_PORT|g" /etc/nginx/sites-available/ogboot.conf
|
||||
sed -i "s|__TFTPPATH__|$OGBOOT_DIR/tftpboot|g" /etc/nginx/sites-available/ogboot.conf
|
||||
sed -i "s|__TFTPPATH__|$OGBOOT_ROOT/tftpboot|g" /etc/nginx/sites-available/ogboot.conf
|
||||
ln -s /etc/nginx/sites-available/ogboot.conf /etc/nginx/sites-enabled/ogboot.conf
|
||||
else
|
||||
echo "El archivo /etc/nginx/sites-available/opengnsys ya existe."
|
||||
|
@ -151,10 +153,9 @@ configure_nginx_and_fpm() {
|
|||
|
||||
configure_samba(){
|
||||
echo "Configurando Samba"
|
||||
mkdir -p /etc/samba/opengnsys/
|
||||
cp /opt/opengnsys/ogboot/etc/samba/smb-ogboot.conf /etc/samba/opengnsys/
|
||||
sed -i "s|__OGBOOT_DIR__|$OGBOOT_DIR|g" /etc/samba/opengnsys/smb-ogboot.conf
|
||||
INCLUDE_LINE="include = /etc/samba/opengnsys/smb-ogboot.conf"
|
||||
cp /opt/opengnsys/ogboot/etc/samba/smb-ogboot.conf /etc/samba/
|
||||
sed -i "s|__OGBOOTDIR__|$OGBOOT_ROOT|g" /etc/samba/smb-ogboot.conf
|
||||
INCLUDE_LINE="include = /etc/samba/smb-ogboot.conf"
|
||||
if ! grep -q "$INCLUDE_LINE" /etc/samba/smb.conf; then
|
||||
echo "$INCLUDE_LINE" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
fi
|
||||
|
|
|
@ -5,12 +5,9 @@
|
|||
|
||||
# Ejecutar composer install durante la fase de construcción
|
||||
override_dh_auto_build:
|
||||
export COMPOSER_ALLOW_SUPERUSER=1
|
||||
export APP_ENV=prod
|
||||
dh_auto_build
|
||||
rm -rf var/cache/*
|
||||
mkdir -p public
|
||||
composer install --no-interaction --no-progress --optimize-autoloader
|
||||
composer dump-env prod
|
||||
composer update doctrine/dbal
|
||||
cd api/; \
|
||||
rm -rf var/cache/*; \
|
||||
mkdir -p public; \
|
||||
COMPOSER_ALLOW_SUPERUSER=1 APP_ENV=prod composer install --no-interaction --no-progress --optimize-autoloader; \
|
||||
COMPOSER_ALLOW_SUPERUSER=1 APP_ENV=prod composer update doctrine/dbal;
|
||||
|
||||
|
|
|
@ -4,13 +4,3 @@
|
|||
writeable = no
|
||||
path = __OGBOOTDIR__/tftpboot
|
||||
guest ok = no
|
||||
|
||||
|
||||
[oglog]
|
||||
comment = OpenGnsys Log
|
||||
browseable = no
|
||||
writeable = yes
|
||||
locking = no
|
||||
path = __OGBOOTDIR__/client_log
|
||||
guest ok = no
|
||||
|
||||
|
|
|
@ -242,6 +242,8 @@ def og_boot_create_dirs():
|
|||
os.makedirs("/opt/opengnsys", mode=0o775, exist_ok=True)
|
||||
subprocess.run(["chmod", "775", "/opt/opengnsys"])
|
||||
os.makedirs(INSTALL_OGBOOT_TARGET, mode=0o775, exist_ok=True)
|
||||
api_dir = os.path.join(INSTALL_OGBOOT_TARGET, "api")
|
||||
os.makedirs(api_dir, mode=0o775, exist_ok=True)
|
||||
|
||||
# Cambiar el propietario de los directorios
|
||||
subprocess.run(["chown", "-R", "opengnsys:opengnsys", INSTALL_OGBOOT_TARGET])
|
||||
|
@ -256,11 +258,14 @@ def og_boot_symfony_install():
|
|||
logger.info("Creating Symfony application skeleton...")
|
||||
|
||||
try:
|
||||
# Copiar los archivos .env y composer.json primero
|
||||
env_src = os.path.join(f"{REPO_DIR}", ".env")
|
||||
composer_src = os.path.join(f"{REPO_DIR}", "composer.json")
|
||||
env_dest = os.path.join(f"{INSTALL_OGBOOT_TARGET}", ".env")
|
||||
composer_dest = os.path.join(f"{INSTALL_OGBOOT_TARGET}", "composer.json")
|
||||
api_dir = os.path.join(INSTALL_OGBOOT_TARGET, "api")
|
||||
os.makedirs(api_dir, exist_ok=True) # Asegurar que el directorio api existe
|
||||
# Cambio de .env y composer.json bajo /api
|
||||
api_source = os.path.join(REPO_DIR, "api")
|
||||
env_src = os.path.join(api_source, ".env")
|
||||
composer_src = os.path.join(api_source, "composer.json")
|
||||
env_dest = os.path.join(api_dir, ".env")
|
||||
composer_dest = os.path.join(api_dir, "composer.json")
|
||||
|
||||
shutil.copy(env_src, env_dest)
|
||||
shutil.copy(composer_src, composer_dest)
|
||||
|
@ -296,25 +301,32 @@ def og_boot_symfony_install():
|
|||
|
||||
|
||||
def og_boot_copy_files():
|
||||
api_dir = os.path.join(INSTALL_OGBOOT_TARGET, "api")
|
||||
api_source = os.path.join(REPO_DIR, "api")
|
||||
|
||||
# api/bin que contendría los scripts composer y console de symfony
|
||||
bin_api_source = os.path.join(api_source, "bin")
|
||||
bin_api_dest = os.path.join(api_dir, "bin")
|
||||
# api/bin que contendría los scripts oglivecli y setsmbpass
|
||||
bin_source = os.path.join(REPO_DIR, "bin")
|
||||
bin_dest = os.path.join(INSTALL_OGBOOT_TARGET, "bin")
|
||||
src_source = os.path.join(REPO_DIR, "src")
|
||||
src_dest = os.path.join(INSTALL_OGBOOT_TARGET, "src")
|
||||
|
||||
config_source = os.path.join(REPO_DIR, "config")
|
||||
config_dest = os.path.join(INSTALL_OGBOOT_TARGET, "config")
|
||||
|
||||
src_source = os.path.join(api_source, "src")
|
||||
src_dest = os.path.join(api_dir, "src")
|
||||
config_source = os.path.join(api_source, "config")
|
||||
config_dest = os.path.join(api_dir, "config")
|
||||
# lib va fuera de /api
|
||||
lib_source = os.path.join(REPO_DIR, "lib")
|
||||
lib_dest = os.path.join(INSTALL_OGBOOT_TARGET, "lib")
|
||||
|
||||
#os.makedirs("/tmp/opt", exist_ok=True)
|
||||
|
||||
#subprocess.run(["chown", "-R", "ogboot:ogboot", "/tmp/opt"])
|
||||
|
||||
if os.path.exists(bin_dest):
|
||||
shutil.rmtree(bin_dest)
|
||||
shutil.copytree(bin_source, bin_dest)
|
||||
|
||||
if os.path.exists(bin_api_dest):
|
||||
shutil.rmtree(bin_api_dest)
|
||||
shutil.copytree(bin_api_source, bin_api_dest)
|
||||
|
||||
if os.path.exists(src_dest):
|
||||
shutil.rmtree(src_dest)
|
||||
shutil.copytree(src_source, src_dest)
|
||||
|
@ -327,25 +339,27 @@ def og_boot_copy_files():
|
|||
shutil.rmtree(lib_dest)
|
||||
shutil.copytree(lib_source, lib_dest)
|
||||
|
||||
os.makedirs(os.path.join(INSTALL_OGBOOT_TARGET, "public"), mode=0o775, exist_ok=True)
|
||||
os.makedirs(os.path.join(INSTALL_OGBOOT_TARGET, "etc"), mode=0o775, exist_ok=True)
|
||||
os.makedirs(os.path.join(INSTALL_OGBOOT_TARGET, "client"), mode=0o775, exist_ok=True)
|
||||
public_dir = os.path.join(api_dir, "public")
|
||||
os.makedirs(public_dir, mode=0o775, exist_ok=True)
|
||||
|
||||
subprocess.run(["chmod", "-R", "775", INSTALL_OGBOOT_TARGET])
|
||||
subprocess.run(["chown", "-R", "opengnsys:opengnsys", INSTALL_OGBOOT_TARGET])
|
||||
|
||||
def og_boot_composer_install():
|
||||
# Ejecutar Composer como el usuario 'opengnsys' para instalar el proyecto Symfony
|
||||
result = subprocess.run(["sudo", "-u", "opengnsys", "composer", "install", "--no-interaction", "--working-dir", INSTALL_OGBOOT_TARGET])
|
||||
if result.returncode != 0:
|
||||
logger.error("Error creating Symfony project using Composer")
|
||||
return
|
||||
api_dir = os.path.join(INSTALL_OGBOOT_TARGET, "api")
|
||||
result = subprocess.run(
|
||||
["sudo", "-u", "opengnsys", "composer", "install", "--no-interaction", "--working-dir", api_dir]
|
||||
)
|
||||
|
||||
# Ejecutar Composer como el usuario 'opengnsys' para actualizar el paquete doctrine/dbal
|
||||
result = subprocess.run(["sudo", "-u", "opengnsys", INSTALL_OGBOOT_TARGET+"/bin/composer.phar", "update", "doctrine/dbal", "--working-dir", INSTALL_OGBOOT_TARGET])
|
||||
result = subprocess.run(["sudo", "-u", "opengnsys", INSTALL_OGBOOT_TARGET+"/api/bin/composer.phar", "update", "doctrine/dbal", "--working-dir", api_dir])
|
||||
if result.returncode != 0:
|
||||
logger.error("Error updating doctrine/dbal package using Composer")
|
||||
return
|
||||
|
||||
subprocess.call(["chown", "-R", "opengnsys:opengnsys", f"{INSTALL_OGBOOT_TARGET}/public"])
|
||||
subprocess.call(["chown", "-R", "opengnsys:opengnsys", f"{api_dir}/public"])
|
||||
|
||||
logger.info("Application skeleton created.")
|
||||
|
||||
|
@ -616,16 +630,16 @@ def setup_nginx():
|
|||
ip_address_server = OGBOOT_IP
|
||||
port_address_server = OGBOOT_PORT
|
||||
php_version = get_php_fpm_version()
|
||||
|
||||
api_dir = os.path.join(INSTALL_OGBOOT_TARGET, "api")
|
||||
# Leer y modificar la plantilla de configuración de nginx
|
||||
template_path = os.path.join(REPO_DIR, "etc/nginxServer.conf.tmpl")
|
||||
with open(template_path, 'r') as nginx_file:
|
||||
nginx_content = nginx_file.read()
|
||||
|
||||
|
||||
nginx_content = nginx_content.replace("__SERVERIP__", ip_address_server)
|
||||
nginx_content = nginx_content.replace("__PORT__", port_address_server)
|
||||
nginx_content = nginx_content.replace("__PHPVERSION__", php_version)
|
||||
nginx_content = nginx_content.replace("__ROOT__", INSTALL_OGBOOT_TARGET)
|
||||
nginx_content = nginx_content.replace("__ROOT__", api_dir)
|
||||
nginx_content = nginx_content.replace("__TFTPPATH__", f"{INSTALL_OGBOOT_TARGET}/tftpboot")
|
||||
|
||||
# Ruta de destino para la configuración de nginx
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
# Configuración inicial
|
||||
set ISODIR ogLive
|
||||
|
||||
:bios_boot_first_second
|
||||
echo "Booting firstboot and secondboot flow using GRUB4DOS..."
|
||||
# Detectar si se está ejecutando en modo UEFI o BIOS
|
||||
iseq ${platform} efi && goto uefi_boot || goto bios_boot
|
||||
|
||||
# Pasar control a GRUB4DOS para manejar firstboot y secondboot
|
||||
chain tftp://__SERVERIP__/tftpboot/grub.exe --config-file="
|
||||
# Configurar ISODIR
|
||||
# BIOS Boot Logic
|
||||
:bios_boot
|
||||
echo "Running in BIOS mode..."
|
||||
echo "Starting firstboot and secondboot flow using GRUB4DOS..."
|
||||
chain http://__SERVERIP__/tftpboot/grub.exe --config-file="
|
||||
timeout 0
|
||||
set ISODIR=${ISODIR};
|
||||
|
||||
|
@ -33,4 +35,50 @@ chain tftp://__SERVERIP__/tftpboot/grub.exe --config-file="
|
|||
:fallback
|
||||
pause Firstboot and Secondboot failed. Press any key to continue...;
|
||||
quit;
|
||||
" || echo "Failed to execute GRUB fallback sequence."
|
||||
|
||||
# OpenGnsys-CACHE
|
||||
echo "Booting OpenGnsys-CACHE"
|
||||
kernel tftp://__SERVERIP__/${ISODIR}/ogvmlinuz ro boot=oginit quiet splash vga=788 irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=false ogdebug=false ogupdateinitrd=true ogtmpfs=15 oglivedir=${ISODIR} INFOHOST
|
||||
initrd tftp://__SERVERIP__/${ISODIR}/oginitrd.img
|
||||
boot || echo "Failed to boot OpenGnsys-CACHE"
|
||||
|
||||
# OpenGnsys-NET
|
||||
echo "Booting OpenGnsys-NET"
|
||||
kernel tftp://__SERVERIP__/${ISODIR}/ogvmlinuz ro boot=oginit quiet splash vga=788 irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=false ogdebug=false ogtmpfs=15 oglivedir=${ISODIR} INFOHOST
|
||||
initrd tftp://__SERVERIP__/${ISODIR}/oginitrd.img
|
||||
boot || echo "Failed to boot OpenGnsys-NET"
|
||||
|
||||
# OpenGnsys-NET Default
|
||||
echo "Booting OpenGnsys-NET Default"
|
||||
kernel tftp://__SERVERIP__/ogLive/ogvmlinuz ro boot=oginit quiet splash vga=788 irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=false ogdebug=false ogtmpfs=15 oglivedir=ogLive INFOHOST
|
||||
initrd tftp://__SERVERIP__/ogLive/oginitrd.img
|
||||
boot || echo "Failed to boot OpenGnsys-NET Default"
|
||||
exit
|
||||
|
||||
# UEFI Boot Logic
|
||||
:uefi_boot
|
||||
echo "Running in UEFI mode..."
|
||||
set timeout 30
|
||||
|
||||
# Verificar y buscar cargadores en orden de prioridad
|
||||
echo "Searching Grub loader..."
|
||||
sanboot --no-describe --drive 0 --filename \EFI\grub\Boot\grubx64.efi && exit || echo "Grub not found."
|
||||
|
||||
echo "Searching rEFInd loader..."
|
||||
sanboot --no-describe --drive 0 --filename \EFI\refind\shimx64.efi.signed && exit || echo "rEFInd not found."
|
||||
|
||||
echo "Searching Part-01-02 loader..."
|
||||
sanboot --no-describe --drive 0 --filename \EFI\Part-01-02\Boot\ogloader.efi && exit || echo "Part-01-02 not found."
|
||||
|
||||
echo "Searching Part-01-03 loader..."
|
||||
sanboot --no-describe --drive 0 --filename \EFI\Part-01-03\Boot\ogloader.efi && exit || echo "Part-01-03 not found."
|
||||
|
||||
echo "Searching Microsoft loader..."
|
||||
sanboot --no-describe --drive 0 --filename \EFI\Microsoft\Boot\bootmgfw.efi && exit || echo "Microsoft loader not found."
|
||||
|
||||
echo "Searching Ubuntu loader..."
|
||||
sanboot --no-describe --drive 0 --filename \EFI\ubuntu\grubx64.efi && exit || echo "Ubuntu loader not found."
|
||||
|
||||
# Fallback: Si no hay cargadores encontrados
|
||||
echo "No bootable operating system detected by OpenGnsys. Falling back..."
|
||||
exit
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
#!ipxe
|
||||
|
||||
# Configuración inicial
|
||||
set ISODIR __OGLIVE__
|
||||
set default 0
|
||||
set kernelargs __INFOHOST__
|
||||
:bios_boot_cache
|
||||
echo "Booting ogLive from cache..."
|
||||
# Detectar si se está ejecutando en modo UEFI o BIOS
|
||||
iseq ${platform} efi && goto uefi_boot || goto bios_boot
|
||||
|
||||
chain tftp://__SERVERIP__/tftpboot/grub.exe --config-file="
|
||||
timeout 0
|
||||
set ISODIR=${ISODIR};
|
||||
find --set-root --ignore-floppies --ignore-cd /boot/${ISODIR}/ogvmlinuz;
|
||||
kernel /boot/${ISODIR}/ogvmlinuz ${kernelargs};
|
||||
initrd /boot/${ISODIR}/oginitrd.img;
|
||||
boot;
|
||||
" || echo "Failed to boot ogLive from cache."
|
||||
:bios_boot
|
||||
echo "Running in BIOS mode"
|
||||
# Si el cliente es BIOS, arranca el grub.pxe
|
||||
chain http://__SERVERIP__/tftpboot/grub.pxe
|
||||
exit
|
||||
|
||||
:uefi_boot
|
||||
echo "Running in UEFI mode"
|
||||
# Si el cliente es UEFI, arranca el grubx64.efi
|
||||
chain http://__SERVERIP__/tftpboot/grubx64.efi
|
||||
exit
|
||||
|
|
Loading…
Reference in New Issue