-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-minecraft.sh.odl
executable file
·56 lines (45 loc) · 1.86 KB
/
update-minecraft.sh.odl
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
#!/bin/bash
# Set your Docker Hub username
DOCKER_USERNAME="jjziets"
# Path to the version file
VERSION_FILE="./minecraft_bedrock_version"
# Initial version
VERSION=""
# Navigate to the directory containing your docker-compose.yml file
#cd /path/to/your/docker-compose/directory
while true; do
if [ -f "$VERSION_FILE" ]; then
NEW_VERSION=$(cat $VERSION_FILE)
# If the version has changed
if [ "$NEW_VERSION" != "$VERSION" ]; then
# Update the Dockerfile with the new version
sed -i "s/^ENV MINECRAFT_VERSION=.*/ENV MINECRAFT_VERSION=${NEW_VERSION}/" Dockerfile
# Build the new Docker image with the latest version
if docker build -t ${DOCKER_USERNAME}/minecraft-bedrock:latest . ; then
echo "Docker build successful"
else
echo "Docker build failed, please check the Dockerfile and the network connection."
sleep 60
continue
fi
# Push the new image to Docker Hub
if docker push ${DOCKER_USERNAME}/minecraft-bedrock:latest ; then
echo "Docker push successful"
# Pull the latest image, remove old images, and recreate the containers
if docker-compose pull && docker image prune -a -f && docker-compose down && docker-compose up -d ; then
echo "Server update successful"
else
echo "Server update failed, please check the docker-compose file and the network connection."
fi
else
echo "Docker push failed, please check your Docker Hub credentials and network connection."
sleep 60
continue
fi
# Update the version
VERSION="$NEW_VERSION"
fi
fi
# Sleep for 1 minute
sleep 60
done