diff --git a/.gitignore b/.gitignore index f13e383..1e65fb0 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,13 @@ output.xml log.html report.html __pycache__ + +### Debian packaging +debian/ogdhcp +debian/*.substvars +debian/*.log +debian/.debhelper/ +debian/files +debian/*.debhelper +debian/*.debhelper.log +debian/debhelper-build-stamp diff --git a/debian/README b/debian/README new file mode 100644 index 0000000..7001dac --- /dev/null +++ b/debian/README @@ -0,0 +1,6 @@ +The Debian Package ogdhcp +---------------------------- + + + + -- vagrant Wed, 05 Mar 2025 19:49:47 +0000 diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..a49256c --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,6 @@ +ogdhcp for Debian +---------------- + + + + -- vagrant Wed, 05 Mar 2025 19:49:47 +0000 diff --git a/debian/README.source b/debian/README.source new file mode 100644 index 0000000..6374145 --- /dev/null +++ b/debian/README.source @@ -0,0 +1,10 @@ +ogdhcp for Debian +---------------- + + + + + + -- vagrant Wed, 05 Mar 2025 19:49:47 +0000 + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..e847c2a --- /dev/null +++ b/debian/changelog @@ -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 Mon, 10 Mar 2025 19:58:42 +0000 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..862725a --- /dev/null +++ b/debian/control @@ -0,0 +1,40 @@ +Source: ogdhcp +Section: unknown +Priority: optional +Maintainer: vagrant +Rules-Requires-Root: no +Build-Depends: + debhelper-compat (= 13), +Standards-Version: 4.6.2 +Homepage: +#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: + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..f8b5f05 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,43 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Source: +Upstream-Name: ogdhcp +Upstream-Contact: + +Files: + * +Copyright: + + +License: GPL-3.0+ + +Files: + debian/* +Copyright: + 2025 vagrant +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 . +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/ diff --git a/debian/ogdhcp.config b/debian/ogdhcp.config new file mode 100644 index 0000000..915a1f7 --- /dev/null +++ b/debian/ogdhcp.config @@ -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 diff --git a/debian/ogdhcp.dirs b/debian/ogdhcp.dirs new file mode 100644 index 0000000..5243f28 --- /dev/null +++ b/debian/ogdhcp.dirs @@ -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 diff --git a/debian/ogdhcp.install b/debian/ogdhcp.install new file mode 100644 index 0000000..32f1706 --- /dev/null +++ b/debian/ogdhcp.install @@ -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/ diff --git a/debian/ogdhcp.postinst b/debian/ogdhcp.postinst new file mode 100644 index 0000000..c989654 --- /dev/null +++ b/debian/ogdhcp.postinst @@ -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" < "$KEA_CONFIG" <&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 diff --git a/debian/ogdhcp.preinst b/debian/ogdhcp.preinst new file mode 100755 index 0000000..0761132 --- /dev/null +++ b/debian/ogdhcp.preinst @@ -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 diff --git a/debian/ogdhcp.prerm b/debian/ogdhcp.prerm new file mode 100644 index 0000000..bdb2829 --- /dev/null +++ b/debian/ogdhcp.prerm @@ -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 diff --git a/debian/ogdhcp.templates b/debian/ogdhcp.templates new file mode 100644 index 0000000..ca83324 --- /dev/null +++ b/debian/ogdhcp.templates @@ -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 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..080c8df --- /dev/null +++ b/debian/rules @@ -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 ). +#override_dh_auto_configure: +# dh_auto_configure -- \ +# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/etc/php/fpm/ogdhcp-fpm.conf b/etc/php/fpm/ogdhcp-fpm.conf new file mode 100644 index 0000000..ff20b37 --- /dev/null +++ b/etc/php/fpm/ogdhcp-fpm.conf @@ -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 + diff --git a/etc/systemd/system/kea-ctrl-agent.service.d/override.conf b/etc/systemd/system/kea-ctrl-agent.service.d/override.conf new file mode 100644 index 0000000..865ee5c --- /dev/null +++ b/etc/systemd/system/kea-ctrl-agent.service.d/override.conf @@ -0,0 +1,4 @@ +[Unit] +# Eliminamos la condición de existencia del archivo de contraseña +ConditionFileNotEmpty= +