This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmc
More file actions
68 lines (62 loc) · 1.28 KB
/
mc
File metadata and controls
68 lines (62 loc) · 1.28 KB
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
#!/bin/sh
user=mcbe
if [ "$(whoami)" != "$user" ]; then
exec sudo -u $user -- "$0" $@
exit
fi
container="minecraft-server"
man=podman
snap="cheesecraft"
help_msg () {
cat <<EOF
console - Connect the current terminal to the Bedrock server console
comm - Run a command on the Bedrock server console
start - Start the server
stop - Stop the server
restart - Restart the server
logs - View the server logs
backup - Create a backup of the world and server config (Takes comment as argument)
backups - View the list of available backups
restore - Restore a backup (Takes number as argument)
EOF
}
cd /home/$user
case "$1" in
comm)
shift
$man exec "$container" send-command $@
;;
console) $man attach "$container";;
start) $man start "$container";;
stop) $man stop "$container";;
restart) $man restart "$container";;
logs) $man logs "$container" | less +G -R;;
backup)
shift
if [ -z "$@" ]; then
echo Error: Missing backup comment
exit
fi
snapper -c "$snap" create --description "$@"
;;
backups) snapper -c "$snap" list;;
restore)
id=$2
if [ -z "$id" ]; then
echo Error: Missing backup number
exit
fi
echo Restoring backup "#"$id
sudo /usr/local/bin/mc_restore "$id"
;;
"")
echo Usage
echo -----
help_msg
;;
*)
echo Invalid command
echo ---------------
help_msg
;;
esac