You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
842 B
29 lines
842 B
#!/bin/bash
|
|
# lxc-start.sh
|
|
# Fonction: Éteindre tout les conteneurs
|
|
# Auteur initial: Vivek Gite <www.cyberciti.biz>, under GPL v2+
|
|
# -------------------------------------------------------
|
|
|
|
# Obtenir la liste des conteneurs
|
|
vms="$(lxc-ls --active)"
|
|
|
|
# Éteindre tout les conteneurs de la liste
|
|
stop_lxc(){
|
|
local vm="$1"
|
|
echo -e "\\033[1;34m*** [VM: $vm [$(hostname) @ $(date)] ] ***"
|
|
echo -e "\\033[1;32m-----------------------------------------------------------------"
|
|
tput sgr0
|
|
echo "Arrêt de $v."
|
|
/usr/bin/lxc-attach -n "$vm" init 0
|
|
# Pour RHEL/CentOS/Fedora Linux, remplacez la commande lxc-attach précédente par celle-ci :
|
|
# lxc-attach -n "$vm" poweroff
|
|
echo -e "\\033[1;32m-----------------------------------------------------------------"
|
|
tput sgr0
|
|
}
|
|
|
|
# Exécuter l'extinction
|
|
for v in $vms
|
|
do
|
|
stop_lxc "$v"
|
|
done
|