From dac2f3fb2d7143fd446bee703ca4aa1621bceab6 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 21 May 2022 00:18:32 +0200 Subject: [PATCH] Nettoyage et #! --- backup.sh | 3 --- blockcommit_all.sh | 1 + execute_cmd_all.sh | 1 + execute_script_all.sh | 1 + migrate_many_to_aunt.sh | 1 + migrate_many_to_mother.sh | 1 + migrate_to_aunt.sh | 1 + migrate_to_mother.sh | 1 + migrate_to_mother_p2p.sh | 11 ++++------- script.sh | 27 --------------------------- script_isengard_superv.sh | 25 ------------------------- script_superv.sh | 5 ----- start_all.sh | 1 + supervision.sh | 1 + 14 files changed, 13 insertions(+), 67 deletions(-) delete mode 100755 backup.sh delete mode 100755 script.sh delete mode 100755 script_isengard_superv.sh delete mode 100755 script_superv.sh diff --git a/backup.sh b/backup.sh deleted file mode 100755 index 7a693aa..0000000 --- a/backup.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - - diff --git a/blockcommit_all.sh b/blockcommit_all.sh index 819fdc8..6ab10cc 100755 --- a/blockcommit_all.sh +++ b/blockcommit_all.sh @@ -1,3 +1,4 @@ +#!/bin/bash count=$1 VMs=$(sudo virsh list --state-running --name | sort -R) diff --git a/execute_cmd_all.sh b/execute_cmd_all.sh index 2226faf..c908ddb 100755 --- a/execute_cmd_all.sh +++ b/execute_cmd_all.sh @@ -1,3 +1,4 @@ +#!/bin/bash command=$1 VMs=$(sudo virsh list --state-running --name) diff --git a/execute_script_all.sh b/execute_script_all.sh index c196742..1f553e3 100755 --- a/execute_script_all.sh +++ b/execute_script_all.sh @@ -1,3 +1,4 @@ +#!/bin/bash script=$1 VMs=$(sudo virsh list --state-running --name | grep chalec) diff --git a/migrate_many_to_aunt.sh b/migrate_many_to_aunt.sh index e907f27..5baf307 100755 --- a/migrate_many_to_aunt.sh +++ b/migrate_many_to_aunt.sh @@ -1,3 +1,4 @@ +#!/bin/bash count=$1 VMs=$(sudo virsh list --state-running --name | head -n $count | sort -R) diff --git a/migrate_many_to_mother.sh b/migrate_many_to_mother.sh index ab09496..d9d7493 100755 --- a/migrate_many_to_mother.sh +++ b/migrate_many_to_mother.sh @@ -1,3 +1,4 @@ +#!/bin/bash count=$1 VMs=$(sudo virsh list --state-running --name | head -n $count | sort -R) diff --git a/migrate_to_aunt.sh b/migrate_to_aunt.sh index 1a5b09c..4ce10be 100755 --- a/migrate_to_aunt.sh +++ b/migrate_to_aunt.sh @@ -1,3 +1,4 @@ +#!/bin/bash vm=$1 if [ -z "$(cat /proc/drbd | grep Connected)" ] diff --git a/migrate_to_mother.sh b/migrate_to_mother.sh index 977d5f5..dd48c57 100755 --- a/migrate_to_mother.sh +++ b/migrate_to_mother.sh @@ -1,3 +1,4 @@ +#!/bin/bash vm=$1 if [ -z "$(cat /proc/drbd | grep Connected)" ] diff --git a/migrate_to_mother_p2p.sh b/migrate_to_mother_p2p.sh index db8d694..ec4ad9c 100755 --- a/migrate_to_mother_p2p.sh +++ b/migrate_to_mother_p2p.sh @@ -1,10 +1,7 @@ -VMs=$(sudo virsh list --state-running --name) +#!/bin/bash +vm=$1 -for vm in $VMs -do - echo MIGRATING $vm ... - virsh migrate --p2p $vm --live --verbose --undefinesource --persistent \ - --copy-storage-all --abort-on-error qemu+ssh://mother.onlink/system -done +echo MIGRATING $vm ... +virsh migrate --p2p $vm --live --verbose --undefinesource --persistent --copy-storage-all --abort-on-error qemu+ssh://mother.onlink/system sudo mv /var/backups/vm/aunt/* /var/backups/vm/mother diff --git a/script.sh b/script.sh deleted file mode 100755 index 63bebd1..0000000 --- a/script.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -#sudo sed -i 's/destemail = cominfra@a-lec.org/destemail = comchalec@a-lec.org/g' /etc/fail2ban/jail.local -#sudo sed -i 's/destemail = root@localhost/destemail = comchalec@a-lec.org/g' /etc/fail2ban/jail.local - -#sudo systemctl restart fail2ban.service - - -#sudo su -c 'echo Defaults mailto="comchalec@a-lec.org" >> /etc/sudoers' - -#sudo sed -i 's/Defaults mailto="cominfra@a-lec.org/ /g' /etc/sudoers - -#sudo etckeeper commit "L'infrastructure envoie ses courriels à comchalec@" - -#sudo apt-get install qemu-guest-agent -y - -#sudo reboot - -#sudo rm /etc/icinga2/conf.d/* - -sudo su -c 'echo -e "[Definition]\nactionstart =\nactionstop =\n" > /etc/fail2ban/action.d/sendmail-common.local' - -sudo etckeeper commit "Désactivation des notifications d'allumage Fail2ban" - -#sudo systemctl restart icinga2 - -sudo systemctl restart fail2ban diff --git a/script_isengard_superv.sh b/script_isengard_superv.sh deleted file mode 100755 index 9e7b43c..0000000 --- a/script_isengard_superv.sh +++ /dev/null @@ -1,25 +0,0 @@ -NAME= -sudo cat << EOF > /etc/icinga2/zones.d/master/$NAME.conf -object Endpoint "NOM_DE_DOMAINE_DE_VM" { -} - -object Zone "NOM_DE_DOMAINE_DE_VM" { -endpoints = [ "NOM_DE_DOMAINE_DE_VM" ] -parent = "master" -} - -object Host "NOM_DE_DOMAINE_DE_VM" { - import "generic-host" - address = "NOM_DE_DOMAINE_DE_VM" - address6 = "NOM_DE_DOMAINE_DE_VM" - vars.os = "GNU/Linux" - vars.client_endpoint = name - - vars.notification["mail"] = { - groups = [ "icingaadmins" ] - } - -} -EOF - -sudo sed -i "s/NOM_DE_DOMAINE_DE_VM/${NAME}/g" /etc/icinga2/zones.d/master/$NAME.conf diff --git a/script_superv.sh b/script_superv.sh deleted file mode 100755 index a0b618d..0000000 --- a/script_superv.sh +++ /dev/null @@ -1,5 +0,0 @@ -sudo apt-get install icinga2 monitoring-plugins monitoring-plugins-contrib - -sudo sed -i 's/check_mem.pl/check_memory/g' /usr/share/icinga2/include/plugins-contrib.d/operating-system.conf - -sudo systemctl restart icinga2 diff --git a/start_all.sh b/start_all.sh index 4bd6690..a3576fe 100755 --- a/start_all.sh +++ b/start_all.sh @@ -1,3 +1,4 @@ +#!/bin/bash VMs=$(sudo virsh list --all --name) for vm in $VMs diff --git a/supervision.sh b/supervision.sh index 5f4f462..f5af04f 100755 --- a/supervision.sh +++ b/supervision.sh @@ -1,3 +1,4 @@ +#!/bin/bash ssh $1 < script_superv.sh sudo sed -i "s/NAME=.*/NAME=$1/g" superv_script_isengard.sh