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.
35 lines
1.2 KiB
35 lines
1.2 KiB
6 years ago
|
#!/bin/bash
|
||
|
# Nom : lxc-maj.sh
|
||
|
# Fonction : Mettre à jour tout les conteneurs
|
||
|
# Auteur initial: Vivek Gite <www.cyberciti.biz>, under GPL v2+
|
||
|
# -------------------------------------------------------
|
||
|
|
||
|
# Obtenir la liste des conteneurs
|
||
|
vms="$(lxc-ls --active)"
|
||
|
|
||
|
# Mettre à jour tout les conteneurs de la liste
|
||
|
maj_lxc(){
|
||
|
local vm="$1"
|
||
|
echo -e "\\033[1;34m*** [VM: $vm [$(hostname) @ $(date)] ] ***"
|
||
|
echo -e "\\033[1;32m-----------------------------------------------------------------"
|
||
|
tput sgr0
|
||
|
/usr/bin/lxc-attach -n "$vm" apt -- -q update
|
||
|
/usr/bin/lxc-attach -n "$vm" apt -- -q -y upgrade
|
||
|
echo 'Lancement de la commande "apt autoremove".'
|
||
|
/usr/bin/lxc-attach -n "$vm" apt -- -qq -y autoremove
|
||
|
/usr/bin/lxc-attach -n "$vm" apt-get -- -qq -y clean
|
||
|
/usr/bin/lxc-attach -n "$vm" apt-get -- -qq -y autoclean
|
||
|
# Pour RHEL/CentOS/Fedora Linux, remplacez les commandes lxc-attach précédentes par celle-ci :
|
||
|
# lxc-attach -n "$vm" yum -y update
|
||
|
echo -e "\\033[1;32m-----------------------------------------------------------------"
|
||
|
tput sgr0
|
||
|
}
|
||
|
|
||
|
# Exécuter la mise à jour
|
||
|
for v in $vms
|
||
|
do
|
||
|
maj_lxc "$v"
|
||
|
done
|
||
|
|
||
|
#Source : https://www.cyberciti.biz/faq/how-to-update-debian-or-ubuntu-linux-containers-lxc/
|