Skip to content

Commit

Permalink
Added installer
Browse files Browse the repository at this point in the history
  • Loading branch information
bence98 committed Dec 30, 2017
1 parent da441e8 commit da22105
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# MineCartD
A Linux daemon for managing Minecraft servers
A Linux daemon for managing Minecraft servers
by CsokiCraft


## Installation
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`.
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`).


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


Expand All @@ -18,7 +24,7 @@ The config file consists of `key=value` pairs. Lines starting with `#` won't be
### Command-line parameters
* `--cfgfile|-f <file>`: use this config file instead of `/etc/minecartd.conf`
* `--gen-cfg|-C`: generate config and quit. Won't launch Command Interface. Can't be used with `-S`
* `--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`
* `--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`


## Using the Command Interface on the client
Expand Down
63 changes: 63 additions & 0 deletions src/rsrc/minecartd_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh

if [ $(id -u) != 0 ]; then
echo "You must run this script as root!" >&2
exit 1
fi

# Add user and working directory
useradd -U -r -d /var/lib/minecartd -m minecartd

# Download JAR
wget -O /usr/lib/minecartd.jar http://csokicraft.agyklub.hu/downloads?file=minecartd_1.0.jar

# Add runscript
cat > /usr/bin/minecartd <<'EOF'
#!/bin/sh
java -jar /usr/lib/minecartd.jar "$@"
EOF
chmod 655 /usr/bin/minecartd

# Create config (using newly created runscript) while we're root
/usr/bin/minecartd -C

# Add systemd service entry
cat > /etc/systemd/system/minecartd.service <<EOF
[Unit]
Description=MineCartD - A Linux daemon for managing Minecraft servers
After=network.target
[Service]
Type=simple
User=minecartd
WorkingDirectory=/var/lib/minecartd
ExecStart=/usr/bin/minecartd
ExecStop=/usr/bin/minecartd -S
Restart=no
[Install]
WantedBy=multi-user.target
EOF

# Enable and start service
systemctl enable minecartd
systemctl start minecartd

cat > /usr/bin/minecartd_uninstall <<EOF
#!/bin/sh
systemctl stop minecartd
systemctl disable minecartd
rm /etc/systemd/system/minecartd.service
rm /etc/minecartd.conf
rm /usr/lib/minecartd.jar
rm /usr/bin/minecartd
rm /usr/bin/minecartd_uninstall
userdel minecartd
echo "MineCartD was successfully uninstalled!"
EOF
chmod 655 /usr/bin/minecartd_uninstall

echo "MineCartD is now installed on your computer!"

0 comments on commit da22105

Please sign in to comment.