Resolved merge conflicts by keeping stash changes

pull/3/head
qindel 2024-03-14 08:35:24 +00:00
parent 9bfebf49f9
commit bce5e8b923
62 changed files with 11468 additions and 216 deletions

40
.env 100644
View File

@ -0,0 +1,40 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=d423d1302b974417d415b10bcde25767
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8&charset=utf8mb4"
DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=15&charset=utf8"
###< doctrine/doctrine-bundle ###
###> symfony/messenger ###
# Choose one of the transports below
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###< symfony/messenger ###
###> symfony/mailer ###
# MAILER_DSN=null://null
###< symfony/mailer ###

6
.env.test 100644
View File

@ -0,0 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots

20
.gitignore vendored 100644
View File

@ -0,0 +1,20 @@
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###
###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###
###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

BIN
bin/composer.phar 100755

Binary file not shown.

17
bin/console 100755
View File

@ -0,0 +1,17 @@
#!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
return new Application($kernel);
};

23
bin/phpunit 100755
View File

@ -0,0 +1,23 @@
#!/usr/bin/env php
<?php
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}
if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
if (PHP_VERSION_ID >= 80000) {
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
} else {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
}
} else {
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
exit(1);
}
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
}

View File

@ -55,7 +55,7 @@
},
"config": {
"platform": {
"php": "8.3"
"php": "7.2.24"
},
"allow-plugins": {
"composer/package-versions-deprecated": true,

9979
composer.lock generated 100644

File diff suppressed because it is too large Load Diff

15
config/bundles.php 100644
View File

@ -0,0 +1,15 @@
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
App\OgBootBundle\OgBootBundle::class => ['all' => true],
];

View File

@ -0,0 +1,19 @@
framework:
cache:
# Unique name of your app: used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name
# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
# Other options include:
# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu
# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: null

View File

@ -0,0 +1,5 @@
when@dev:
debug:
# Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser.
# See the "server:dump" command to start a new server.
dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%"

View File

@ -0,0 +1,43 @@
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '15'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
when@test:
doctrine:
dbal:
# "TEST_TOKEN" is typically set by ParaTest
dbname_suffix: '_test%env(default::TEST_TOKEN)%'
when@prod:
doctrine:
orm:
auto_generate_proxy_classes: false
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system

View File

@ -0,0 +1,6 @@
doctrine_migrations:
migrations_paths:
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
'DoctrineMigrations': '%kernel.project_dir%/migrations'
enable_profiler: false

View File

@ -0,0 +1,24 @@
# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
secret: '%env(APP_SECRET)%'
#csrf_protection: true
http_method_override: false
# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
session:
handler_id: null
cookie_secure: auto
cookie_samesite: lax
storage_factory_id: session.storage.factory.native
#esi: true
#fragments: true
php_errors:
log: true
when@test:
framework:
test: true
session:
storage_factory_id: session.storage.factory.mock_file

View File

@ -0,0 +1,3 @@
framework:
mailer:
dsn: '%env(MAILER_DSN)%'

View File

@ -0,0 +1,24 @@
framework:
messenger:
failure_transport: failed
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
use_notify: true
check_delayed_interval: 60000
retry_strategy:
max_retries: 3
multiplier: 2
failed: 'doctrine://default?queue_name=failed'
# sync: 'sync://'
routing:
Symfony\Component\Mailer\Messenger\SendEmailMessage: async
Symfony\Component\Notifier\Message\ChatMessage: async
Symfony\Component\Notifier\Message\SmsMessage: async
# Route your messages to the transports
# 'App\Message\YourMessage': async

View File

@ -0,0 +1,61 @@
monolog:
channels:
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
when@dev:
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]
when@test:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
channels: ["!event"]
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
when@prod:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
nested:
type: stream
path: php://stderr
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]
deprecation:
type: stream
channels: [deprecation]
path: php://stderr

View File

@ -0,0 +1,12 @@
framework:
notifier:
chatter_transports:
texter_transports:
channel_policy:
# use chat/slack, chat/telegram, sms/twilio or sms/nexmo
urgent: ['email']
high: ['email']
medium: ['email']
low: ['email']
admin_recipients:
- { email: admin@example.com }

View File

@ -0,0 +1,12 @@
framework:
router:
utf8: true
# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
#default_uri: http://localhost
when@prod:
framework:
router:
strict_requirements: null

View File

@ -0,0 +1,40 @@
security:
enable_authenticator_manager: true
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
users_in_memory: { memory: null }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider: users_in_memory
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
# - { path: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }
when@test:
security:
password_hashers:
# By default, password hashers are resource intensive and take time. This is
# important to generate secure password hashes. In tests however, secure hashes
# are not important, waste resources and increase test times. The following
# reduces the work factor to the lowest possible values.
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
algorithm: auto
cost: 4 # Lowest possible value for bcrypt
time_cost: 3 # Lowest possible value for argon
memory_cost: 10 # Lowest possible value for argon

View File

@ -0,0 +1,13 @@
framework:
default_locale: en
translator:
default_path: '%kernel.project_dir%/translations'
fallbacks:
- en
# providers:
# crowdin:
# dsn: '%env(CROWDIN_DSN)%'
# loco:
# dsn: '%env(LOCO_DSN)%'
# lokalise:
# dsn: '%env(LOKALISE_DSN)%'

View File

@ -0,0 +1,6 @@
twig:
default_path: '%kernel.project_dir%/templates'
when@test:
twig:
strict_variables: true

View File

@ -0,0 +1,13 @@
framework:
validation:
email_validation_mode: html5
# Enables validator auto-mapping support.
# For instance, basic validation constraints will be inferred from Doctrine's metadata.
#auto_mapping:
# App\Entity\: []
when@test:
framework:
validation:
not_compromised_password: false

View File

@ -0,0 +1,15 @@
when@dev:
web_profiler:
toolbar: true
intercept_redirects: false
framework:
profiler: { only_exceptions: false }
when@test:
web_profiler:
toolbar: false
intercept_redirects: false
framework:
profiler: { collect: false }

View File

@ -0,0 +1,5 @@
<?php
if (file_exists(dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php')) {
require dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php';
}

View File

@ -0,0 +1,3 @@
#index:
# path: /
# controller: App\Controller\DefaultController::index

View File

@ -0,0 +1,7 @@
controllers:
resource: ../../src/OgBootBundle/Controller/
type: annotation
kernel:
resource: ../../src/Kernel.php
type: annotation

View File

@ -0,0 +1,4 @@
when@dev:
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
prefix: /_error

View File

@ -0,0 +1,8 @@
when@dev:
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt
web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler

View File

@ -0,0 +1,27 @@
# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.
# 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:
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
App\OgBootBundle\Controller\:
resource: '../src/OgBootBundle/Controller'
tags: ['controller.service_arguments']

View File

@ -0,0 +1,121 @@
## API de DHCP
La API de DHCP proporciona una interfaz para interactuar con el servidor DHCP de Kea. Esta API permite realizar operaciones como obtener la configuración actual del servidor DHCP, actualizar la configuración y obtener información sobre las reservas de direcciones IP.
Los endpoints están agrupados en el recurso al que hace referencia. Actualmente se gestionan dos recursos:
- `/dhcp/subnets/`: CRUD de subredes de Kea DHCP. Las subredes serán donde se organizarán los hosts y hacen referencia a las subredes montadas por el aula.
- `/dhcp/subnets/hosts/`: CRUD de hosts en la configuración de Kea DHCP. Los hosts hacen referencia a los ordenadores dados de alta en las aulas. Esta sección en Kea DHCP se encarga de asignar, dada la MAC del dispositivo, la IP y el boot-file-name del ordenador.
El presente documento detalla los endpoints del API con sus respectivos parámetros de entrada así como los cambios que aplican sobre la configuración de Kea DHCP.
### Recurso `/dhcp/subnets`
#### Obtener configuración de las subredes
Devuelve las subredes dadas de alta en la configuración de Kea DHCP.
**Método HTTP:** GET
**URL:** `/dhcp/subnets`
#### Añadir subred
Añade un nueva subred a la configuración de Kea DHCP.
**Método HTTP:** POST
**URL:** `/dhcp/subnets`
**Parámetros de entrada:**
- `name`: Nombre de la subred.
- `subnet`: DirecciónIP de la subred.
- `boot-file-name`: Archivo de arranque de la subred.
- `nextServer`: Dirección IP del next-server.
#### Borrar subred DHCP
Borrar una subred de la configuración de Kea DHCP.
**Método HTTP:** DELETE
**URL:** `/dhcp/subnets/{id_subnet}`
#### Modificar Host DHCP
Modificar la subred en la configuración de Kea DHCP.
**Método HTTP:** PUT
**URL:** `/dhcp/subnets/{id_subnet}`
**Parámetros de entrada:**
- `name`: Nombre de la subred.
- `subnet`: DirecciónIP de la subred.
- `boot-file-name`: Archivo de arranque de la subred.
- `nextServer`: Dirección IP del next-server.
### Recurso `/dhcp/subnets/hosts`
#### Obtener configuración de los hosts
Devuelve la configuración de los hosts que se encuentran bajo una subred en la configuración de Kea DHCP.
**Método HTTP:** GET
**URL:** `/dhcp/subnets/{id_subnet}/hosts`
#### Añadir Host DHCP
Añade un nuevo host a la subnet especificada.
**Método HTTP:** POST
**URL:** `/dhcp/subnets/{id_subnet}/hosts`
**Parámetros de entrada:**
- `host`: Nombre del host.
- `macAddress`: Dirección MAC del host.
- `address`: Dirección IP del host.
- `nextServer`: Dirección IP del next-server.
#### Borrar Host DHCP
Borrar un host de la subnet especificada.
**Método HTTP:** DELETE
**URL:** `/dhcp/subnets/{id_subnet}/hosts`
**Parámetros de entrada:**
- `host`: Nombre del host.
#### Modificar Host DHCP
Modificar la configuración de un host en la subnet especificada.
**Método HTTP:** PUT
**URL:** `/dhcp/subnets/{id_subnet}/hosts`
**Parámetros de entrada:**
- `host`: Nombre del host.
- `oldMacAddress`: Dirección MAC antigua del host.
- `oldAddress`: Dirección IP antigua del host.
- `macAddress`: Nueva dirección MAC del host.
- `address`: Nueva dirección IP del host.
- `nextServer`: Nueva dirección IP del servidor siguiente.

View File

@ -0,0 +1,25 @@
# OpenGnsys ogdhcp configuration for Apache.
Alias /opengnsys3/rest OGHDPCDIR
# PHP-FPM configuration
<IfModule proxy_fcgi_module>
<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</IfModule>
RewriteEngine On
# Default configuration.
<Directory OGHDPCDIR>
Require all granted
Options -Indexes +FollowSymLinks
DirectoryIndex index.php
AddType octet/stream .pkg
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET,POST,OPTIONS,DELETE,PUT"
Header set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
FallbackResource /index.php
</Directory>

View File

@ -0,0 +1,7 @@
ServidorAdm=172.17.8.71
PUERTO=2008
USUARIO=usuog
PASSWORD=passusuog
datasource=localhost
CATALOG=ogAdmBD

View File

@ -0,0 +1,7 @@
ServidorAdm=192.168.2.1
PUERTO=2008
USUARIO=usuog
PASSWORD=passusuog
datasource=localhost
CATALOG=ogAdmBD

View File

@ -0,0 +1,7 @@
ServidorAdm=192.168.2.1
PUERTO=2008
USUARIO=usuog
PASSWORD=passusuog
datasource=localhost
CATALOG=ogAdmBD

View File

@ -0,0 +1,2 @@
IPlocal=172.17.8.71
ApiToken=REPOKEY

View File

@ -0,0 +1,2 @@
IPlocal=192.168.2.1
ApiToken=57ba8db739566d8f3e645ebb020ecbcf

View File

@ -0,0 +1,2 @@
IPlocal=192.168.2.1
ApiToken=57ba8db739566d8f3e645ebb020ecbcf

View File

@ -0,0 +1,8 @@
ServidorAdm=172.17.8.71
PUERTO=2008
USUARIO=usuog
PASSWORD=passusuog
datasource=localhost
CATALOG=ogAdmBD
INTERFACE=eth0
APITOKEN=REPOKEY

View File

@ -0,0 +1,8 @@
ServidorAdm=192.168.2.1
PUERTO=2008
USUARIO=usuog
PASSWORD=passusuog
datasource=localhost
CATALOG=ogAdmBD
INTERFACE=eth1
APITOKEN=e9823768e959157556f31d66ecf0d918

View File

@ -0,0 +1,8 @@
ServidorAdm=192.168.2.1
PUERTO=2008
USUARIO=usuog
PASSWORD=passusuog
datasource=localhost
CATALOG=ogAdmBD
INTERFACE=eth1
APITOKEN=e9823768e959157556f31d66ecf0d918

View File

@ -0,0 +1,13 @@
{
"oglive": [
{
"distribution": "focal",
"kernel": "5.11.0-22-generic",
"architecture": "amd64",
"revision": "r20210413",
"directory": "ogLive-5.11.0-r20210413",
"iso": "ogLive-focal-5.11.0-22-generic-amd64-r20210413.992ebb9.iso"
}
],
"default": 0
}

5
etc/php-vars.php 100644
View File

@ -0,0 +1,5 @@
<?php
// hostname: Common Name of the ogAdmSrv certificate
// port: the port stunnel4 is listening on
define('OG_REST_URL', 'https://ogAdmSrv.opengnsys.local:48888/');
?>

View File

@ -0,0 +1,5 @@
<?php
// hostname: Common Name of the ogAdmSrv certificate
// port: the port stunnel4 is listening on
define('OG_REST_URL', 'https://__OGADMSRV_HOSTNAME__:__OGADMSRV_PORT__/');
?>

View File

@ -0,0 +1,5 @@
{
"directory": "/opt/opengnsys/images",
"images": [],
"ous": []
}

View File

@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtzCCAZ8CAhABMA0GCSqGSIb3DQEBCwUAMB0xGzAZBgNVBAMMEmNhLm9wZW5n
bnN5cy5sb2NhbDAeFw0yNDAyMTMxNzI2MDlaFw0yNTAyMjIxNzI2MDlaMCUxIzAh
BgNVBAMMGldlYkNvbnNvbGUub3Blbmduc3lzLmxvY2FsMIIBIjANBgkqhkiG9w0B
AQEFAAOCAQ8AMIIBCgKCAQEA4ZbzWdu3fZu/sJvAmugapuNe2SCmW+XjbnSn1GUS
Rx/VYlyr7BBQDDQTfYnSvL2Nc0aCjkyjR2G5E9rTN2OAkvVST7lozt1sqCx1WXhH
Skhb2tnWjCMWqEL+jhwNc6RlS3TVGAIdzGBiVl+tdMTGBJW0j1nvyGke0R5GOtem
psuCkOGnhDJsGNY6hksVuJm9UY64GP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+tQKBgQD4++R/GtPiX/oK5vEDqoKMEkP35/zhsgbVuJYIjGrIIzq9yxg33wua
pXyB29xNvu3E+n0jod9RuD+HYOmFHlfa+Jy3F5NWwxS+b5naDjeVkcZwfPPkwI+z
uqpM0XgFL6CUBfR01rXCfF0Tfo3cQBd1THpan76ayUIKZgAXMY5Arg==
-----END RSA PRIVATE KEY-----

0
migrations/.gitignore vendored 100644
View File

37
phpunit.xml.dist 100644
View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="display_errors" value="1" />
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
<!-- Uncomment when adding extensions
<extensions>
</extensions>
-->
</phpunit>

BIN
sbin/ogBootAgent 100755

Binary file not shown.

285
sbin/ogBootRepoAux 100755
View File

@ -0,0 +1,285 @@
#!/bin/bash
PARM=`cat`
#PARM=$@
#TODO: ticket 379
#buscar parametro de identificador de operacion.
#usar parametro de identificacion para anexarlo al nombre de log
#Comprobar si la variable está seteas.
#Si no lo está setearla.
#Si esta seteada (en progreso) salir.
TIME=$SECONDS
BASEDIR=/opt/opengnsys
PATH=$PATH:$BASEDIR/bin
REPONAME=ogAdmRepo
REPODIR="$BASEDIR/images/"
# Para las sincronizadas
# BACKUP: Define si se realiza copia de seguridad al crear una imagen (true|false).
# IMGFS: Sistema de ficheros al crear las sincronizadas tipo archivo (EXT4|BTRFS).
[ -z $OGENGINECONFIGURATE ] && source $BASEDIR/client/etc/engine.cfg
# FS segun la configuracion y la version del kernel. ext4 para < 3.7, para >= BTRFS
KERNEL=$(file -bkr /opt/opengnsys/tftpboot/ogclient/ogvmlinuz |awk '/Linux/ {for(i=1;i<=NF;i++) if($i~/version/) {v=$(i+1);printf("%d",v);sub(/[0-9]*\./,"",v);printf(".%02d",v)}}')
[ $KERNEL \< 3.07 ] && IMGFS="EXT4" || IMGFS=${IMGFS:-"BTRFS"}
# Añade registro de incidencias.
function echolog () {
logger --tag $0 --priority local0.info "$*"
echo "$*"
}
function mountImage () {
#@param 1 image_file
#@param 2 mount_dir
#@param 3 openciones mount
[ "$3" != "" ] && OPTMOUNT=" -o $3 "
# Si está montado nada que hacer
df |grep "$2$" 2>&1 >/dev/null && return 0
# FS de la imagen segun el contenido del archivo .img
if file "$1" |grep -i -e " ext4 filesystem " 2>&1 > /dev/null ; then
echolog "mount $OPTMOUNT -t ext4 $1 $2"
mount $OPTMOUNT -t ext4 $1 $2
else
echolog "mount $OPTMOUNT -o compress=lzo $1 $2"
mount $OPTMOUNT -o compress=lzo "$1" "$2"
fi
# Si esta montado da error 32, lo damos como bueno
RETVAL=$?
[ $RETVAL -eq 32 ] && RETVAL=0
return $RETVAL
}
PARM1=$(echo $PARM | cut -f1 -d" ")
PARM2=$(echo $PARM | cut -f2 -d" ")
PARM3=$(echo $PARM | cut -f3 -d" ")
PARM4=$(echo $PARM | cut -f4 -d" ")
# Determinamos el tipo de sistema de fichero de las imagenes segun el kernel que tenga
case "$PARM1" in
START_MULTICAST)
#1 START_MULTICAST
#2 fichero a enviar
#3 opciones de multicast
FILE="$PARM2"
MCASTOPT="$PARM3"
echolog "Ejecutar $(which sendFileMcast) $FILE $MCASTOPT"
sendFileMcast $FILE $MCASTOPT |logger --tag $0 --priority local0.info
case $? in
1) echolog "Parametros insuficientes"
exit 1 ;;
2) echolog "Fichero no accesible"
exit 2 ;;
3) echolog "Sesion multicast no valida"
exit 3 ;;
esac
;;
CREATE_IMAGE)
# Creamos/Redimensionamos el fichero de imagen y lo montamos para que se pueda escribir sobre el
#1 CREATE_IMAGE
#2 nombre imagen
#3 tipo de imagen [ img | diff ]
#4 tamaño imagen
LOOPDEVICE=$(losetup -f)
DIRMOUNT="$REPODIR/mount/$PARM2"
if [ "$PARM3" == "img" ] ; then
IMGEXT="img"
else
IMGEXT="img.diff"
DIRMOUNT="$DIRMOUNT.diff"
fi
IMGFILE="$REPODIR/$PARM2.$IMGEXT"
IMGDIR="$(dirname $IMGFILE)"
[ -d $IMGDIR ] || mkdir -p $IMGDIR
mkdir -p "$DIRMOUNT"
LOCKFILE="$IMGFILE.lock"
SIZEREQUIRED="$PARM4"
# Si existe la imagen hacemos copia de seguridad y la redimesionamos
if [ -f "$IMGFILE" ]; then
echolog "La imagen $IMGFILE ya existe."
# TODO modificar ogGetImageSize
IMGSIZE=$(ls -l --block-size=1024 $IMGFILE| cut -f5 -d" ")
if [ "$BACKUP" == "true" -o "$BACKUP" == "TRUE" -o $IMGSIZE -lt $SIZEREQUIRED ]; then
# Si la imagen esta montada la desmonto
if [ -r "$DIRMOUNT/ogimg.info" ]; then
echolog "umount $DIRMOUNT"
umount "$DIRMOUNT"
[ $? -ne 0 ] && echolog "Error: No podemos desmontar la imagen para hacer copia de seguridad o redimensionar" && exit 1
fi
fi
# Copia de seguridad de la imagen
if [ "$BACKUP" == "true" -o "$BACKUP" == "TRUE" ]; then
echolog "Copia de seguridad de la imagen anterior"
echolog "cp $IMGFILE $IMGFILE.ant"
cp "$IMGFILE" "$IMGFILE.ant"
echolog mv -f "$IMGFILE.torrent" "$IMGFILE.torrent.ant" 2>/dev/null
mv -f "$IMGFILE.torrent" "$IMGFILE.torrent.ant" 2>/dev/null
fi
# Redimensionamos la imagen al tamaño necesario
if [ $IMGSIZE -lt $SIZEREQUIRED ];then
echolog "Redimensionamos la imagen $IMGFILE al tamaño necesario: $SIZEREQUIRED"
echolog "truncate --size=\">$SIZEREQUIRED\"k $IMGFILE"
truncate --size=">$SIZEREQUIRED"k $IMGFILE 2>&1 |logger --tag $0 --priority local0.info
# FS de la imagen segun el contenido del archivo .img
if file "$IMGFILE" |grep -i -e " ext4 filesystem " 2>&1 > /dev/null ; then
losetup $LOOPDEVICE "$IMGFILE"
echolog "resize2fs -f $LOOPDEVICE"
resize2fs -f $LOOPDEVICE |logger --tag $0 --priority local0.info
else
mount -o compress=lzo "$IMGFILE" "$DIRMOUNT"
echolog "btrfs filesystem resize max $DIRMOUNT"
btrfs filesystem resize max "$DIRMOUNT" 2>&1 |logger --tag $0 --priority local0.info
fi
fi
# Si no existe la imagen creamos el fichero.
else
echolog "Creamos la imagen $IMGFILE al tamaño necesario: $SIZEREQUIRED"
touch "$IMGFILE"
echolog "truncate --size=\">$SIZEREQUIRED\"k $IMGFILE"
truncate --size=">$SIZEREQUIRED"k $IMGFILE 2>&1 |logger --tag $0 --priority local0.info
#Formateamos imagen
echo losetup $LOOPDEVICE "$IMGFILE"
losetup $LOOPDEVICE "$IMGFILE"
if [ $IMGFS == "EXT4" ] ; then
echolog " mkfs.ext4 -i 4096 -b 4096 -L ${PARM2##*\/} $LOOPDEVICE"
mkfs.ext4 -i 4096 -b 4096 -L ${PARM2##*\/} $LOOPDEVICE
else
echolog mkfs.btrfs -L ${PARM2##*\/} $LOOPDEVICE
mkfs.btrfs -L ${PARM2##*\/} $LOOPDEVICE #&> $OGLOGCOMMAND
fi
fi
# Montamos la imagen.
mountImage "$IMGFILE" "$DIRMOUNT"
if [ $? -ne 0 ]; then
rmdir "$DIRMOUNT"
echolog "Error al crear/redimensionar la imagen"
exit 1
fi
#touch "$DIRMOUNT/ogimg.info"
echo "mounted"> "$LOCKFILE"
TIME2=$[SECONDS-TIME]
echolog "Fin creación/redimension de la imagen: $[TIME2/60]m $[TIME2%60]s"
# Si existe dispositivo loop lo borramos.
[ $LOOPDEVICE ] && losetup -a| grep $LOOPDEVICE &> /dev/null && losetup -d $LOOPDEVICE
# TODO: comprobar que no se quede el losetup bloqueado.
;;
MOUNT_IMAGE)
# Montamos el fichero imagen para que se pueda
#1 MOUNT_IMAGE
#2 nombre imagen
#3 tipo de imagen [ img | diff ]
DIRMOUNT="$REPODIR""mount/$PARM2"
if [ "$PARM3" == "img" ] ; then
IMGEXT="img"
else
IMGEXT="img.diff"
DIRMOUNT="$DIRMOUNT.diff"
fi
IMGFILE="$REPODIR/$PARM2.$IMGEXT"
echolog "Montamos la imagen $IMGFILE "
mkdir -p "$DIRMOUNT"
mountImage "$IMGFILE" "$DIRMOUNT" ro || (echolog "Error al montar la imagen"; exit 1)
;;
UMOUNT_IMAGE)
# Desmontamos el fichero imagen.
# Si el directorio esta ocupado no se desmontará
#1 UMOUNT_IMAGE
#2 nombre imagen
#3 tipo de imagen [ img | diff ]
IMGTYPE="$PARM3"
DIRMOUNT="$REPODIR/mount/$PARM2"
if [ "$IMGTYPE" == "img" ]; then
IMGEXT="img"
else
DIRMOUNT="$DIRMOUNT.$IMGTYPE"
IMGEXT="img.diff"
fi
LOCKFILE="$REPODIR/$PARM2.$IMGEXT.lock"
echolog "Desmontamos la imagen $PARM2 $PARM3 "
umount $DIRMOUNT
rmdir $DIRMOUNT
[ -f $LOCKFILE ] && sed -i s/mounted//g $LOCKFILE
;;
REDUCE_IMAGE)
# Reduce el archivo de la imagen a tamaño datos + 500M
#1 REDUCE_IMAGE
#2 Nombre Imagen
#3 Tipo de imagen [ img |diff ]
DIRMOUNT="${REPODIR}mount/${PARM2}"
if [ "$PARM3" == "img" ] ; then
IMGEXT="img"
else
IMGEXT="img.diff"
DIRMOUNT="$DIRMOUNT.diff"
fi
IMGFILE="$REPODIR$PARM2.$IMGEXT"
LOCKFILE="$IMGFILE.lock"
[ ! -f $IMGFILE ] && echolog "Imagen $IMGFILE no existe" && exit 1
# Para imagenes EXT4 reduzco, para BTRFS solo desmonto.
if file $IMGFILE |grep -i -e " ext4 filesystem " 2>&1 > /dev/null ; then
[ -d $DIRMOUNT ] || mkdir $DIRMOUNT
mountImage "$IMGFILE" "$DIRMOUNT" || (echolog "Error al montar la imagen $IMGFILE"; exit 1)
# Si el espacio libre menor que 200Mb desmontamos la imagen y nos salimos
AVAILABLE=$(df -k|grep $DIRMOUNT|awk '{print $4}')
if [ $AVAILABLE -lt 200000 ]; then
echolog "reducir imagen REPO $PARM2 $IMGEXT. tamaño minimo, nada que hacer"
umount $DIRMOUNT || (echolog "Error al desmontar la imagen $IMGFILE"; exit 1)
else
# Calculamos la diferencia entre el tamaño interno y externo
EXTSIZE=$(ls -l --block-size=1024 $IMGFILE | cut -f5 -d" ")
INTSIZE=$(df -k|grep "$DIRMOUNT"|awk '{print $2}')
let EDGESIZE=$EXTSIZE-$INTSIZE
echolog "reducir imagen REPO $PARM2 $IMGEXT, tamaño final: $ENDSIZE"
umount $DIRMOUNT
LOOPDEVICE=$(losetup -f)
losetup $LOOPDEVICE "$IMGFILE"
# Redimensiono sistema de ficheros
echolog "resize2fs -fpM $LOOPDEVICE "
resize2fs -fpM $LOOPDEVICE # 2>&1 |logger --tag $0 --priority local0.info
mountImage "$IMGFILE" "$DIRMOUNT"
# Calculamos el tamaño final del archivo
INTSIZE=$(df -k|grep "$DIRMOUNT"|awk '{print $2}')
let EXTSIZE=$INTSIZE+$EDGESIZE
umount $DIRMOUNT || (echolog "Error al desmontar la imagen $IMGFILE"; exit 1)
# Si existe dispositivo loop lo borramos.
[ $LOOPDEVICE ] && losetup -a| grep $LOOPDEVICE &> /dev/null && losetup -d $LOOPDEVICE
# Corto el archivo al tamaño del sistema de ficheros
echo "truncate --size=\"$EXTSIZE\"k $IMGFILE"
echolog "truncate --size=\"$EXTSIZE\"k $IMGFILE"
truncate --size="$EXTSIZE"k $IMGFILE
fi
else
umount $DIRMOUNT || (echolog "Error al desmontar la imagen $IMGFILE"; exit 1)
fi
rmdir $DIRMOUNT
echo "reduced" >$LOCKFILE
;;
default)
echolog "Solicitud con parametros \"$PARM\" no realizada, no registrada o con errores"
;;
esac

BIN
sbin/ogBootServer 100755

Binary file not shown.

View File

@ -0,0 +1,47 @@
#!/bin/bash
# Script para solicitar acciones al servidor de administración desde los clientes.
# Acciones permitidas: configurar modo de arranque.
PARM=`cat`
BASEDIR=/opt/opengnsys
PATH=$PATH:$BASEDIR/bin
SERVERNAME=ogAdmServer
SERVERLOG=$BASEDIR/log/$SERVERNAME.log
# Añade registro de incidencias.
function echolog () {
logger --tag $0 --priority local0.info "$*"
echo "$*"
}
PARM1=$(echo $PARM | cut -f1 -d" ")
PARM2=$(echo $PARM | cut -f2 -d" ")
PARM3=$(echo $PARM | cut -f3 -d" ")
PARM4=$(echo $PARM | cut -f4 -d" ")
case "$PARM1" in
SET_CLIENTMODE)
#1 SET_CLIENTMODE
#2 template
#3 pc_name o group_pc
#4 modo temporal o permanente
TEMPLATE="$PARM2"
PC="$PARM3"
#incluyo parametro de MODO
MODO="$PARM4"
echolog "Ejecutar $(which setclientmode) $FILE $MCASTOPT"
#incluyo parametro de MODO
setclientmode $TEMPLATE $PC $MODO &>> $SERVERLOG
exit $?
;;
default)
echolog "Solicitud con parametros \"$PARM\" no realizada, no registrada o con errores"
;;
esac

View File

@ -30,7 +30,7 @@ class OgBootController
/**
* @OA\Post(
* path="/clients/poweroff",
* path="/poweroff",
* summary="Power off a client",
* @OA\RequestBody(
* description="JSON payload",
@ -57,7 +57,7 @@ class OgBootController
* )
* )
* )
* @Route("/clients/poweroff", name="poweroff", methods={"POST"})
* @Route("/poweroff", name="poweroff", methods={"POST"})
*/
public function poweroff(Request $request): Response
{
@ -80,7 +80,7 @@ class OgBootController
/**
* @OA\Post(
* path="/clients/reboot",
* path="/reboot",
* summary="Reboot a client",
* @OA\RequestBody(
* description="JSON payload",
@ -107,7 +107,7 @@ class OgBootController
* )
* )
* )
* @Route("/clients/reboot", name="reboot", methods={"POST"})
* @Route("/reboot", name="reboot", methods={"POST"})
*/
public function reboot(Request $request): Response
{
@ -119,7 +119,7 @@ class OgBootController
$ips = $data['clients'];
$result = $this->curlRequestService->common_request(OG_REST_CMD_REBOOT, POST, [OG_REST_PARAM_CLIENTS => $ips]);
$result = $this->curlRequestService->common_request(OG_REST_CMD_REBOOT, 'POST', [OG_REST_PARAM_CLIENTS => $ips]);
if ($result) {
return new Response('Success', Response::HTTP_OK);
@ -129,210 +129,4 @@ class OgBootController
}
/**
* @OA\Post(
* path="/clients/stop",
* summary="Stop a client",
* @OA\RequestBody(
* description="JSON payload",
* required=true,
* @OA\JsonContent(
* type="object",
* @OA\Property(property="clients", type="array", @OA\Items(type="string", example="192.168.1.1"))
* )
* ),
* @OA\Response(
* response=200,
* description="Clients stopped successfully",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="success", type="string")
* )
* ),
* @OA\Response(
* response=400,
* description="Error occurred",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="error", type="string")
* )
* )
* )
* @Route("/clients/stop", name="stop", methods={"POST"})
*/
public function stop(Request $request): Response
{
$data = json_decode($request->getContent(), true);
if (!isset($data['clients'])) {
return new Response('Invalid data', Response::HTTP_BAD_REQUEST);
}
$ips = $data['clients'];
$result = $this->curlRequestService->common_request(OG_REST_CMD_REBOOT, POST, [OG_REST_PARAM_CLIENTS => $ips]);
if ($result) {
return new Response('Success', Response::HTTP_OK);
} else {
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
/**
* @OA\Post(
* path="/clients/refresh",
* summary="Refresh a client",
* @OA\RequestBody(
* description="JSON payload",
* required=true,
* @OA\JsonContent(
* type="object",
* @OA\Property(property="clients", type="array", @OA\Items(type="string", example="192.168.1.1"))
* )
* ),
* @OA\Response(
* response=200,
* description="Clients refreshed successfully",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="success", type="string")
* )
* ),
* @OA\Response(
* response=400,
* description="Error occurred",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="error", type="string")
* )
* )
* )
* @Route("/clients/refresh", name="refresh", methods={"POST"})
*/
public function refresh(Request $request): Response
{
$data = json_decode($request->getContent(), true);
if (!isset($data['clients'])) {
return new Response('Invalid data', Response::HTTP_BAD_REQUEST);
}
$ips = $data['clients'];
$result = $this->curlRequestService->common_request(OG_REST_CMD_REFRESH, POST, [OG_REST_PARAM_CLIENTS => $ips]);
if ($result) {
return new Response('Success', Response::HTTP_OK);
} else {
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
/**
* @OA\Post(
* path="/clients/hardware",
* summary="Get hardware info of a client",
* @OA\RequestBody(
* description="JSON payload",
* required=true,
* @OA\JsonContent(
* type="object",
* @OA\Property(property="clients", type="array", @OA\Items(type="string", example="192.168.1.1"))
* )
* ),
* @OA\Response(
* response=200,
* description="Hardware info retrieved successfully",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="success", type="string")
* )
* ),
* @OA\Response(
* response=400,
* description="Error occurred",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="error", type="string")
* )
* )
* )
* @Route("/clients/hardware", name="hardware", methods={"POST"})
*/
public function hardware(Request $request): Response
{
$data = json_decode($request->getContent(), true);
if (!isset($data['clients'])) {
return new Response('Invalid data', Response::HTTP_BAD_REQUEST);
}
$ips = $data['clients'];
$result = $this->curlRequestService->common_request(OG_REST_CMD_HARDWARE, POST, [OG_REST_PARAM_CLIENTS => $ips]);
if ($result) {
return new Response('Success', Response::HTTP_OK);
} else {
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
/**
* @OA\Post(
* path="/clients/software",
* summary="Get software info of a client",
* @OA\RequestBody(
* description="JSON payload",
* required=true,
* @OA\JsonContent(
* type="object",
* @OA\Property(property="clients", type="array", @OA\Items(type="string", example="192.168.1.1")),
* @OA\Property(property="disk", type="string", example="disk1"),
* @OA\Property(property="part", type="string", example="part1")
* )
* ),
* @OA\Response(
* response=200,
* description="Software info retrieved successfully",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="success", type="string")
* )
* ),
* @OA\Response(
* response=400,
* description="Error occurred",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="error", type="string")
* )
* )
* )
* @Route("/clients/software", name="software", methods={"POST"})
*/
public function software(Request $request): Response
{
$data = json_decode($request->getContent(), true);
if (!isset($data['clients']) || !isset($data['disk']) || !isset($data['part'])) {
return new Response('Invalid data', Response::HTTP_BAD_REQUEST);
}
$ips = $data['clients'];
$disk = $data['disk'];
$part = $data['part'];
$result = $this->curlRequestService->common_request(OG_REST_CMD_SOFTWARE, POST, [OG_REST_PARAM_CLIENTS => $ips, OG_REST_PARAM_DISK => $disk, OG_REST_PARAM_PART => $part]);
if ($result) {
return new Response('Success', Response::HTTP_OK);
} else {
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
}

View File

@ -20,10 +20,14 @@ class CurlRequestService
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
OG_REST_API_TOKEN,
));
));
echo __DIR__ . '/../../../etc/ssl/WebConsole.crt.pem';
curl_setopt ($curl, CURLOPT_SSLCERT, __DIR__ . '/../../../etc/ssl/WebConsole.crt.pem');
curl_setopt ($curl, CURLOPT_SSLKEY, __DIR__ . '/../../../etc/ssl/WebConsole.key.pem');
curl_setopt ($curl, CURLOPT_SSLKEY, __DIR__ . '/../../../etc/ssl/WebConsole.key.pem');
if (curl_error($curl)) {
echo 'Error setting key: ' . curl_error($curl);
}
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
switch ($type) {
default:
case GET:
@ -34,7 +38,8 @@ class CurlRequestService
}
$curl_response = curl_exec($curl);
$info = curl_getinfo($curl);
$info = curl_getinfo($curl);
var_dump($info);
if ($curl_response === false || $info['http_code'] != 200) {
syslog(LOG_ERR, 'error occured during curl exec. Additioanl info: ' . print_r($info, TRUE));

261
symfony.lock 100644
View File

@ -0,0 +1,261 @@
{
"doctrine/annotations": {
"version": "1.14",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "a2759dd6123694c8d901d0ec80006e044c2e6457"
},
"files": [
"config/routes/annotations.yaml"
]
},
"doctrine/doctrine-bundle": {
"version": "2.11",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "2.4",
"ref": "191046a1fdd1a58fcca48d8bf2f58c45a93b1d00"
},
"files": [
"config/packages/doctrine.yaml",
"src/Entity/.gitignore",
"src/Repository/.gitignore"
]
},
"doctrine/doctrine-migrations-bundle": {
"version": "3.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "3.1",
"ref": "1d01ec03c6ecbd67c3375c5478c9a423ae5d6a33"
},
"files": [
"config/packages/doctrine_migrations.yaml",
"migrations/.gitignore"
]
},
"phpunit/phpunit": {
"version": "8.5",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "4.7",
"ref": "db276258424d15e572d35a4eb834b8f815662b25"
},
"files": [
".env.test",
"phpunit.xml.dist",
"tests/bootstrap.php"
]
},
"symfony/console": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.3",
"ref": "da0c8be8157600ad34f10ff0c9cc91232522e047"
},
"files": [
"bin/console"
]
},
"symfony/debug-bundle": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.3",
"ref": "5aa8aa48234c8eb6dbdd7b3cd5d791485d2cec4b"
},
"files": [
"config/packages/debug.yaml"
]
},
"symfony/flex": {
"version": "1.21",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "146251ae39e06a95be0fe3d13c807bcf3938b172"
},
"files": [
".env"
]
},
"symfony/framework-bundle": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.4",
"ref": "3cd216a4d007b78d8554d44a5b1c0a446dab24fb"
},
"files": [
"config/packages/cache.yaml",
"config/packages/framework.yaml",
"config/preload.php",
"config/routes/framework.yaml",
"config/services.yaml",
"public/index.php",
"src/Controller/.gitignore",
"src/Kernel.php"
]
},
"symfony/mailer": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "4.3",
"ref": "df66ee1f226c46f01e85c29c2f7acce0596ba35a"
},
"files": [
"config/packages/mailer.yaml"
]
},
"symfony/maker-bundle": {
"version": "1.50",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
"symfony/messenger": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.4",
"ref": "8bd5f27013fb1d7217191c548e340f0bdb11912c"
},
"files": [
"config/packages/messenger.yaml"
]
},
"symfony/monolog-bundle": {
"version": "3.10",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "3.7",
"ref": "aff23899c4440dd995907613c1dd709b6f59503f"
},
"files": [
"config/packages/monolog.yaml"
]
},
"symfony/notifier": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.0",
"ref": "178877daf79d2dbd62129dd03612cb1a2cb407cc"
},
"files": [
"config/packages/notifier.yaml"
]
},
"symfony/phpunit-bridge": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.3",
"ref": "07ce01a897311647520b43d4ddddad9537b99ba6"
},
"files": [
".env.test",
"bin/phpunit",
"phpunit.xml.dist",
"tests/bootstrap.php"
]
},
"symfony/routing": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.3",
"ref": "85de1d8ae45b284c3c84b668171d2615049e698f"
},
"files": [
"config/packages/routing.yaml",
"config/routes.yaml"
]
},
"symfony/security-bundle": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.3",
"ref": "98f1f2b0d635908c2b40f3675da2d23b1a069d30"
},
"files": [
"config/packages/security.yaml"
]
},
"symfony/translation": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.3",
"ref": "e28e27f53663cc34f0be2837aba18e3a1bef8e7b"
},
"files": [
"config/packages/translation.yaml",
"translations/.gitignore"
]
},
"symfony/twig-bundle": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.4",
"ref": "bb2178c57eee79e6be0b297aa96fc0c0def81387"
},
"files": [
"config/packages/twig.yaml",
"templates/base.html.twig"
]
},
"symfony/validator": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.3",
"ref": "c32cfd98f714894c4f128bb99aa2530c1227603c"
},
"files": [
"config/packages/validator.yaml"
]
},
"symfony/web-profiler-bundle": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.3",
"ref": "24bbc3d84ef2f427f82104f766014e799eefcc3e"
},
"files": [
"config/packages/web_profiler.yaml",
"config/routes/web_profiler.yaml"
]
},
"twig/extra-bundle": {
"version": "v3.8.0"
}
}

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text></svg>">
{# Run `composer require symfony/webpack-encore-bundle` to start using Symfony UX #}
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
{% endblock %}
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>

View File

@ -0,0 +1,20 @@
{% extends 'base.html.twig' %}
{% block title %}Hello DhcpController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code><a href="{{ '/home/luis/dhcp_symfony/src/Controller/DhcpController.php'|file_link(0) }}">src/Controller/DhcpController.php</a></code></li>
<li>Your template at <code><a href="{{ '/home/luis/dhcp_symfony/templates/dhcp/index.html.twig'|file_link(0) }}">templates/dhcp/index.html.twig</a></code></li>
</ul>
</div>
{% endblock %}

View File

@ -0,0 +1,11 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
require dirname(__DIR__).'/vendor/autoload.php';
if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
require dirname(__DIR__).'/config/bootstrap.php';
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}

0
translations/.gitignore vendored 100644
View File