First deb commit
testing/og-dhcp-API/pipeline/pr-main There was a failure building this commit Details
testing/og-dhcp-API/pipeline/head There was a failure building this commit Details

pull/4/head
Nicolas Arenas 2025-03-10 21:03:13 +01:00
parent c0ee3837c5
commit f1413dae81
18 changed files with 449 additions and 0 deletions

10
.gitignore vendored
View File

@ -38,3 +38,13 @@ output.xml
log.html log.html
report.html report.html
__pycache__ __pycache__
### Debian packaging
debian/ogdhcp
debian/*.substvars
debian/*.log
debian/.debhelper/
debian/files
debian/*.debhelper
debian/*.debhelper.log
debian/debhelper-build-stamp

6
debian/README vendored 100644
View File

@ -0,0 +1,6 @@
The Debian Package ogdhcp
----------------------------
<Comments regarding the Package.>
-- vagrant <vagrant@build> Wed, 05 Mar 2025 19:49:47 +0000

6
debian/README.Debian vendored 100644
View File

@ -0,0 +1,6 @@
ogdhcp for Debian
----------------
<Possible notes regarding this package - if none, delete this file.>
-- vagrant <vagrant@build> Wed, 05 Mar 2025 19:49:47 +0000

10
debian/README.source vendored 100644
View File

@ -0,0 +1,10 @@
ogdhcp for Debian
----------------
<This file describes information about the source package, see Debian policy
manual section 4.14. You WILL either need to modify or delete this file.>
-- vagrant <vagrant@build> Wed, 05 Mar 2025 19:49:47 +0000

14
debian/changelog vendored 100644
View File

@ -0,0 +1,14 @@
ogdhcp (1.0.2+pkg-deb20250310-1) unstable; urgency=medium
* Updates changelog 0.6.0
* Merge pull request 'new-parameters-subnet' (#3) from new-parameters-subnet into main
* refs #1543 fix swagger annotation
* refs #1568 adds new parameters subnetName and dns to kea dhcp
* refs #1581 fix backup permissions in installer
* refs #1468 update CHANGELOG
* refs #1468 fix bug and permissions in opt opengnsys
* refs #1468 updates CHANGELOG
* refs #1468 changes home of the opengnsys user
* Adds changelog
-- Tu Nombre <tuemail@example.com> Mon, 10 Mar 2025 19:58:42 +0000

40
debian/control vendored 100644
View File

@ -0,0 +1,40 @@
Source: ogdhcp
Section: unknown
Priority: optional
Maintainer: vagrant <vagrant@build>
Rules-Requires-Root: no
Build-Depends:
debhelper-compat (= 13),
Standards-Version: 4.6.2
Homepage: <insert the upstream URL, if relevant>
#Vcs-Browser: https://salsa.debian.org/debian/ogdhcp
#Vcs-Git: https://salsa.debian.org/debian/ogdhcp.git
Package: ogdhcp
Architecture: any
Multi-Arch: foreign
Depends: ${shlibs:Depends}, ${misc:Depends}, debconf (>= 1.5.0),
php,
php-cli,
php-fpm,
php-json,
php-pdo,
php-mysql,
php-zip,
php-gd,
php-mbstring,
php-curl,
php-xml,
php-pear,
php-bcmath,
composer,
unzip,
kea-dhcp4-server,
kea-common,
kea-ctrl-agent,
jq,
net-tools,
nginx
Conflicts: apache2
Description: <insert up to 60 chars description>
<Insert long description, indented with spaces.>

43
debian/copyright vendored 100644
View File

@ -0,0 +1,43 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: <url://example.com>
Upstream-Name: ogdhcp
Upstream-Contact: <preferred name and address to reach the upstream project>
Files:
*
Copyright:
<years> <put author's name and email here>
<years> <likewise for another author>
License: GPL-3.0+
Files:
debian/*
Copyright:
2025 vagrant <vagrant@build>
License: GPL-3.0+
License: GPL-3.0+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Comment:
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
# Please also look if there are files or directories which have a
# different copyright/license attached and list them here.
# Please avoid picking licenses with terms that are more restrictive than the
# packaged work, as it may make Debian's contributions unacceptable upstream.
#
# If you need, there are some extra license texts available in two places:
# /usr/share/debhelper/dh_make/licenses/
# /usr/share/common-licenses/

11
debian/ogdhcp.config vendored 100644
View File

@ -0,0 +1,11 @@
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
db_input high opengnsys/ogdhcp_interfaces || true
db_input high opengnsys/ogdhcp_ip|| true
db_input high opengnsys/ogdhcp_ogbootIP || true
db_go

11
debian/ogdhcp.dirs vendored 100644
View File

@ -0,0 +1,11 @@
/opt/opengnsys/ogdhcp
/opt/opengnsys/ogdhcp/bin
/opt/opengnsys/ogdhcp/config
/opt/opengnsys/ogdhcp/docs
/opt/opengnsys/ogdhcp/public
/opt/opengnsys/ogdhcp/src
/opt/opengnsys/ogdhcp/etc/kea/backup
/opt/opengnsys/ogdhcp/templates
/opt/opengnsys/ogdhcp/var/cache
/opt/opengnsys/ogdhcp/var/log
/opt/opengnsys/ogdhcp/vendor

15
debian/ogdhcp.install vendored 100644
View File

@ -0,0 +1,15 @@
config /opt/opengnsys/ogdhcp/
public /opt/opengnsys/ogdhcp/
src /opt/opengnsys/ogdhcp/
etc /opt/opengnsys/ogdhcp/
templates /opt/opengnsys/ogdhcp/
migrations /opt/opengnsys/ogdhcp/
translations /opt/opengnsys/ogdhcp/
docs /opt/opengnsys/ogdhcp/
var /opt/opengnsys/ogdhcp/
vendor /opt/opengnsys/ogdhcp/
composer.json /opt/opengnsys/ogdhcp/
composer.lock /opt/opengnsys/ogdhcp/
symfony.lock /opt/opengnsys/ogdhcp/
.env.local.php /opt/opengnsys/ogdhcp/
etc/systemd/system/kea-ctrl-agent.service.d/override.conf /etc/systemd/system/kea-ctrl-agent.service.d/

128
debian/ogdhcp.postinst vendored 100644
View File

@ -0,0 +1,128 @@
#!/bin/bash
set -e
. /usr/share/debconf/confmodule
KEA_CTRL_AGENT_CONF="/etc/kea/kea-ctrl-agent.conf"
db_get opengnsys/ogdhcp_interfaces
OGDHCP_INTERFACES="$RET"
db_get opengnsys/ogdhcp_ip
OGDHCP_IP="$RET"
db_get opengnsys/ogdhcp_ogbootIP
OGBOOT_IP="$RET"
case "$1" in
configure)
echo "Configurando ogdhcp..."
# Configuración de kea-ctrl-agent
echo "Eliminando autenticación de kea-ctrl-agent..."
if [ -e "$KEA_CTRL_AGENT_CONF" ]; then
dpkg-divert --package ogdhcp --divert "$KEA_CTRL_AGENT_CONF.dpkg-dist" --rename "$KEA_CTRL_AGENT_CONF"
cp -a "$KEA_CTRL_AGENT_CONF.dpkg-dist" "$KEA_CTRL_AGENT_CONF"
if grep -q '^[^#]*"authentication": {' "$KEA_CTRL_AGENT_CONF"; then
sed -i '/"authentication": {/,/^[[:space:]]*},/ {
s/^\([[:space:]]*\)\([^#]\)/\1#\2/
}' "$KEA_CTRL_AGENT_CONF"
fi
fi
# Configuración de AppArmor
APPARMOR_LOCAL_PROFILE="/etc/apparmor.d/local/usr.sbin.kea-dhcp4"
echo "Añadiendo permisos personalizados a AppArmor para kea-dhcp4..."
mkdir -p "$(dirname "$APPARMOR_LOCAL_PROFILE")"
cat > "$APPARMOR_LOCAL_PROFILE" <<EOF
/etc/kea/ rw,
/etc/kea/** rw,
EOF
echo "Recargando perfiles de AppArmor..."
apparmor_parser -r /etc/apparmor.d/usr.sbin.kea-dhcp4
if [ $? -eq 0 ]; then
echo "El perfil de AppArmor se recargó correctamente."
else
echo "Error al recargar el perfil de AppArmor."
fi
# Configuración de nginx
echo "Configurando nginx..."
PHP_VERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')
if [ ! -f /etc/nginx/sites-available/ogdhcp.conf ]; then
cp /opt/opengnsys/ogdhcp/etc/nginxServer.conf.tmpl /etc/nginx/sites-available/ogdhcp.conf
sed -i "s|__PHPVERSION__|$PHP_VERSION|g" /etc/nginx/sites-available/ogdhcp.conf
sed -i "s|__SERVERIP__|$OGDHCP_IP|g" /etc/nginx/sites-available/ogdhcp.conf
sed -i "s|__PUBLICDIR__|/opt/opengnsys/ogdhcp/public|g" /etc/nginx/sites-available/ogdhcp.conf
ln -s /etc/nginx/sites-available/ogdhcp.conf /etc/nginx/sites-enabled/ogdhcp.conf
else
echo "El archivo /etc/nginx/sites-available/ogdhcp.conf ya existe."
fi
# Configuración de php-fpm
echo "Configurando php-fpm..."
if [ ! -f /etc/php/$PHP_VERSION/fpm/pool.d/ogdhcp.conf ]; then
cp /opt/opengnsys/ogdhcp/etc/php/fpm/ogdhcp-fpm.conf /etc/php/$PHP_VERSION/fpm/pool.d/ogdhcp.conf
fi
# Configuración de kea-dhcp4
echo "Configurando kea-dhcp4..."
IFS=',' read -r -a INTERFACES <<< "$OGDHCP_INTERFACES"
KEA_CONFIG="/etc/kea/kea-dhcp4.conf"
if [ -e "$KEA_CONFIG" ]; then
dpkg-divert --package ogdhcp --divert "$KEA_CONFIG.dpkg-dist" --rename "$KEA_CONFIG"
cat > "$KEA_CONFIG" <<EOF
{
"Dhcp4": {
"interfaces-config": {
"interfaces": [ $(
for interface in "${INTERFACES[@]}"; do
echo "\"$interface\""
done | paste -sd "," -
) ]
},
"client-classes": [
{
"name": "UEFI-64",
"test": "not substring(option[60].hex,0,20) == 'PXEClient:Arch:00000'",
"boot-file-name": "ipxe.efi",
"next-server": "$OGBOOT_IP"
},
{
"name": "Legacy",
"test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:00000'",
"boot-file-name": "undionly.kpxe",
"next-server": "$OGBOOT_IP"
}
],
"control-socket": {
"socket-name": "/run/kea/kea4-ctrl-socket",
"socket-type": "unix"
}
}
}
EOF
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument '$1'" >&2
exit 1
;;
esac
chown opengnsys:www-data /opt/opengnsys/
chown -R opengnsys:www-data /opt/opengnsys/ogdhcp
chown -R _kea:_kea /etc/kea
# Reiniciar servicios
systemctl daemon-reload
systemctl restart nginx
systemctl restart kea-dhcp4-server
systemctl restart kea-ctrl-agent
systemctl restart php$PHP_VERSION-fpm
exit 0

15
debian/ogdhcp.preinst vendored 100755
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e
# Asegurarse de que el usuario exista
USER="opengnsys"
HOME_DIR="/opt/opengnsys"
if id "$USER" &>/dev/null; then
echo "El usuario $USER ya existe."
else
echo "Creando el usuario $USER con home en $HOME_DIR."
useradd -m -d "$HOME_DIR" -s /bin/bash "$USER"
fi
exit 0

69
debian/ogdhcp.prerm vendored 100644
View File

@ -0,0 +1,69 @@
#!/bin/bash
set -e
KEA_CTRL_AGENT_CONF="/etc/kea/kea-ctrl-agent.conf"
KEA_CONFIG="/etc/kea/kea-dhcp4.conf"
APPARMOR_LOCAL_PROFILE="/etc/apparmor.d/local/usr.sbin.kea-dhcp4"
NGINX_CONF="/etc/nginx/sites-available/ogdhcp.conf"
PHP_FPM_CONF="/etc/php/*/fpm/pool.d/ogdhcp.conf"
case "$1" in
remove)
echo "Preparando eliminación de ogdhcp..."
# Restaurar el archivo kea-ctrl-agent.conf original si se modificó
if [ -e "$KEA_CTRL_AGENT_CONF.dpkg-dist" ]; then
echo "Restaurando configuración original de kea-ctrl-agent..."
mv -f "$KEA_CTRL_AGENT_CONF.dpkg-dist" "$KEA_CTRL_AGENT_CONF"
dpkg-divert --package ogdhcp --remove --divert "$KEA_CTRL_AGENT_CONF.dpkg-dist" --rename "$KEA_CTRL_AGENT_CONF"
fi
# Restaurar el archivo kea-dhcp4.conf original si se modificó
if [ -e "$KEA_CONFIG.dpkg-dist" ]; then
echo "Restaurando configuración original de kea-dhcp4..."
mv -f "$KEA_CONFIG.dpkg-dist" "$KEA_CONFIG"
dpkg-divert --package ogdhcp --remove --divert "$KEA_CONFIG.dpkg-dist" --rename "$KEA_CONFIG"
fi
# Eliminar perfil personalizado de AppArmor
if [ -f "$APPARMOR_LOCAL_PROFILE" ]; then
echo "Eliminando perfil de AppArmor personalizado..."
rm -f "$APPARMOR_LOCAL_PROFILE"
apparmor_parser -r /etc/apparmor.d/usr.sbin.kea-dhcp4 || true
fi
# Eliminar configuración de nginx
if [ -f "$NGINX_CONF" ]; then
echo "Eliminando configuración de nginx..."
rm -f "$NGINX_CONF"
rm -f "/etc/nginx/sites-enabled/ogdhcp.conf"
fi
# Eliminar configuración de php-fpm
echo "Eliminando configuración de php-fpm..."
rm -f $PHP_FPM_CONF
# Restaurar permisos de directorios
echo "Restaurando permisos en /opt/opengnsys..."
chown root:root /opt/opengnsys/
chown -R root:root /opt/opengnsys/ogdhcp
# Detener servicios antes de eliminar el paquete
echo "Deteniendo servicios..."
systemctl stop nginx || true
systemctl stop kea-dhcp4-server || true
systemctl stop kea-ctrl-agent || true
systemctl stop php*-fpm || true
;;
upgrade|deconfigure)
echo "Preparando actualización o desconfiguración de ogdhcp..."
;;
*)
echo "prerm llamado con un argumento desconocido '$1'" >&2
exit 1
;;
esac
exit 0

19
debian/ogdhcp.templates vendored 100644
View File

@ -0,0 +1,19 @@
Template: opengnsys/ogdhcp_interfaces
Type: string
Default: eth0
Description: Interfaces para DHCP
Template: opengnsys/ogdhcp_ip
Type: string
Default: 127.0.0.1
Description: IP para el servicio de ogdhcp
Template: opengnsys/ogboot_ogliveUrl
Type: string
Default: 127.0.0.1
Description: URL del OgLive a instalar
Template: opengnsys/ogdhcp_ogbootIP
Type: string
Default: 127.0.0.1
Description: Ip para el servicio de ogBoot

35
debian/rules vendored 100755
View File

@ -0,0 +1,35 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1
# See FEATURE AREAS in dpkg-buildflags(1).
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%:
dh $@
override_dh_auto_build:
export COMPOSER_ALLOW_SUPERUSER=1
export APP_ENV=prod
dh_auto_build
rm -rf var/cache/*
composer install
composer dump-env prod
composer update doctrine/dbal
# dh_make generated override targets.
# This is an example for Cmake (see <https://bugs.debian.org/641051>).
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

1
debian/source/format vendored 100644
View File

@ -0,0 +1 @@
3.0 (native)

View File

@ -0,0 +1,12 @@
[ogdhcp]
user = opengnsys
group = www-data
listen = /var/run/php/php8.3-fpm-ogdhcp.sock
listen.owner = opengnsys
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

View File

@ -0,0 +1,4 @@
[Unit]
# Eliminamos la condición de existencia del archivo de contraseña
ConditionFileNotEmpty=