Informations :
Dates
- Publish : : Thursday 13 october 2022
- 47 views
Share :
J'ai plusieurs serveurs qui tournent avec Proxmox VE html.
Pour me faciliter la tâche j'ai fais un script pour mettre à jour périodiquement mon hôte Proxmox VE et mes LinuX Containers html (lxc).
Script avec 69 lignes
001root@lv1:~ # cat /root/lxc-infos-update.bash 002#!/bin/bash 003############################################################### 004# Script update|infos linux containers (lxc) and host 005# Author O.Romain.Jaillet-ramey 006# Date : 20220216 007############################################################### 008 009#####-------------------------- START / STOP ----------------------------###### 010 011case "$1" in 012 013update) 014echo "$0 Update" 015 016 echo '########### ------------------------- UPDATE HOST ---------------------------- ###########'; 017 echo ''; 018 apt update 019 echo '## ------ ##'; 020 apt list --upgradable 021 echo '## ------ ##'; 022 apt -y upgrade 023 echo '## ------ ##'; 024 apt -y autoremove 025 echo ''; 026 echo '########### ------------------------- UPDATE HOST ---------------------------- ###########'; 027 echo ''; 028 029 for i in `lxc-ls` ; 030 do 031 STATE="`lxc-info -n $i | grep -i "State:" | awk -F: '{print $2}' | sed 's/ //g'`" 032 033 if [ ${STATE} = 'RUNNING' ]; 034 then 035 echo '### ------------------------------ UPDATE CONTAINER ---------------------------------- ###'; 036 lxc-info $i; 037 echo ''; 038 echo '## ------ CONTAINER UP -→ UPDATE ------ ##'; 039 echo ''; 040 lxc-attach -n $i -- apt -y update 041 echo '## ------ ##'; 042 lxc-attach -n $i -- apt list --upgradable 043 echo '## ------ ##'; 044 lxc-attach -n $i -- apt -y upgrade 045 echo '## ------ ##'; 046 lxc-attach -n $i -- apt -y autoremove 047 echo '### ------------------------------ UPDATE CONTAINER ---------------------------------- ###'; 048 echo ''; 049 fi; 050 done; 051;; 052 053infos) 054echo "$0 Infos" 055 056 for i in `lxc-ls` ; 057 do 058 echo '### ---------------------------------------------------------------------------------- ###'; 059 lxc-info $i; 060 echo '### ---------------------------------------------------------------------------------- ###'; 061 echo ''; 062 done; 063;; 064 065*) 066 echo "usage : $0 (infos|update)" 067;; 068 069esac
Commande : /root/lxc-infos-update.bash update|infos
Envoyer cela en tâche planifiée tous les jours.
Sinon vous pouvez regarder les documentations Linux et utiliser les mises à jour automatiques ou les mises à jour "sans surveillance" (Unattended Upgrades).
- Ubuntu Documentation : Mises à jour automatiques html
- Debian Wiki: UnattendedUpgrades html
Infos : Proxmox Virtual Environment html - Kernel Virtual Machine html - LinuX Containers html
- WikipediA : Proxmox VE html
Proxmox Virtual Environnement est une solution de virtualisation libre (licence AGPLv3) basée sur l'hyperviseur Linux KVM html, et offre aussi une solution de containers avec LXC. - WikipediA : LXC html
LXC, contraction de l'anglais LinuX Containers est un système de virtualisation, utilisant l'isolation comme méthode de cloisonnement au niveau du système d'exploitation.
Pour infos complémentaire dans Proxmox VE html on peut créer des Machines Virtuelles, des KVM html.
Exemple de commande : /usr/sbin/qm list
:
Script avec 3 lignes
001 VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID 002 101 vm1 running 48288 2200.00 8382 003 102 vm2 running 16192 100.00 3124
/usr/sbin/qm --help
pour plus d'informations.
/usr/sbin/qm start 101
etc.
;)