Skip to content

Commit 05b4756

Browse files
authored
Merge pull request #28 from TimInTech/chore/audit-minor-fixes
Chore/audit minor fixes
2 parents 9ffc06f + 119ef19 commit 05b4756

5 files changed

Lines changed: 37 additions & 18 deletions

File tree

.github/copilot-instructions.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ When asked “Run/Build”, provide these options as example commands (explanati
1515
```bash
1616
chmod +x setup_minecraft.sh
1717
./setup_minecraft.sh
18-
screen -r minecraft
19-
````
18+
sudo -u minecraft screen -r minecraft
19+
```
2020

2121
### Option 2: Java server in LXC/Container
2222

2323
```bash
2424
chmod +x setup_minecraft_lxc.sh
2525
./setup_minecraft_lxc.sh
26-
screen -r minecraft
26+
sudo -u minecraft screen -r minecraft
2727
```
2828

2929
### Option 3: Bedrock server
3030

3131
```bash
3232
chmod +x setup_bedrock.sh
3333
./setup_bedrock.sh
34-
screen -r bedrock
34+
sudo -u minecraft screen -r bedrock
3535
```
3636

3737
### Option 4: Update existing Java server (PaperMC)
@@ -57,4 +57,3 @@ sudo systemctl enable --now minecraft
5757
* For detailed step-by-step effects of each script, refer to `SIMULATION.md`.
5858

5959

60-

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Perfect for self-hosters, gaming communities, and homelab enthusiasts!
3939

4040
## 📊 Status
4141

42-
> ⚠ No build workflow present
43-
> For automated tests or deployment, please add `main.yml` to `.github/workflows/`.
42+
ShellCheck linting workflow is present under `.github/workflows/shellcheck.yml`.
43+
Add additional tests or deployment workflows as needed.
4444

4545
---
4646

@@ -55,7 +55,7 @@ chmod +x setup_minecraft.sh
5555
```
5656
Open console:
5757
```bash
58-
screen -r minecraft
58+
sudo -u minecraft screen -r minecraft
5959
```
6060

6161
### VM (Static IP)
@@ -86,7 +86,7 @@ chmod +x setup_minecraft_lxc.sh
8686
```
8787
Open console:
8888
```bash
89-
screen -r minecraft
89+
sudo -u minecraft screen -r minecraft
9090
```
9191

9292
### Bedrock
@@ -98,7 +98,7 @@ chmod +x setup_bedrock.sh
9898
```
9999
Open console:
100100
```bash
101-
screen -r bedrock
101+
sudo -u minecraft screen -r bedrock
102102
```
103103

104104
---

scripts/proxmox_create_ct_bedrock.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pct create "$CTID" "${STORE}:vztmpl/${TPL}" -hostname mc-bedrock -cores 2 -mem
1111
pct start "$CTID"
1212
pct exec "$CTID" -- bash -lc '
1313
apt update && apt -y install wget curl
14-
wget -qO /root/setup_bedrock.sh https://raw.githubusercontent.com/TimInTech/minecraft-server-Proxmox.git/main/setup_bedrock.sh
14+
wget -qO /root/setup_bedrock.sh https://raw.githubusercontent.com/TimInTech/minecraft-server-Proxmox/main/setup_bedrock.sh
1515
bash /root/setup_bedrock.sh
1616
'
1717
echo "CT $CTID ready. Change password. Attach: pct enter $CTID"

setup_minecraft.sh

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ fi
2020
sudo mkdir -p /opt/minecraft
2121
if ! id -u minecraft >/dev/null 2>&1; then sudo useradd -r -m -s /bin/bash minecraft; fi
2222
sudo chown -R minecraft:minecraft /opt/minecraft
23-
sudo chown "$(whoami)":"$(whoami)" /opt/minecraft
2423
cd /opt/minecraft || exit 1
2524

2625
# Fetch the latest PaperMC version
@@ -60,19 +59,37 @@ EOF
6059
chmod +x start.sh
6160

6261
# Create update script
63-
cat <<EOF > update.sh
62+
cat <<'EOF' > update.sh
6463
#!/bin/bash
64+
set -euo pipefail
6565
cd /opt/minecraft || exit 1
66-
LATEST_VERSION=\$(curl -s https://api.papermc.io/v2/projects/paper | jq -r '.versions | last')
67-
LATEST_BUILD=\$(curl -s https://api.papermc.io/v2/projects/paper/versions/\$LATEST_VERSION | jq -r '.builds | last')
66+
LATEST_VERSION=$(curl -s https://api.papermc.io/v2/projects/paper | jq -r '.versions | last')
67+
LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/paper/versions/"$LATEST_VERSION" | jq -r '.builds | last')
68+
BUILD_JSON="$(curl -s "https://api.papermc.io/v2/projects/paper/versions/${LATEST_VERSION}/builds/${LATEST_BUILD}")"
69+
EXPECTED_SHA="$(printf '%s' "$BUILD_JSON" | jq -r '.downloads.application.sha256')"
70+
JAR_NAME="$(printf '%s' "$BUILD_JSON" | jq -r '.downloads.application.name')"
6871
69-
wget -O server.jar "https://api.papermc.io/v2/projects/paper/versions/\$LATEST_VERSION/builds/\$LATEST_BUILD/downloads/paper-\$LATEST_VERSION-\$LATEST_BUILD.jar"
70-
echo "✅ Update complete."
72+
wget -O "server.jar" "https://api.papermc.io/v2/projects/paper/versions/${LATEST_VERSION}/builds/${LATEST_BUILD}/downloads/${JAR_NAME}"
73+
ACTUAL_SHA="$(sha256sum server.jar | awk '{print $1}')"
74+
if [ -n "$EXPECTED_SHA" ] && [ "$EXPECTED_SHA" != "null" ]; then
75+
if [ "$ACTUAL_SHA" != "$EXPECTED_SHA" ]; then
76+
echo "ERROR: SHA256 mismatch for PaperMC (expected ${EXPECTED_SHA}, got ${ACTUAL_SHA})"
77+
exit 1
78+
fi
79+
echo "SHA256 verified: ${ACTUAL_SHA}"
80+
else
81+
echo "WARNING: No upstream SHA provided; computed: ${ACTUAL_SHA}"
82+
fi
83+
84+
echo "✅ Update complete to version $LATEST_VERSION (build $LATEST_BUILD)"
7185
EOF
7286
chmod +x update.sh
7387

88+
# Ensure all files are owned by the runtime user
89+
sudo chown -R minecraft:minecraft /opt/minecraft
90+
7491
# Start server in detached screen session
7592
if command -v runuser >/dev/null 2>&1; then runuser -u minecraft -- bash -lc 'cd /opt/minecraft && screen -dmS minecraft ./start.sh'; else sudo -u minecraft bash -lc 'cd /opt/minecraft && screen -dmS minecraft ./start.sh'; fi
7693

7794
echo "✅ Minecraft Server setup complete!"
78-
echo "To access console: sudo -u $(whoami) screen -r minecraft"
95+
echo "To access console: sudo -u minecraft screen -r minecraft"

setup_minecraft_lxc.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ EOF
5959

6060
chmod +x start.sh
6161

62+
# Ensure all files are owned by the runtime user
63+
chown -R minecraft:minecraft /opt/minecraft
64+
6265
# Start the server in a detached screen session
6366
if command -v runuser >/dev/null 2>&1; then runuser -u minecraft -- bash -lc 'cd /opt/minecraft && screen -dmS minecraft ./start.sh'; else sudo -u minecraft bash -lc 'cd /opt/minecraft && screen -dmS minecraft ./start.sh'; fi
6467

0 commit comments

Comments
 (0)