Compare commits
2 Commits
d4f8af8e54
...
598233bc33
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
598233bc33 | ||
|
|
1ea17a5ddf |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Ignorer le fichier d'environnement
|
||||
.env
|
||||
54
reinitialisation_salle.sh
Executable file
54
reinitialisation_salle.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
# Charger le .env
|
||||
if [ -f .env ]; then
|
||||
export $(grep -v '^#' .env | xargs)
|
||||
fi
|
||||
|
||||
#Si rien n'est passé dans le prompt valeur n par défaut
|
||||
read -e -p "Attention vous allez réinitialiser complétement la salle, voullez vous vraiment continuer [o/n] : " -i "n" confirmation
|
||||
|
||||
echo "Vous avez entré ${confirmation}"
|
||||
|
||||
|
||||
if [ $confirmation == 'o' ];
|
||||
then
|
||||
|
||||
echo "Lancement de la tâche de réinitialisation de la salle"
|
||||
|
||||
#Script
|
||||
#curl -H "fog-api-token: ${FOG_API_TOKEN}" -H "fog-user-token: ${FOG_USER_TOKEN}" -H "Content-Type: application/json" -X GET http://localhost/fog/group | jq
|
||||
|
||||
|
||||
#Variables de configuration de la tâche
|
||||
GROUP_ID="1"
|
||||
IMAGE_ID="1"
|
||||
TASK_TYPE="1" #Déploiement multicast
|
||||
SHUTDOWN="1" #Eteindre les machines à la fin
|
||||
|
||||
|
||||
#Wake On LAN du groupe
|
||||
echo "Envoi du Wake On LAN vers le groupe ${GROUP_ID}"
|
||||
curl -H "fog-api-token: ${FOG_API_TOKEN}" -H "fog-user-token: ${FOG_USER_TOKEN}" -X POST http://localhost/fog/group/${GROUP_ID}/wol
|
||||
|
||||
|
||||
#Construction du JSON avec les paramètres de la tâche
|
||||
DATA=$(cat <<EOF
|
||||
{
|
||||
"taskTypeID": "$TASK_TYPE",
|
||||
"shutdown": "$SHUTDOWN",
|
||||
"imageID": "$IMAGE_ID"
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
#Création de la tâche
|
||||
curl -H "fog-api-token: ${FOG_API_TOKEN}" -H "fog-user-token: ${FOG_USER_TOKEN}" -H "Content-Type: application/json" -X POST http://localhost/fog/group/${GROUP_ID}/task -d "$DATA"
|
||||
|
||||
|
||||
else
|
||||
echo "Annulation de la tâche de réinitialisation de la salle"
|
||||
fi
|
||||
|
||||
echo "FIN"
|
||||
Loading…
x
Reference in New Issue
Block a user