Browse Source

changed mount points

feature/startup-from-labels
Mar Alegre 5 years ago
parent
commit
eae48a09b2
  1. 2
      src/minecraft_be/Containerfile
  2. 31
      src/minecraft_be/assets/bin/mcbe-backup
  3. 12
      src/minecraft_be/assets/minecraft/permissions.json

2
src/minecraft_be/Containerfile

@ -8,7 +8,7 @@ FROM localhost/debian:latest
LABEL deployopts="\ LABEL deployopts="\
-p 19132:19132/udp \ -p 19132:19132/udp \
-p 19133:19133/udp \ -p 19133:19133/udp \
-v /srv/vol/minecraft_be/worlds:/vol/worlds" -v /srv/vol/minecraft_be/data:/vol/data"
# Build variables # Build variables
# uid that the files owner user should have # uid that the files owner user should have

31
src/minecraft_be/assets/bin/mcbe-backup

@ -1,14 +1,29 @@
#!/bin/bash #!/bin/bash
do_backup() { do_stop() {
echo "Shutting down server for scheduled daily backup." echo "Shutting down server for scheduled daily backup."
mcbe-shutdown 10 "Shutting down server for scheduled daily backup." mcbe-shutdown 10 "Shutting down server for scheduled daily backup."
rsync -vaSH /home/mcadmin/worlds/ /vol/worlds/ }
do_start() {
sleep 5 sleep 5
echo "Restarting server after backup." echo "Restarting server after backup."
service mcbe start service mcbe start
} }
do_backup() {
day=$(date +%d)
cd /vol/data
mkdir -p worlds-daily-$day/
rsync -vaSH /home/mcadmin/worlds/ worlds-daily-$day/
if [[ $day == 1 ]]; then
month=$(date +%m)
year=$(date +%Y)
mkdir -p worlds-$year-$month-$day/
rsync -vaSH worlds-daily-$day/ worlds-$year-$month-$day/
fi
}
# Check if server is started # Check if server is started
status=$(systemctl show mcbe -p ActiveState --value) status=$(systemctl show mcbe -p ActiveState --value)
# Check if any players present # Check if any players present
@ -16,22 +31,26 @@ players=$(mcbe-exec list | cut -d ' ' -f 3 | cut -d '/' -f 1)
# check when mcbe-backup was last triggered # check when mcbe-backup was last triggered
last=$(date -d "$(systemctl show mcbe-backup.timer -p LastTriggerUSec --value)" +%s) last=$(date -d "$(systemctl show mcbe-backup.timer -p LastTriggerUSec --value)" +%s)
# get current time # get current time
today=$(date +%s) now=$(date +%s)
# if service is not active, do backup immediately and exit # if service is not active, do backup immediately and exit
if [[ $status == inactive ]]; then if [[ $status != active ]]; then
echo "Service is inactive: copying worlds immediately without restarting service." echo "Service is inactive: copying worlds immediately without restarting service."
rsync -vaSH /home/mcadmin/worlds/ /vol/worlds/ do_backup
# if no players are present, do backup immediately and exit # if no players are present, do backup immediately and exit
elif [[ $players == 0 ]]; then elif [[ $players == 0 ]]; then
echo "No players detected: running backup immediately." echo "No players detected: running backup immediately."
do_stop
do_backup do_backup
do_start
# if 12 or more hours have passed since backup was triggered, go ahead and force a shutdown anyways # if 12 or more hours have passed since backup was triggered, go ahead and force a shutdown anyways
elif [[ $(( $today - $last )) -ge 43200 ]]; then elif [[ $(( $now - $last )) -ge 43200 ]]; then
echo "Backup was triggered more than 12 hours ago: forcing backup now." echo "Backup was triggered more than 12 hours ago: forcing backup now."
do_stop
do_backup do_backup
do_start
# otherwise, schedule another attempt in an hour # otherwise, schedule another attempt in an hour
else else

12
src/minecraft_be/assets/minecraft/permissions.json

@ -1,6 +1,10 @@
[ [
{ {
"permission" : "operator", "permission": "operator",
"xuid" : "2535473403284928" "xuid": "2535473403284928"
} },
{
"permission": "operator",
"xuid": ""
}
] ]

Loading…
Cancel
Save