First version fo deb packages
parent
3a2f96d5e9
commit
5755afba00
|
@ -0,0 +1,9 @@
|
|||
### Debian packaging
|
||||
debian/ogrepository
|
||||
debian/*.substvars
|
||||
debian/*.log
|
||||
debian/.debhelper/
|
||||
debian/files
|
||||
debian/*.debhelper
|
||||
debian/*.debhelper.log
|
||||
debian/debhelper-build-stamp
|
|
@ -1,5 +0,0 @@
|
|||
ogrepository (1.0) unstable; urgency=low
|
||||
|
||||
* Initial release.
|
||||
|
||||
-- Your Name <nicolas.arenas@qindel.com> Thu, 01 Jan 1970 00:00:00 +0000
|
|
@ -1,9 +0,0 @@
|
|||
Package: ogrepository
|
||||
Version: %%VERSION%%
|
||||
Section: base
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
Depends: git, python3, python3-pip, python3-flask, python3-paramiko, python3-psutil, python3-flasgger, debian-archive-keyring ,samba, gunicorn, wakeonlan
|
||||
Maintainer: Nicolas Arenas <nicolas.arenas@qindel.com>
|
||||
Description: Description of the ogcore package
|
||||
This is a longer description of the ogcore package.
|
|
@ -1,21 +0,0 @@
|
|||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: ogrepository
|
||||
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.
|
|
@ -1,35 +0,0 @@
|
|||
#!/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
|
||||
systemd-run --no-block /bin/bash -c "sleep 10; apt update -y && apt install -y bittorrent bittornado ctorrent"
|
||||
sed -i "s/%%OGREPOSITORY_USER%%/$USER/g" /etc/systemd/system/ogrepo-api.service
|
||||
sed -i "s/%%OGREPOSITORY_USER%%/$USER/g" /etc/samba/smb.conf.ogrepository
|
||||
echo "include = /etc/samba/smb.conf.ogrepository" >> /etc/samba/smb.conf
|
||||
systemctl enable ogrepo-api
|
||||
systemctl restart smbd
|
||||
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
|
||||
echo "Actualización desde la versión $2"
|
||||
fi
|
||||
|
||||
# Cambiar la propiedad de los archivos al usuario especificado
|
||||
chown opengnsys:www-data /opt/opengnsys/
|
||||
chown -R opengnsys:www-data /opt/opengnsys/ogrepository
|
||||
|
||||
# Install http server stuff
|
||||
# Reiniciar servicios si es necesario
|
||||
# systemctl restart nombre_del_servicio
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl restart ogrepo-api
|
||||
|
||||
exit 0
|
|
@ -1,15 +0,0 @@
|
|||
#!/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
|
|
@ -0,0 +1,6 @@
|
|||
The Debian Package ogrepository
|
||||
----------------------------
|
||||
|
||||
<Comments regarding the Package.>
|
||||
|
||||
-- vagrant <vagrant@build> Thu, 06 Mar 2025 07:16:52 +0000
|
|
@ -0,0 +1,6 @@
|
|||
ogrepository for Debian
|
||||
----------------------
|
||||
|
||||
<Possible notes regarding this package - if none, delete this file.>
|
||||
|
||||
-- vagrant <vagrant@build> Thu, 06 Mar 2025 07:16:52 +0000
|
|
@ -0,0 +1,10 @@
|
|||
ogrepository 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> Thu, 06 Mar 2025 07:16:52 +0000
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
ogrepository (1.0.0+deb-packages20250311-1) unstable; urgency=medium
|
||||
|
||||
* First debian version
|
||||
* Merge pull request 'refs #1530 - Add 'backupImage.py' and related endpoint' (#22) from add_python_scripts into main
|
||||
* refs #1530 - Add 'backupImage.py' and related endpoint
|
||||
* Merge pull request 'refs #1482 - Modify Paramiko SSH Client parameters' (#21) from add_python_scripts into main
|
||||
* refs #1482 - Modify Paramiko SSH Client parameters
|
||||
* Merge pull request 'add_python_scripts' (#20) from add_python_scripts into main
|
||||
* refs #1444 - Modify API help
|
||||
* refs #1444 - Modify transfers between repositories
|
||||
* Merge pull request 'refs #1437 - Scripts corrections' (#19) from add_python_scripts into main
|
||||
* refs #1437 - Scripts corrections
|
||||
|
||||
-- Tu Nombre <tuemail@example.com> Tue, 11 Mar 2025 04:43:58 +0000
|
|
@ -0,0 +1,13 @@
|
|||
Source: ogrepository
|
||||
Section: base
|
||||
Priority: optional
|
||||
Maintainer: Nicolas Arenas <nicolas.arenas@qindel.com>
|
||||
Standards-Version: 4.5.0
|
||||
Build-Depends: debhelper-compat (= 12)
|
||||
|
||||
Package: ogrepository
|
||||
Architecture: all
|
||||
Pre-Depends: debian-archive-keyring , debconf (>= 1.5.0),
|
||||
Depends: ${misc:Depends}, git, python3, python3-pip, python3-flask, python3-paramiko, python3-psutil, python3-flasgger, samba, gunicorn, wakeonlan , lzop , partclone , qemu-utils , udpcast
|
||||
Description: Ogrepsoitory Package
|
||||
This package provides Ogrepsoitory service.
|
|
@ -0,0 +1,43 @@
|
|||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Source: <url://example.com>
|
||||
Upstream-Name: ogrepository
|
||||
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/
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
|
||||
# Leer las variables de configuración
|
||||
|
||||
db_input high opengnsys/ogrepository_ogrepoIp || true
|
||||
db_input high opengnsys/ogrepository_ogcoreIp || true
|
||||
db_input high opengnsys/ogrepository_sambaUser || true
|
||||
db_input high opengnsys/ogrepository_sambaUserPass || true
|
||||
|
||||
db_go
|
|
@ -0,0 +1,4 @@
|
|||
/opt/opengnsys/ogrepository/images_virtual
|
||||
/opt/opengnsys/ogrepository/images
|
||||
/opt/opengnsys/ogrepository/images_trash
|
||||
/opt/opengnsys/ogrepository/log
|
|
@ -0,0 +1,8 @@
|
|||
api/* /opt/opengnsys/ogrepository/api/
|
||||
bin/* /opt/opengnsys/ogrepository/bin/
|
||||
etc/* /opt/opengnsys/ogrepository/etc/
|
||||
installer/files/ctorrent.sources /etc/apt/sources.list.d/
|
||||
installer/files/ogrepo-api.service /etc/systemd/system/
|
||||
installer/files/ogrepo-smb.conf /etc/samba/
|
||||
installer/ssh-keys/* /opt/opengnsys/ogrepository/etc/
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
# Cargar variables de configuración
|
||||
db_get opengnsys/ogrepository_ogrepoIp
|
||||
OGREPO_IP="$RET"
|
||||
db_get opengnsys/ogrepository_ogcoreIp
|
||||
OGCORE_IP="$RET"
|
||||
db_get opengnsys/ogrepository_sambaUser
|
||||
SAMBA_USER="$RET"
|
||||
db_get opengnsys/ogrepository_sambaUserPass
|
||||
SAMBA_PASS="$RET"
|
||||
|
||||
# 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
|
||||
systemd-run --no-block /bin/bash -c "
|
||||
sleep 10;
|
||||
apt update -y;
|
||||
for pkg in bittorrent bittornado ctorrent; do
|
||||
if ! dpkg -l | grep -qw \"\$pkg\"; then
|
||||
apt install -y \"\$pkg\"
|
||||
fi
|
||||
done
|
||||
"
|
||||
|
||||
sed -i "s/%%OGREPOSITORY_USER%%/$SAMBA_USER/g" /etc/systemd/system/ogrepo-api.service
|
||||
sed -i "s/%%OGREPOSITORY_USER%%/$SAMBA_USER/g" /etc/samba/ogrepo-smb.conf
|
||||
|
||||
# Install ssh keys on opengnsys user
|
||||
# Get opengnsys home directory
|
||||
OPENGNSYS_HOME=$(getent passwd opengnsys | cut -d: -f6)
|
||||
# Create .ssh directory
|
||||
mkdir -p $OPENGNSYS_HOME/.ssh
|
||||
# Copy ssh keys
|
||||
cp /opt/opengnsys/ogrepository/etc/opengnsys $OPENGNSYS_HOME/.ssh/id_ed25519
|
||||
cp /opt/opengnsys/ogrepository/etc/opengnsys.pub $OPENGNSYS_HOME/.ssh/id_ed25519.pub
|
||||
|
||||
if [ -f /etc/samba/smb.conf ]; then
|
||||
dpkg-divert --package ogrepository --add --rename --divert /etc/samba/smb.conf.orig /etc/samba/smb.conf
|
||||
fi
|
||||
# Incluir el archivo de configuración de samba si no está incluido ya
|
||||
if ! grep -q "include = /etc/samba/ogrepo-smb.conf" /etc/samba/smb.conf; then
|
||||
echo "include = /etc/samba/ogrepo-smb.conf" >> /etc/samba/smb.conf
|
||||
fi
|
||||
|
||||
(echo "$SAMBA_PASS"; echo "$SAMBA_PASS") | smbpasswd -a $SAMBA_USER
|
||||
|
||||
# Configure Repo
|
||||
|
||||
cp /opt/opengnsys/ogrepository/etc/ogAdmRepo.cfg.tmpl /opt/opengnsys/ogrepository/etc/ogAdmRepo.cfg
|
||||
sed -i "s/SERVERIP/$OGREPO_IP/g" /opt/opengnsys/ogrepository/etc/ogAdmRepo.cfg
|
||||
sed -i "s/OGCOREIP/$OGCORE_IP/g" /opt/opengnsys/ogrepository/etc/ogAdmRepo.cfg
|
||||
|
||||
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
|
||||
echo "Actualización desde la versión $2"
|
||||
fi
|
||||
|
||||
# Cambiar la propiedad de los archivos al usuario especificado
|
||||
chown opengnsys:www-data /opt/opengnsys/
|
||||
chown -R opengnsys:www-data /opt/opengnsys/ogrepository
|
||||
|
||||
# Install http server stuff
|
||||
# Reiniciar servicios si es necesario
|
||||
# systemctl restart nombre_del_servicio
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable ogrepo-api
|
||||
systemctl restart ogrepo-api
|
||||
systemctl restart smbd
|
||||
|
||||
# echo "ogrepository-trigger" > /var/lib/dpkg/triggers/ogrepository.trigger
|
||||
# POST_INVOKE_SCRIPT="/var/lib/dpkg/info/ogrepository.trigger"
|
||||
|
||||
# echo "Registrando post-invoke para instalación de paquetes adicionales..."
|
||||
|
||||
# cat <<EOF > "$POST_INVOKE_SCRIPT"
|
||||
# #!/bin/sh
|
||||
# set -e
|
||||
|
||||
# echo "Ejecutando post-trigger: Instalando bittorrent, bittornado y ctorrent..."
|
||||
|
||||
# export DEBIAN_FRONTEND=noninteractive
|
||||
# apt-get update
|
||||
# apt-get install -y bittorrent bittornado ctorrent
|
||||
|
||||
# echo "Instalación de paquetes adicionales completada."
|
||||
|
||||
# exit 0
|
||||
# EOF
|
||||
|
||||
# chmod +x "$POST_INVOKE_SCRIPT"
|
||||
|
||||
# # Intentar ejecutar el script ahora si no hay otro proceso de apt corriendo
|
||||
# if ! pgrep -x "apt" > /dev/null; then
|
||||
# echo "Ejecutando instalación de paquetes adicionales inmediatamente..."
|
||||
# "$POST_INVOKE_SCRIPT"
|
||||
# else
|
||||
# echo "Apt está en uso, los paquetes se instalarán después."
|
||||
# fi
|
||||
|
||||
# find /opt/opengnsys/ogrepository -type f -name "*.py" -exec chmod +x {} \;
|
||||
|
||||
# dpkg-trigger --by-package=ogrepository ogrepository-trigger
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
KEY_FILE="/usr/share/keyrings/debian-archive-buster-stable.gpg"
|
||||
REPO_FILE="/etc/apt/sources.list.d/buster.list"
|
||||
|
||||
# Asegurarse de que el usuario exista
|
||||
USER="opengnsys"
|
||||
HOME_DIR="/opt/opengnsys"
|
||||
if id "$USER" >/dev/null 2>&1; 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
|
||||
echo "Añadiendo el repositorio de Debian Buster en $REPO_FILE..."
|
||||
|
||||
# Crear el directorio si no existe
|
||||
mkdir -p "$(dirname "$REPO_FILE")"
|
||||
|
||||
# Crear el archivo de repositorio si no existe
|
||||
if [ ! -f "$REPO_FILE" ]; then
|
||||
echo "deb [signed-by=$KEY_FILE] http://ftp.de.debian.org/debian buster main" > "$REPO_FILE"
|
||||
else
|
||||
echo "El repositorio ya está configurado en $REPO_FILE"
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,60 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
remove|purge)
|
||||
echo "Deteniendo y deshabilitando servicios..."
|
||||
systemctl stop ogrepo-api || true
|
||||
systemctl disable ogrepo-api || true
|
||||
|
||||
systemctl stop smbd || true
|
||||
systemctl stop nmbd || true
|
||||
|
||||
# Restaurar configuración original de Samba si fue modificada
|
||||
if [ -f /etc/samba/smb.conf.ogrepository ]; then
|
||||
echo "Restaurando configuración original de Samba..."
|
||||
mv /etc/samba/smb.conf.ogrepository /etc/samba/smb.conf
|
||||
dpkg-divert --remove --rename /etc/samba/smb.conf
|
||||
fi
|
||||
|
||||
# Eliminar configuración específica de ogrepository en Samba
|
||||
if grep -q "include = /etc/samba/ogrepo-smb.conf" /etc/samba/smb.conf; then
|
||||
echo "Eliminando referencia a ogrepo-smb.conf en smb.conf..."
|
||||
sed -i '/include = \/etc\/samba\/ogrepo-smb.conf/d' /etc/samba/smb.conf
|
||||
fi
|
||||
|
||||
# Eliminar usuario de Samba si es necesario
|
||||
if pdbedit -L | grep -q "^$SAMBA_USER:"; then
|
||||
echo "Eliminando usuario Samba $SAMBA_USER..."
|
||||
smbpasswd -x "$SAMBA_USER"
|
||||
fi
|
||||
|
||||
# Eliminar archivos de configuración si se trata de una purga
|
||||
if [ "$1" = "purge" ]; then
|
||||
echo "Eliminando archivos de configuración..."
|
||||
rm -rf /opt/opengnsys/ogrepository
|
||||
rm -rf /etc/samba/ogrepo-smb.conf
|
||||
rm -rf /etc/systemd/system/ogrepo-api.service
|
||||
fi
|
||||
|
||||
# Eliminar el script post-invoke si existe
|
||||
if [ -f /var/lib/dpkg/info/ogrepository.post-invoke ]; then
|
||||
echo "Eliminando script post-invoke..."
|
||||
rm -f /var/lib/dpkg/info/ogrepository.post-invoke
|
||||
fi
|
||||
|
||||
echo "Limpieza completada."
|
||||
;;
|
||||
|
||||
upgrade|deconfigure)
|
||||
# No hacer nada en actualización o desconfiguración
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "prerm llamado con un argumento desconocido '$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,19 @@
|
|||
Template: opengnsys/ogrepository_ogrepoIp
|
||||
Type: string
|
||||
Default: 127.0.0.1
|
||||
Description: IP del repositorio.
|
||||
|
||||
Template: opengnsys/ogrepository_ogcoreIp
|
||||
Default: 127.0.0.1
|
||||
Type: string
|
||||
Description: IP del servidor OGCore.
|
||||
|
||||
Template: opengnsys/ogrepository_sambaUser
|
||||
Type: string
|
||||
Default: opengnsys
|
||||
Description: Usuario de Samba.
|
||||
|
||||
Template: opengnsys/ogrepository_sambaUserPass
|
||||
Type: password
|
||||
Default: og
|
||||
Description: Contraseña para el usuario de Samba.
|
|
@ -0,0 +1,26 @@
|
|||
#!/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 $@
|
||||
|
||||
|
||||
# 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)
|
|
@ -0,0 +1 @@
|
|||
3.0 (native)
|
|
@ -0,0 +1,7 @@
|
|||
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||
QyNTUxOQAAACBs7Wbqztq5ixPGFL+1DlTa0T6QUBMiLq6KxZnCJ5rofQAAAJD7Xj89+14/
|
||||
PQAAAAtzc2gtZWQyNTUxOQAAACBs7Wbqztq5ixPGFL+1DlTa0T6QUBMiLq6KxZnCJ5rofQ
|
||||
AAAEC4UmYDisgl5jNR6SUwRA80k6Qc06cBHg1mW3+2NU6SfmztZurO2rmLE8YUv7UOVNrR
|
||||
PpBQEyIurorFmcInmuh9AAAABm5vbmFtZQECAwQFBgc=
|
||||
-----END OPENSSH PRIVATE KEY-----
|
|
@ -0,0 +1 @@
|
|||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGztZurO2rmLE8YUv7UOVNrRPpBQEyIurorFmcInmuh9 noname
|
Loading…
Reference in New Issue