Primera subida
This commit is contained in:
commit
60dd0e3625
31
copia_fichero_lxc.sh
Executable file
31
copia_fichero_lxc.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Verificar al menos un parámetro (el archivo origen)
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Uso: $0 <archivo_origen> [archivo_destino]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Parámetros
|
||||
ARCHIVO_ORIGEN="$1"
|
||||
ARCHIVO_DESTINO="${2:-$1}" # Si no especificas destino, será el mismo que el origen
|
||||
|
||||
# Comprobar si el archivo existe en el host
|
||||
if [ ! -f "$ARCHIVO_ORIGEN" ]; then
|
||||
echo "El archivo $ARCHIVO_ORIGEN no existe."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Iterar por todos los CT IDs existentes
|
||||
for CTID in $(pct list | awk 'NR>1 {print $1}')
|
||||
do
|
||||
echo "Copiando a LXC $CTID ..."
|
||||
pct push "$CTID" "$ARCHIVO_ORIGEN" "$ARCHIVO_DESTINO"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Archivo copiado exitosamente a $CTID"
|
||||
else
|
||||
echo "Error al copiar el archivo a $CTID"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "¡Proceso terminado!"
|
||||
26
ejecutar_en_lxcs.sh
Executable file
26
ejecutar_en_lxcs.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Comprobar que el usuario ingresó al menos un comando
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Uso: $0 <comando>"
|
||||
echo "Ejemplo: $0 'apt update'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# El comando a ejecutar en los contenedores
|
||||
COMANDO="$*"
|
||||
|
||||
# Iterar por todos los CT IDs existentes y ejecutar el comando
|
||||
for CTID in $(pct list | awk 'NR>1 {print $1}')
|
||||
do
|
||||
echo "Ejecutando en LXC $CTID: $COMANDO"
|
||||
pct exec "$CTID" -- bash -c "$COMANDO"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Comando ejecutado exitosamente en $CTID"
|
||||
else
|
||||
echo "Error al ejecutar el comando en $CTID"
|
||||
fi
|
||||
echo "-----------------------------"
|
||||
done
|
||||
|
||||
echo "¡Proceso terminado!"
|
||||
4
shutdown.sh
Executable file
4
shutdown.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
zabbix_sender -z 192.168.1.10 -s pve01 -k shutdown -o 1
|
||||
shutdown -h now
|
||||
Loading…
Reference in New Issue
Block a user