refs #1570 Adds DEBIAN folder to create deb package of ogcore

pull/21/head
Nicolas Arenas 2025-02-20 13:57:36 +01:00
parent f9feafa9b8
commit 9292be3feb
8 changed files with 158 additions and 2 deletions

View File

@ -5,8 +5,8 @@ APP_SECRET=e95c7f17da15ce1b03d77ad655379c34
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
DATABASE_URL="mysql://root:root@ogcore-database:3306/ogcore?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
OG_1_DATABASE_URL="mysql://root:root@ogcore-database:3306/ogcore_old_og?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
DATABASE_URL="mysql://root:root@127.0.0.1:3306/ogcore?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
OG_1_DATABASE_URL="mysql://root:root@127.0.0.1:3306/ogcore_old_og?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
###< doctrine/doctrine-bundle ###
###> nelmio/cors-bundle ###

5
DEBIAN/changelog 100644
View File

@ -0,0 +1,5 @@
ogcore (1.0) unstable; urgency=low
* Initial release.
-- Your Name <your.email@example.com> Thu, 01 Jan 1970 00:00:00 +0000

12
DEBIAN/control 100644
View File

@ -0,0 +1,12 @@
Package: ogcore
Version: %%VERSION%%
Section: base
Priority: optional
Architecture: all
Depends: mariadb-server, systemd, nginx, libzip-dev, zip, unzip, php8.3-opcache,
php8.3-bcmath, php8.3-cli, php8.3-curl, php8.3-fpm, php8.3-gd,
php8.3-ldap, php8.3-mbstring, php8.3-mysql, php8.3-common,
php8.3-xml, php8.3-zip
Maintainer: Nicolas Arenas <nicolas.arenas@qindel.com>
Description: Description of the ogcore package
This is a longer description of the ogcore package.

21
DEBIAN/copyright 100644
View File

@ -0,0 +1,21 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ogcore
Source: <source URL>
Files: *
Copyright: 2023 Your Name <your.email@example.com>
License: GPL-3+
This package 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 package; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA.

54
DEBIAN/postinst 100644
View File

@ -0,0 +1,54 @@
#!/bin/bash
set -e
# Asegurarse de que el usuario exista
USER="opengnsys"
# Provisionar base de datos si es necesario en caso de instalación.
# Detectar si es una instalación nueva o una actualización
if [ "$1" = "configure" ] && [ -z "$2" ]; then
cd /opt/opengnsys/ogcore/api
mariadb -e "GRANT ALL ON *.* to 'root'@'localhost' IDENTIFIED BY 'root' WITH GRANT OPTION;"
echo "Primera instalación"
# Provisionar base de datos si es necesario en caso de instalación.
echo "Creando par de claves para JWT"
php bin/console lexik:jwt:generate-keypair --overwrite
echo "Creando base de datos y cargando datos iniciales"
php bin/console doctrine:database:create --if-not-exists
php bin/console doctrine:migrations:migrate --no-interaction
# Cargar datos iniciales
echo "Cargando datos iniciales"
php bin/console opengnsys:load-default-user
echo "Cargando usuarios y grupos por defecto"
php bin/console app:load-default-user-groups
echo "Cargando comandos por defecto"
php bin/console app:load-default-commands
echo "Cargando menú por defecto"
php bin/console opengnsys:load-default-menu
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
cd /opt/opengnsys/ogcore/api
echo "Actualización desde la versión $2"
# Ejecutar comandos específicos para la actualización
php bin/console doctrine:migrations:migrate --no-interaction
# Otros comandos específicos para la actualización
fi
# Cambiar la propiedad de los archivos al usuario especificado
chown opengnsys:www-data /opt/opengnsys/
chown -R opengnsys:www-data /opt/opengnsys/ogcore
# Install http server stuff
ln -s /opt/opengnsys/ogcore/etc/nginx/sites-available/ogcore.conf /etc/nginx/sites-enabled/ogcore.conf
ln -s /opt/opengnsys/ogcore/etc/php/8.3/fpm/pool.d/ogcore-fpm.conf /etc/php/8.3/fpm/pool.d/ogcore-fpm.conf
# Reiniciar servicios si es necesario
# systemctl restart nombre_del_servicio
systemctl daemon-reload
systemctl restart nginx
systemctl restart php8.3-fpm
exit 0

15
DEBIAN/preinst 100644
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

View File

@ -0,0 +1,37 @@
server {
listen 8443 ssl;
server_name _;
root /opt/opengnsys/ogcore/api/public/;
index index.html index.php;
ssl_certificate /opt/opengnsys/ogcore/etc/nginx/certs/ogcore.uds-test.net.crt.pem;
ssl_certificate_key /opt/opengnsys/ogcore/etc/nginx/certs/ogcore.uds-test.net.key.pem;
location /opengnsys/rest/ous// {
rewrite ^/opengnsys/rest/ous//([0-9]+)/images /opengnsys/rest/ous/$1/images;
rewrite ^/opengnsys/rest/ous//([0-9]+)/labs /opengnsys/rest/ous/$1/labs;
}
# Bloque principal para archivos
location / {
try_files $uri $uri/ /index.php?$args;
}
# Manejo de PHP
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php8.3-fpm-ogcore.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $request_uri;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
}
# Bloque para errores PHP
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/ogcore-error.log;
access_log /var/log/nginx/ogcore-access.log;
}

View File

@ -0,0 +1,12 @@
[ogcore]
user = opengnsys
group = www-data
listen = /run/php/php8.3-fpm-ogcore.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