refs #477 Changes function execution in symfony installation
parent
5b1cf84fe1
commit
fae7536690
|
@ -1,10 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
#/**
|
||||
# setsmbpass
|
||||
#@file setsmbpass [ogLive]
|
||||
#@brief Cambia la contraseña de los clientes para acceder a los servicios principales.
|
||||
#@usage setsmbpass [ogLive]
|
||||
#@param ogLive solo modifica la clave del cliente indicado (puede crear inconsistencias)
|
||||
#@brief Cambia la contraseña del usuario del cliente para acceder a los servicios Samba.
|
||||
#@warning Se modifica el Initrd del cliente y se cambia la clave en el servidor.
|
||||
#@warning No se modifica el usuario de acceso (usuario "opengnsys").
|
||||
#@version 1.0.2 - Versión inicial.
|
||||
|
@ -13,41 +12,38 @@
|
|||
#@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
|
||||
#*/ ##
|
||||
|
||||
|
||||
# Variables y funciones globales.
|
||||
PROG="$(basename "$0")"
|
||||
OPENGNSYS=${OPENGNSYS:-"/opt/ogboot"}
|
||||
PATH=$PATH:$OPENGNSYS/bin
|
||||
# Variables.
|
||||
PROG=$(basename "$0")
|
||||
PATH=$PATH:$(dirname "$(realpath "$0")")
|
||||
OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
|
||||
OGCFGFILE=$OPENGNSYS/etc/opengnsys.json
|
||||
SAMBAUSER="opengnsys" # Usuario por defecto.
|
||||
TFTPDIR=$OPENGNSYS/tftpboot
|
||||
INITRD=oginitrd.img
|
||||
TMPDIR=/tmp/oglive$$
|
||||
let CHANGES=0
|
||||
|
||||
source $OPENGNSYS/lib/ogfunctions.sh || exit 1
|
||||
|
||||
# Control de parámetros.
|
||||
[ "$*" == "help" ] && help
|
||||
[ "$*" == "version" ] && version
|
||||
[ "$USER" != "root" ] && raiseError access "Solo ejecutable por root"
|
||||
# Control básico de errores.
|
||||
if [ "$USER" != "root" ]; then
|
||||
echo "$PROG: Error: solo ejecutable por root" >&2
|
||||
exit 1
|
||||
fi
|
||||
case $# in
|
||||
0) # Cambios en todos los clientes ogLive instalados.
|
||||
echolog "Cambiando contraseña en todos los clientes ogLive instalados"
|
||||
if which oglivecli &>/dev/null; then
|
||||
LIST=$(oglivecli list | awk '{print $2}')
|
||||
else
|
||||
LIST="ogclient"
|
||||
fi ;;
|
||||
1) # Cambios en único ogLive (AVISO: puede crear inconsistencias con otros ogLive).
|
||||
echolog "Cambiando contraseña en un solo ogLive"
|
||||
LIST="$1" ;;
|
||||
*) # Error de formato.
|
||||
raiseError usage ;;
|
||||
echo "$PROG: Error de ejecución" >&2
|
||||
echo "Formato: $PROG ogLive"
|
||||
exit 1 ;;
|
||||
esac
|
||||
|
||||
# Recuperar eco de consola si se corta el proceso.
|
||||
|
@ -65,8 +61,9 @@ for OGLIVE in $LIST; do
|
|||
# Solo se deben aceptar números y letras para la clave de acceso.
|
||||
if [[ "$SAMBAPASS" =~ [^a-zA-Z0-9] ]]; then
|
||||
echo
|
||||
echo "$PROG: Error: la clave solo debe contener caracteres alfanuméricos" >&2
|
||||
stty echo 2>/dev/null
|
||||
raiseError cancel "La clave solo debe contener caracteres alfanuméricos"
|
||||
exit 2
|
||||
fi
|
||||
echo
|
||||
# Obtener confirmación clave sin eco en pantalla.
|
||||
|
@ -74,15 +71,34 @@ for OGLIVE in $LIST; do
|
|||
read -r SAMBAPASS2
|
||||
echo
|
||||
stty echo 2>/dev/null
|
||||
[ "$SAMBAPASS" != "$SAMBAPASS2" ] && raiseError cancel "Las claves no coinciden"
|
||||
if [ "$SAMBAPASS" != "$SAMBAPASS2" ]; then
|
||||
echo "$PROG: Error: las claves no coinciden" >&2
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
# Editar la parte de acceso del cliente:
|
||||
# descomprimir Initrd, sustituir clave y recomprimir Initrd).
|
||||
echolog "Configurando cliente \"$OGLIVE\" ..."
|
||||
echo "Configurando cliente \"$OGLIVE\" ..."
|
||||
mkdir -p $TMPDIR
|
||||
cd $TMPDIR || ogRaiseError access "Directorio temporal"
|
||||
COMPRESS=$(file -b "$CLIENTINITRD" | awk '{print tolower($1);}')
|
||||
$COMPRESS -dc "$CLIENTINITRD" | cpio -im
|
||||
cd $TMPDIR || { echo "Error: no se pudo cambiar al directorio temporal."; exit 3; }
|
||||
|
||||
# Verificar si el archivo es gzip o lz4 antes de descomprimir.
|
||||
if file "$CLIENTINITRD" | grep -q "gzip compressed data"; then
|
||||
if ! gzip -dc "$CLIENTINITRD" | cpio -im; then
|
||||
echo "Error: No se pudo descomprimir y extraer $CLIENTINITRD con gzip."
|
||||
exit 4
|
||||
fi
|
||||
COMPRESS_CMD="gzip -9c"
|
||||
elif file "$CLIENTINITRD" | grep -q "LZ4 compressed data"; then
|
||||
if ! lz4 -d "$CLIENTINITRD" | cpio -im; then
|
||||
echo "Error: No se pudo descomprimir y extraer $CLIENTINITRD con lz4."
|
||||
exit 4
|
||||
fi
|
||||
COMPRESS_CMD="lz4 -c"
|
||||
else
|
||||
echo "Error: $CLIENTINITRD no está en formato gzip o lz4."
|
||||
exit 4
|
||||
fi
|
||||
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).
|
||||
|
@ -90,30 +106,37 @@ for OGLIVE in $LIST; do
|
|||
# FIN CÓDIGO TEMPORAL.
|
||||
# Ticket 565, preparar acceso Rsync cliente.
|
||||
echo "$SAMBAPASS" > scripts/passrsync
|
||||
chown root.root scripts/passrsync
|
||||
chmod 400 scripts/passrsync
|
||||
# Generar Initrd del cliente (siempre comprimido con gzip).
|
||||
find . | cpio -H newc -oa | gzip -9c > "$CLIENTINITRD"
|
||||
# Guardar tokens de seguridad.
|
||||
cat << EOT > scripts/client.cfg
|
||||
CLIENTID=$(jq -r .client.id $OGCFGFILE)
|
||||
CLIENTSECRET=$(jq -r .client.secret $OGCFGFILE)
|
||||
EOT
|
||||
chown root.root scripts/passrsync scripts/client.cfg
|
||||
chmod 400 scripts/passrsync scripts/client.cfg
|
||||
# Generar Initrd del cliente.
|
||||
if ! find . | cpio -H newc -oa | $COMPRESS_CMD > "$CLIENTINITRD"; then
|
||||
echo "Error: No se pudo recomprimir $CLIENTINITRD."
|
||||
exit 5
|
||||
fi
|
||||
else
|
||||
echolog "$PROG: Aviso: no se ha modificado la clave del cliente \"$OGLIVE\"."
|
||||
echo "$PROG: Aviso: no se ha modificado la clave del cliente \"$OGLIVE\"."
|
||||
fi
|
||||
rm -fr $TMPDIR
|
||||
# Calcular suma de comprobación.
|
||||
md5sum "$CLIENTINITRD" | cut -f1 -d" " > "$CLIENTINITRD.sum"
|
||||
let CHANGES++
|
||||
else
|
||||
echolog "$PROG: Cliente \"$OGLIVE\" no accesible."
|
||||
echo "$PROG: Cliente \"$OGLIVE\" no accesible."
|
||||
fi
|
||||
done
|
||||
if [[ $CHANGES != 0 ]]; then
|
||||
# Ticket 565, preparar acceso Rsync servidor.
|
||||
[ -e /etc/rsyncd.secrets ] && sed -i -n -e "/^$SAMBAUSER:/!p" -e "$ a$SAMBAUSER:$SAMBAPASS" /etc/rsyncd.secrets || echo "$SAMBAUSER:$SAMBAPASS" > /etc/rsyncd.secrets
|
||||
echo "$SAMBAUSER:$SAMBAPASS" > /etc/rsyncd.secrets
|
||||
chown root.root /etc/rsyncd.secrets
|
||||
chmod 600 /etc/rsyncd.secrets
|
||||
# Cambiar clave Samba.
|
||||
echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | smbpasswd -a -s $SAMBAUSER
|
||||
else
|
||||
echolog "$PROG: Aviso: no se ha modificado la clave de ningún cliente."
|
||||
echo "$PROG: Aviso: no se ha modificado la clave de ningún cliente."
|
||||
fi
|
||||
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ def og_boot_create_dirs():
|
|||
|
||||
def og_boot_symfony_install(path_opengnsys_base):
|
||||
logger.info("Creating Symfony application skeleton...")
|
||||
downloadComposer()
|
||||
# downloadComposer()
|
||||
# Copiar los archivos .env y composer.json primero
|
||||
logger.info(f"Copying files (.env and composer.json) from {WORKDIR}/ogboot/.env to {path_opengnsys_base}/.env")
|
||||
shutil.copy(f"{WORKDIR}/ogboot/.env", os.path.join(path_opengnsys_base, ".env"))
|
||||
|
@ -976,11 +976,13 @@ og_core_create_user("ogboot")
|
|||
logger.info("Creating directories.")
|
||||
og_boot_create_dirs()
|
||||
|
||||
logger.info("Copying installation files.")
|
||||
og_boot_copy_files(INSTALL_OGBOOT_TARGET)
|
||||
|
||||
logger.info("Installing Symfony.")
|
||||
og_boot_symfony_install(INSTALL_OGBOOT_TARGET)
|
||||
|
||||
logger.info("Copying installation files.")
|
||||
og_boot_copy_files(INSTALL_OGBOOT_TARGET)
|
||||
|
||||
#if os.system("echo $?") != 0:
|
||||
# logger.error("Error while creating skeleton directory!")
|
||||
# exit(1)
|
||||
|
|
Loading…
Reference in New Issue