Skip to content

Commit da22105

Browse files
committed
Added installer
1 parent da441e8 commit da22105

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# MineCartD
2-
A Linux daemon for managing Minecraft servers
2+
A Linux daemon for managing Minecraft servers
3+
by CsokiCraft
4+
5+
6+
## Installation
7+
Run the `minecartd_install` script. It downloads and installs `minecartd`, sets up a new user account, generates default config file and servers directory, and installs and enables a `systemd` service for `minecartd`.
8+
In general, using the service is the preferred method. However, on systems without `systemd`, or when testing the software, you may opt to disable it (`systemctl stop minecartd && systemctl disable minecartd`) and use the command line instead (`/usr/bin/minecartd` or `java -jar minecartd.jar`).
39

410

511
## Usage
6-
On the server, run `minecartd`.
12+
On the server, run `minecartd`, either from command line or via `systemd` service.
713
Then on the client, connect to it with an appropriate tool (ex. `telnet`) to access the Command Interface
814

915

@@ -18,7 +24,7 @@ The config file consists of `key=value` pairs. Lines starting with `#` won't be
1824
### Command-line parameters
1925
* `--cfgfile|-f <file>`: use this config file instead of `/etc/minecartd.conf`
2026
* `--gen-cfg|-C`: generate config and quit. Won't launch Command Interface. Can't be used with `-S`
21-
* `--stop|-S`: connect to a server on localhost and send STOP to it (stops all Minecraft servers and the `minecartd` host). Can't be used with `-C`
27+
* `--stop|-S`: connect to a server on `localhost` and send `STOP` to it (stops all Minecraft servers and the `minecartd` host). Can't be used with `-C`
2228

2329

2430
## Using the Command Interface on the client

src/rsrc/minecartd_install

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
3+
if [ $(id -u) != 0 ]; then
4+
echo "You must run this script as root!" >&2
5+
exit 1
6+
fi
7+
8+
# Add user and working directory
9+
useradd -U -r -d /var/lib/minecartd -m minecartd
10+
11+
# Download JAR
12+
wget -O /usr/lib/minecartd.jar http://csokicraft.agyklub.hu/downloads?file=minecartd_1.0.jar
13+
14+
# Add runscript
15+
cat > /usr/bin/minecartd <<'EOF'
16+
#!/bin/sh
17+
java -jar /usr/lib/minecartd.jar "$@"
18+
EOF
19+
chmod 655 /usr/bin/minecartd
20+
21+
# Create config (using newly created runscript) while we're root
22+
/usr/bin/minecartd -C
23+
24+
# Add systemd service entry
25+
cat > /etc/systemd/system/minecartd.service <<EOF
26+
[Unit]
27+
Description=MineCartD - A Linux daemon for managing Minecraft servers
28+
After=network.target
29+
30+
[Service]
31+
Type=simple
32+
User=minecartd
33+
WorkingDirectory=/var/lib/minecartd
34+
ExecStart=/usr/bin/minecartd
35+
ExecStop=/usr/bin/minecartd -S
36+
Restart=no
37+
38+
[Install]
39+
WantedBy=multi-user.target
40+
EOF
41+
42+
# Enable and start service
43+
systemctl enable minecartd
44+
systemctl start minecartd
45+
46+
cat > /usr/bin/minecartd_uninstall <<EOF
47+
#!/bin/sh
48+
systemctl stop minecartd
49+
systemctl disable minecartd
50+
51+
rm /etc/systemd/system/minecartd.service
52+
rm /etc/minecartd.conf
53+
rm /usr/lib/minecartd.jar
54+
rm /usr/bin/minecartd
55+
rm /usr/bin/minecartd_uninstall
56+
57+
userdel minecartd
58+
59+
echo "MineCartD was successfully uninstalled!"
60+
EOF
61+
chmod 655 /usr/bin/minecartd_uninstall
62+
63+
echo "MineCartD is now installed on your computer!"

0 commit comments

Comments
 (0)