From 0e3e1674ae6d35ab6af29af96a6f24bfb9179078 Mon Sep 17 00:00:00 2001 From: "Ramón M. Gómez" Date: Thu, 3 Sep 2020 12:29:04 +0200 Subject: #997: Support for Initrd compressed in several formats. Adding compatibility with Ubuntu 20.04 Initrd, which is compressed in LZ4 format. --- installer/opengnsys_installer.sh | 2 +- installer/opengnsys_update.sh | 2 +- server/bin/installmodule | 3 ++- server/bin/oglivecli | 10 +++++----- server/bin/setsmbpass | 8 ++++++-- server/bin/setsslkey | 6 ++++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/installer/opengnsys_installer.sh b/installer/opengnsys_installer.sh index 72f3be21..94f15de8 100755 --- a/installer/opengnsys_installer.sh +++ b/installer/opengnsys_installer.sh @@ -189,7 +189,7 @@ OSVERSION="${OSVERSION%%.*}" # Configuración según la distribución GNU/Linux (usar minúsculas). case "$OSDISTRIB" in ubuntu|debian|linuxmint) - DEPENDENCIES=( subversion apache2 php php-ldap php-fpm mysql-server php-mysql isc-dhcp-server bittorrent tftp-hpa tftpd-hpa xinetd build-essential g++-multilib libmysqlclient-dev wget curl doxygen graphviz bittornado ctorrent samba rsync unzip netpipes debootstrap schroot squashfs-tools btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan udpcast libev-dev libjansson-dev libssl-dev shim-signed grub-efi-amd64-signed gawk libdbi-dev libdbi1 libdbd-mysql automake) + DEPENDENCIES=( subversion apache2 php php-ldap php-fpm mysql-server php-mysql isc-dhcp-server bittorrent tftp-hpa tftpd-hpa xinetd build-essential g++-multilib libmysqlclient-dev wget curl doxygen graphviz bittornado ctorrent samba rsync unzip netpipes debootstrap schroot squashfs-tools btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan udpcast libev-dev libjansson-dev libssl-dev shim-signed grub-efi-amd64-signed gawk libdbi-dev libdbi1 libdbd-mysql automake liblz4-tool ) UPDATEPKGLIST="apt-get update" INSTALLPKG="apt-get -y install --force-yes" CHECKPKG="dpkg -s \$package 2>/dev/null | grep Status | grep -qw install" diff --git a/installer/opengnsys_update.sh b/installer/opengnsys_update.sh index 6468fd7f..bd689008 100755 --- a/installer/opengnsys_update.sh +++ b/installer/opengnsys_update.sh @@ -117,7 +117,7 @@ function autoConfigure() # Configuración según la distribución de Linux. if [ -f /etc/debian_version ]; then # Distribución basada en paquetes Deb. - DEPENDENCIES=( curl rsync btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan udpcast libev-dev libjansson-dev libssl-dev shim-signed grub-efi-amd64-signed php-fpm gawk libdbi-dev libdbi1 libdbd-mysql automake) + DEPENDENCIES=( curl rsync btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan udpcast libev-dev libjansson-dev libssl-dev shim-signed grub-efi-amd64-signed php-fpm gawk libdbi-dev libdbi1 libdbd-mysql automake liblz4-tool ) # Paquete correcto para realpath. [ -z "$(apt-cache pkgnames realpath)" ] && DEPENDENCIES=( ${DEPENDENCIES[@]//realpath/coreutils} ) UPDATEPKGLIST="add-apt-repository -y ppa:ondrej/php; apt-get update" diff --git a/server/bin/installmodule b/server/bin/installmodule index 4625bd04..b0a4ac5b 100755 --- a/server/bin/installmodule +++ b/server/bin/installmodule @@ -73,7 +73,8 @@ source module.conf || exit # Descomprimir Initrd. mkdir -p $tmpinit cd $tmpinit -gzip -dc $INITRD | cpio -im 2>/dev/null +COMPRESS=$(file -b "$CLIENTINITRD" | awk '{print tolower($1);}') +$COMPRESS -dc $INITRD | cpio -im 2>/dev/null # Versión del Kernel del Initrd. KERNEL=$(ls -d lib/modules/[0-9]* | head -1) diff --git a/server/bin/oglivecli b/server/bin/oglivecli index a6e3148a..65dd2e0f 100755 --- a/server/bin/oglivecli +++ b/server/bin/oglivecli @@ -260,7 +260,7 @@ function download() { # Install an ogLive client from a previously downloaded ISO image. function install() { local OGLIVEFILE OGLIVEDIST OGLIVEREV OGLIVEKRNL OGLIVEDIR OGINITRD OGSQFS OGCLIENT=ogclient - local SAMBAPASS TMPDIR RSYNCSERV RSYNCCLNT + local COMPRESS SAMBAPASS TMPDIR RSYNCSERV RSYNCCLNT [ $# -ne 1 ] && raiseError usage OGLIVEFILE=$(realpath $DOWNLOADDIR/$1) # Only 1 file in pathname expansion. @@ -289,10 +289,10 @@ function install() { OGINITRD=$OGLIVEDIR/oginitrd.img [ ! -r $OGINITRD ] && OGINITRD=$TFTPDIR/$DEFOGLIVE/oginitrd.img if [ -r $OGINITRD ]; then - SAMBAPASS=$(gzip -dc $OGINITRD | \ - cpio -i --to-stdout scripts/ogfunctions 2>&1 | \ - grep "^[ ].*OPTIONS=" | \ - sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/') + COMPRESS=$(file -b "$OGINITRD " | awk '{print tolower($1);}') + SAMBAPASS=$($COMPRESS -dc $OGINITRD | \ + cpio -i --to-stdout scripts/ogfunctions 2>&1 | \ + sed -n '/^[ ].*OPTIONS=/s/.*pass=\(\w*\).*/\1/p') fi # Make ogLive backup. rm -fr ${OGLIVEDIR}.old diff --git a/server/bin/setsmbpass b/server/bin/setsmbpass index f681196b..4920d399 100755 --- a/server/bin/setsmbpass +++ b/server/bin/setsmbpass @@ -13,6 +13,9 @@ #@version 1.1.0 - Soporte para varios clientes ogLive. #@author Ramón M. Gómez - ETSII Univ. Sevilla #@date 2017-06-20 +#@version 1.2.0 - Soporte para varios compresores de Initrd. +#@author Ramón M. Gómez - ETSII Univ. Sevilla +#@date 2020-09-02 #*/ ## @@ -76,7 +79,8 @@ for OGLIVE in $LIST; do echo "Configurando cliente \"$OGLIVE\" ..." mkdir -p $TMPDIR cd $TMPDIR || ogRaiseError access "Directorio temporal" - gzip -dc "$CLIENTINITRD" | cpio -im + COMPRESS=$(file -b "$CLIENTINITRD" | awk '{print tolower($1);}') + $COMPRESS -dc "$CLIENTINITRD" | cpio -im if [ -f scripts/ogfunctions ]; then sed -i "s/OPTIONS=\(.*\)user=\w*\(.*\)pass=\w*\(.*\)/OPTIONS=\1user=$SAMBAUSER\2pass=$SAMBAPASS\3/" scripts/ogfunctions # TEMPORAL: solución ticket 554, actualizar cliente en caché (ogLive r3257). @@ -86,7 +90,7 @@ for OGLIVE in $LIST; do echo "$SAMBAPASS" > scripts/passrsync chown root.root scripts/passrsync chmod 400 scripts/passrsync - # Generar Initrd del cliente. + # Generar Initrd del cliente (siempre comprimido con gzip). find . | cpio -H newc -oa | gzip -9c > "$CLIENTINITRD" else echo "$PROG: Aviso: no se ha modificado la clave del cliente \"$OGLIVE\"." diff --git a/server/bin/setsslkey b/server/bin/setsslkey index 9652f006..2ea46a6e 100755 --- a/server/bin/setsslkey +++ b/server/bin/setsslkey @@ -58,7 +58,8 @@ if [ "$NEWKEY" != "NEW" ]; then if [ -r "$CLIENTINITRD" ]; then mkdir -p $TMPDIR cd $TMPDIR || exit 3 - gzip -dc "$CLIENTINITRD" | cpio -im + COMPRESS=$(file -b "$CLIENTINITRD" | awk '{print tolower($1);}') + $COMPRESS -dc "$CLIENTINITRD" | cpio -im if [ -r scripts/ssl/id_rsa ]; then PRIVKEY=$(cat scripts/ssl/id_rsa |grep -v '\-\-\-') PUBLICKEY=$(cat scripts/ssl/id_rsa.pub) @@ -94,7 +95,8 @@ for OGLIVE in $LIST; do echo "Configurando cliente \"$OGLIVE\" ..." mkdir -p $TMPDIR cd $TMPDIR || exit 3 - gzip -dc "$CLIENTINITRD" | cpio -im + COMPRESS=$(file -b "$CLIENTINITRD" | awk '{print tolower($1);}') + $COMPRESS -dc "$CLIENTINITRD" | cpio -im # Genero archivos de claves [ -d $TMPDIR/scripts/ssl ] || mkdir -p $TMPDIR/scripts/ssl -- cgit v1.2.3-18-g5258