blob: b80b5b983a1f6d9ae14a6347025038478bb44606 (
plain)
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
|
#!/bin/bash
if [ "$#" -eq 0 ]; then
cat <<EOF
Usage: craftbukkit-save [-d DIR] COMMAND...
Executes COMMAND with Minecraft's saving disabled
Options:
-d DIR Specifies the server directory being used, to distinguish which
server to access when using minecraft@.service, craftbukkit@.service,
or spigot@.service. After the path is made absolute, the encoded form
("systemd-escape -p") should match the instance name (part after
the @). Empty string means no instance (same as not providing the
argument).
Disabling saving lets users continue using the Minecraft server while also
providing a consistent view of the Minecraft files. This allows a consistent
backup (or "snapshot") to be made. Saving is automatically enabled when COMMAND
completes.
EOF
exit 1
fi
DIR=
if [ "$1" = "-d" ]; then
if [ "$#" -lt 2 ]; then
echo "Must specify a directory after -d" >&2
exit 1
fi
DIR="$2"
shift 2
fi
if /usr/bin/craftbukkit-mcrcon -d "$DIR" --is-running; then
if ! /usr/bin/craftbukkit-mcrcon -d "$DIR" --dryrun; then
echo "Warning: RCON not available. Can't guarantee valid backups." >&2
else
trap '/usr/bin/craftbukkit-mcrcon save-on' EXIT
/usr/bin/craftbukkit-mcrcon save-off save-all
fi
fi
"$@"
|