1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| #!/bin/bash
backup_source="/home/feneck91/docker/$1/$2"
backup_dest_up="/mnt/ntfs1/Backups/Minecraft/Worlds/$2"
backup_dest="$backup_dest_up/$(date '+%Y-%m-%d_%H:%M:%S')"
current_date="$(date '+%Y-%m-%d - %H:%M:%S')"
if ! test -d "$backup_dest_up"
then
mkdir -m 755 -p "$backup_dest_up"
fi
# Stop docker
docker stop "$3"
cp -Rfp "$backup_source" "$backup_dest"
# Ici on doit tout mettre à jour
# Update floodgate-api.jar
if [ -e "${backup_source}/plugins/floodgate-api.jar" ]
then
wget -N "https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/lastSuccessfulBuild/artifact/api/target/floodgate-api.jar" -O "${backup_source}/plugins/floodgate-api.jar"
fi
# Update Geyser-Spigot.jar
if [ -e "${backup_source}/plugins/Geyser-Spigot.jar" ]
then
wget -N "https://ci.opencollab.dev//job/GeyserMC/job/Geyser/job/master/lastSuccessfulBuild/artifact/bootstrap/spigot/target/Geyser-Spigot.jar" -O "${backup_source}/plugins/Geyser-Spigot.jar"
fi
# Update worldedit-bukkitxxx.jar
# 1 - Récupérer le fichier worldedit-bukkit-xxx sur le disque, fichier à mettre à jour
wordeditfileold=$(find "$backup_source/plugins/" -maxdepth 1 -regextype posix-extended -regex '.*/worldedit-bukkit-[0-9\.]+\.jar$' | sed -n 's/.*\(worldedit-bukkit-.*\.jar\)/\1/p')
if [ -n "$wordeditfileold" ]
then
# Le fichier wordedit existe, donc ce répertoire contient ce plugin, voir s'il faut le mettre à jour
# 2 - récupérer le nom du fichier worldedit-bukkit-xxx dernière version pour voir s'il faut le mettre à jour
read wordeditfilenew < <(wget -SqO /dev/null "https://dev.bukkit.org/projects/worldedit/files/latest" 2>&1 | grep -m1 -Po '^\s*Location.*/\K.*')
if [ "${wordeditfileold}" != "${wordeditfilenew}" ];
then
# Mise à jour du nouveau fichier
wget -N "https://dev.bukkit.org/projects/worldedit/files/${wordeditfileNew}"
if [ -e "${backup_source}/plugins/${wordeditfileNew}" ]
then
echo "${current_date} - Mise à jour du fichier : ${wordeditfileNew}" >> "${backup_source}/plugins/update_info.txt"
# Suppression de l'ancien fichier
echo "${current_date} - Suppression du fichier : ${wordeditfileold}" >> "${backup_source}/plugins/update_info.txt"
rm "${backup_source}/plugins/${wordeditfileold}"
else
echo "${current_date} - Echec lors de la mise à jour du fichier : ${wordeditfileNew}" >> "${backup_source}/plugins/update_info.txt"
fi
fi
fi
# Update worldguard-bukkit-xxx-dist.jar
# 1 - Récupérer le fichier worldguard-bukkit-xxx-dist.jar sur le disque, fichier à mettre à jour
wordguardfileold=$(find "$backup_source/plugins/" -maxdepth 1 -regextype posix-extended -regex '.*/worldguard-bukkit-[0-9\.]+-dist\.jar$' | sed -n 's/.*\(worldguard-bukkit-.*\.jar\)/\1/p')
if [ -n "$wordguardfileold" ]
then
# Le fichier wordguard existe, donc ce répertoire contient ce plugin, voir s'il faut le mettre à jour
# 2 - récupérer le nom du fichier worldguard-bukkit-xxx-dist.jar dernière version pour voir s'il faut le mettre à jour
read wordguardfilenew < <(wget -SqO /dev/null "https://dev.bukkit.org/projects/worldguard/files/latest" 2>&1 | grep -m1 -Po '^\s*Location.*/\K.*')
if [ "${wordguardfileold}" != "${wordguardfilenew}" ];
then
# Mise à jour du nouveau fichier
wget -N "https://dev.bukkit.org/projects/worldguard/files/${wordguardfilenew}"
if [ -e "${backup_source}/plugins/${wordguardfilenew}" ]
then
echo "${current_date} - Mise à jour du fichier : ${wordguardfilenew}" >> "${backup_source}/plugins/update_info.txt"
# Suppression de l'ancien fichier
echo "${current_date} - Suppression du fichier : ${wordguardfileold}" >> "${backup_source}/plugins/update_info.txt"
rm "${backup_source}/plugins/${wordguardfileold}"
else
echo "${current_date} - Echec lors de la mise à jour du fichier : ${wordguardfilenew}" >> "${backup_source}/plugins/update_info.txt"
fi
fi
fi
docker start watchtower-once "$3" |