first commit yeeah

This commit is contained in:
grey-cat-1908 2024-01-30 20:39:50 +03:00
commit e9ecd4ef50
10 changed files with 190 additions and 0 deletions

4
.balena/balena.yml Normal file
View file

@ -0,0 +1,4 @@
name: Minecraft Server
data:
applicationEnvironmentVariables:
- RAM: 1G

13
LICENSE.txt Normal file
View file

@ -0,0 +1,13 @@
Copyright 2024 Viktor K
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

54
README.md Normal file
View file

@ -0,0 +1,54 @@
# Your Portable Minecraft Server
This is a project that allows you to easily install and configure a minecraft server on your Raspberry Pi or other similar device.
## Advantages
- Easy and very fast installation
- Does not require any knowledge
- Portable (you can bring your Raspberry Pi wherever you want)
- It is cheap (No need to pay for anything other than electricity if you already have a Raspberry Pi)
- Runs on Raspberry Pi 4 and Raspberry Pi 5 (4G and 8GB model)
- You'll look cool in front of your friends if you run a server on the board (if they don't know what Raspberry Pi is)
- Does not load your computer
- You can control and configure everything (as long as your board has enough power)
## Setup
... ToDo...?
## Connecting to the server
... ToDo...?
## Configuring
You can configure nearly everything by setting up the following Enviroment Variables:
| Variable | Description | Value |
|---|---|---|
| `RAM` | How much RAM do you want to allocate to the server? | `1G` (default) |
| `MC_VERSION` | What version of Minecraft do you want to install? | `1.20` (default) |
| `SSH_PASSWORD` | SSH password | `admin` (default) |
**NOTE:** You can set Environment Variable within balenaCloud. On the left, simply click on “Device Variables” and then click the “Add Variable” button. Give it a name, and set the value.
![set variable demonstration](https://cdn.arbuz.icu/img/balena/balenaSetVariables.png)
## Connecting to the server using SFTP
I recommend using FileZilla to connect to the server via SFTP.
### FileZilla User Guide
... ToDo...?
Once the connection is established, remember to navigate to the `/usr/src/mcfiles' directory.
## Installing plugins
... ToDo...?
## Mods...?
... ToDo...?

31
docker-compose.yml Normal file
View file

@ -0,0 +1,31 @@
version: '2'
services:
minecraft:
network_mode: host
restart: always
build: ./minecraft
privileged: true
labels:
io.balena.features.dbus: 1
io.balena.features.supervisor-api: 1
volumes:
- mcfiles:/usr/src/mcfiles
- localcache:/localcache
ports:
- "25565:25565/tcp"
ssh:
network_mode: host
restart: always
build: ./ssh
privileged: false
labels:
io.balena.features.dbus: 1
volumes:
- mcfiles:/usr/src/mcfiles
- localcache:/localcache
ports:
- "22:22/tcp"
- "22:22/udp"
volumes:
mcfiles:
localcache:

View file

@ -0,0 +1,13 @@
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian:latest
ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
RUN install_packages wget jq openjdk-17-jre
COPY . /
COPY run.sh /usr/src/
RUN chmod +x /usr/src/run.sh
CMD ["/bin/bash", "/usr/src/run.sh"]

View file

@ -0,0 +1 @@
eula=true

View file

@ -0,0 +1,16 @@
enable-jmx-monitoring=false
rcon.port=25575
enable-command-block=true
motd=A Minecraft Server
max-players=20
online-mode=true
enable-status=true
view-distance=7
server-ip=0.0.0.0
server-port=25565
enable-rcon=false
simulation-distance=5
rcon.password=
white-list=false
sync-chunk-writes=false
spawn-protection=1

41
minecraft/run.sh Normal file
View file

@ -0,0 +1,41 @@
get_pufferfish_server() {
if [[ -z "$RAM" ]]; then
MC_VERSION="1.20"
fi
majorVersion=$MC_VERSION
PUFFERFISH_BUILD_JSON=$(curl -X GET -s "https://ci.pufferfish.host/job/Pufferfish-${majorVersion}/lastSuccessfulBuild/api/json")
PUFFERFISH_BUILD_URL=$(jq -n "$PUFFERFISH_BUILD_JSON" | jq -jc '.url // empty' )
PUFFERFISH_BUILD_FILENAME=$(jq -n "$PUFFERFISH_BUILD_JSON" | jq -jc '.artifacts[].fileName // empty' )
PUFFERFISH_BUILD_DOWNLOAD_URL="${PUFFERFISH_BUILD_URL}artifact/build/libs/${PUFFERFISH_BUILD_FILENAME}"
shopt -s nullglob
if [ -f "pufferfish.jar" ]; then
rm "pufferfish.jar"
fi
wget --quiet -O pufferfish.jar -T 60 $PUFFERFISH_BUILD_DOWNLOAD_URL
}
if [[ ! -e "/localcache/conf-saved.txt" ]]; then
cp -R /mcfiles /usr/src/
touch /localcache/conf-saved.txt
fi
cd /usr/src/mcfiles/ || exit
if [[ ! -e "pufferfish.jar" ]]; then
get_pufferfish_server
else
if [[ "$FORCE_REINSTALL" -eq 1 ]]; then
get_pufferfish_server
fi
fi
if [[ -z "$RAM" ]]; then
RAM="1G"
fi
java -Xms$RAM -Xmx$RAM -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1HeapRegionSize=8M -XX:G1HeapWastePercent=5 -XX:G1MaxNewSizePercent=40 -XX:G1MixedGCCountTarget=4 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1NewSizePercent=30 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:G1ReservePercent=20 -XX:InitiatingHeapOccupancyPercent=15 -XX:MaxGCPauseMillis=200 -XX:MaxTenuringThreshold=1 -XX:SurvivorRatio=32 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar pufferfish.jar nogui
sleep 10

7
ssh/Dockerfile.template Normal file
View file

@ -0,0 +1,7 @@
FROM balenalib/%%BALENA_MACHINE_NAME%%:latest
RUN install_packages openssh-server
COPY run.sh /usr/src/
CMD ["/bin/bash", "/usr/src/run.sh"]

10
ssh/run.sh Normal file
View file

@ -0,0 +1,10 @@
if [[ -z "$SSH_PASSWORD" ]]; then
export SSH_PASSWORD=admin
fi
mkdir /var/run/sshd
echo "root:$SSH_PASSWORD" | chpasswd
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config
exec /usr/sbin/sshd -D