-
Notifications
You must be signed in to change notification settings - Fork 0
/
mccreate
executable file
·39 lines (34 loc) · 1.1 KB
/
mccreate
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
#!/bin/sh
# Setup server
# `build-essentials` is only required if you don't have mcrcon yet
./update
sudo apt install -y openjdk-8-jre-headless
if [ -e "~/backups" ]; then
# New server with backup (assumed in ~/backups)
./mcrestore
fi
if [ -e "~/bin/mcrcon" ]; then
# Build mcrcon if not present
sudo apt install -y build-essential
mkdir -p ~/{backups,server}
pwd=`pwd`
cd ../github_mcrcon
git submodule init
git submodule update
gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c
mv mcrcon ~/bin
cd $pwd
sudo apt remove -y build-essential
sudo apt autoremove -y
fi
# Set systemd user service
mkdir -p ~/.config/systemd/user
ln ~/bin/mc.service ~/.config/systemd/user/mc.service
loginctl enable-linger mc
systemctl --user daemon-reload
./mcenable
./mcstart
crontab -l 2>/dev/null | grep -q 'mcshutdownwarning' || (crontab -l 2>/dev/null; echo "21 55 * * * $HOME/bin/mcshutdownwarning") | crontab -
crontab -l 2>/dev/null | grep -q 'mcbackup' || (crontab -l 2>/dev/null; echo "21 55 * * * $HOME/bin/mcbackup") | crontab -
sudo timedatectl set-timezone Europe/Amsterdam
sudo systemctl restart crond