Compare commits

..

No commits in common. "5406e67b95df4265f61e2eda060ebf2d20c3f577" and "311ecc7f3a07f25e66ba7dc99d0bd8875632f41a" have entirely different histories.

6 changed files with 22 additions and 63 deletions

View File

@ -51,8 +51,13 @@ pipeline {
stage('Build') {
steps {
script {
construirPaquete(env.BUILD_DIR, "../artifacts", "172.17.8.68", "/var/tmp/opengnsys/debian-repo/ogrepository")
dir("${env.BUILD_DIR}") {
sh '''
dpkg-buildpackage -us -uc
mkdir -p ../artifacts && mv ../*.deb ../*.changes ../*.buildinfo ../artifacts/
ssh aptly@172.17.8.68 "rm -rf /var/tmp/opengnsys/debian-repo/ogrepository && mkdir -p /var/tmp/opengnsys/debian-repo/ogrepository"
scp -r ../artifacts/* aptly@172.17.8.68:/var/tmp/opengnsys/debian-repo/ogrepository
'''
}
}
}
@ -64,11 +69,7 @@ pipeline {
}
agent { label 'debian-repo' }
steps {
script {
// Construir el patrón de versión esperado en el nombre del paquete
def versionPattern = "${env.TAG_NAME}-${env.BUILD_NUMBER}"
publicarEnAptly('/var/tmp/opengnsys/debian-repo/ogrepository', 'opengnsys-devel', versionPattern)
}
sh "aptly repo add opengnsys-devel /var/tmp/opengnsys/debian-repo/ogrepository/*.deb"
}
}
}

2
debian/control vendored
View File

@ -8,6 +8,6 @@ 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, uftp
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.

View File

@ -56,12 +56,13 @@ done
if [ -f /etc/samba/smb.conf ]; then
dpkg-divert --package ogrepository --add --rename --divert /etc/samba/smb.conf.orig /etc/samba/smb.conf
cp /etc/samba/smb.conf.orig /etc/samba/smb.conf
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
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
@ -69,26 +70,13 @@ done
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
# Copiar sudoers file ogrepository/etc/opengnsys-repository
cp /opt/opengnsys/ogrepository/etc/opengnsys-repository /etc/sudoers.d/opengnsys
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
echo "Actualización desde la versión $2"
# Recopy static files without configuration
cp /opt/opengnsys/ogrepository/etc/opengnsys-repository /etc/sudoers.d/opengnsys-repository
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
cat $OPENGNSYS_HOME/.ssh/id_ed25519.pub >> $OPENGNSYS_HOME/.ssh/authorized_keys
fi
# Cambiar la propiedad de los archivos al usuario especificado
chown opengnsys:www-data /opt/opengnsys/
chown -R opengnsys:www-data /opt/opengnsys/ogrepository
chmod 755 /opt/opengnsys/ogrepository/bin/
# Install http server stuff
# Reiniciar servicios si es necesario

View File

@ -2,13 +2,19 @@
set -e
UNIT_FILE="/etc/systemd/system/ogrepo-api.service"
NGINX_FILE="/etc/nginx/sites-enabled/oggui.conf"
UNIT_FILE="/etc/systemd/system/oggui.service"
case "$1" in
remove)
echo "El paquete se está desinstalando..."
# Aquí puedes hacer limpieza de archivos o servicios
if [ -L "$NGINX_FILE" ]; then
rm -f "$NGINX_FILE"
systemctl restart nginx
fi
if [ -L "$UNIT_FILE" ]; then
rm -f "$UNIT_FILE"
systemctl daemon-reload

View File

@ -44,18 +44,11 @@ case "$1" in
rm -f /var/lib/dpkg/info/ogrepository.post-invoke
fi
# Remove sudoers file
if [ -f /etc/sudoers.d/opengnsys-repository ]; then
echo "Removing sudoers file..."
rm -f /etc/sudoers.d/opengnsys-repository
fi
echo "Limpieza completada."
;;
upgrade|deconfigure)
# No hacer nada en actualización o desconfiguración
;;
*)

View File

@ -1,29 +0,0 @@
# Variables para facilitar la lectura
Cmnd_Alias MOUNT_RECOVERY = \
/usr/bin/mkdir -p /mnt/recovery, \
/usr/bin/mount /dev/* /mnt/recovery, \
/usr/bin/mount --bind /dev /mnt/recovery/dev, \
/usr/bin/mount --bind /proc /mnt/recovery/proc, \
/usr/bin/mount --bind /sys /mnt/recovery/sys, \
/usr/bin/umount /mnt/recovery/dev, \
/usr/bin/umount /mnt/recovery/proc, \
/usr/bin/umount /mnt/recovery/sys, \
/usr/bin/umount -l /mnt/recovery
Cmnd_Alias CHROOT_GRUB = \
/usr/sbin/chroot /mnt/recovery /usr/sbin/grub-install --target=i386-pc *, \
/usr/sbin/chroot /mnt/recovery /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg
Cmnd_Alias LOOP_KPARTX = \
/usr/sbin/losetup -d *, \
/usr/sbin/kpartx -av /opt/opengnsys/ogrepository/images_virtual/*, \
/usr/sbin/kpartx -d /opt/opengnsys/ogrepository/images_virtual/*, \
/usr/sbin/blkid /dev/mapper/*
Cmnd_Alias KILL_BT = \
/usr/bin/pkill -9 btlaunchmany, \
/usr/bin/pkill -9 bttrack, \
/usr/bin/kill -9 *
# Permitir al usuario opengnsys ejecutar estos comandos sin contraseña
opengnsys ALL=(root) NOPASSWD: MOUNT_RECOVERY, CHROOT_GRUB, LOOP_KPARTX, KILL_BT