Skip to content

Commit 411bfe3

Browse files
authored
Merge pull request #7 from TimInTech/codex/check-and-improve-file-upload-issues
Fix shellcheck warnings
2 parents a4aafe2 + 1f07376 commit 411bfe3

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

bedrock_helper.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/bash
2+
set -euo pipefail
23
echo "Manual Bedrock update required. Visit official Mojang page to download."

setup_bedrock.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Tested on Debian 11/12 and Ubuntu 24.04
55
# Author: TimInTech
66

7-
set -e # Exit on any error
7+
set -euo pipefail # Exit on error, unset variable, or failed pipeline
88

99
# Install required dependencies
1010
sudo apt update && sudo apt upgrade -y
1111
sudo apt install -y unzip wget screen curl
1212

1313
# Set up server directory
1414
sudo mkdir -p /opt/minecraft-bedrock
15-
sudo chown $(whoami):$(whoami) /opt/minecraft-bedrock
15+
sudo chown "$(whoami)":"$(whoami)" /opt/minecraft-bedrock
1616
cd /opt/minecraft-bedrock
1717

1818
# Fetch the latest Bedrock server URL
@@ -25,10 +25,7 @@ if [[ -z "$LATEST_URL" ]]; then
2525
fi
2626

2727
echo "Downloading Minecraft Bedrock Server from: $LATEST_URL"
28-
wget -O bedrock-server.zip "$LATEST_URL"
29-
30-
# Check if the download was successful
31-
if [[ $? -ne 0 ]]; then
28+
if ! wget -O bedrock-server.zip "$LATEST_URL"; then
3229
echo "ERROR: Download failed. Check your internet connection."
3330
exit 1
3431
fi

setup_minecraft.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Tested on Debian 11/12 and Ubuntu 24.04
55
# Author: TimInTech
66

7-
set -e # Exit script on error
7+
set -euo pipefail # Exit script on error, undefined variable, or failed pipeline
88

99
# Install required dependencies
1010
sudo apt update && sudo apt upgrade -y
@@ -18,12 +18,12 @@ fi
1818

1919
# Set up server directory
2020
sudo mkdir -p /opt/minecraft
21-
sudo chown $(whoami):$(whoami) /opt/minecraft
21+
sudo chown "$(whoami)":"$(whoami)" /opt/minecraft
2222
cd /opt/minecraft
2323

2424
# Fetch the latest PaperMC version
2525
LATEST_VERSION=$(curl -s https://api.papermc.io/v2/projects/paper | jq -r '.versions | last')
26-
LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/paper/versions/$LATEST_VERSION | jq -r '.builds | last')
26+
LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/paper/versions/"$LATEST_VERSION" | jq -r '.builds | last')
2727

2828
# Validate if version and build numbers were retrieved
2929
if [[ -z "$LATEST_VERSION" || -z "$LATEST_BUILD" ]]; then

setup_minecraft_lxc.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# Tested on Debian 11/12 and Ubuntu 24.04
55
# Author: TimInTech
66

7+
8+
set -euo pipefail
9+
710
# Update package lists and install required dependencies
811
apt update && apt upgrade -y
912
apt install -y screen wget curl jq unzip
@@ -15,11 +18,11 @@ if ! apt install -y openjdk-21-jre-headless; then
1518
fi
1619

1720
# Create the Minecraft server directory
18-
mkdir -p /opt/minecraft && cd /opt/minecraft
21+
mkdir -p /opt/minecraft && cd /opt/minecraft || exit
1922

2023
# Fetch the latest PaperMC version
2124
LATEST_VERSION=$(curl -s https://api.papermc.io/v2/projects/paper | jq -r '.versions | last')
22-
LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/paper/versions/$LATEST_VERSION | jq -r '.builds | last')
25+
LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/paper/versions/"$LATEST_VERSION" | jq -r '.builds | last')
2326

2427
# Validate if the version and build exist
2528
if [[ -z "$LATEST_VERSION" || -z "$LATEST_BUILD" ]]; then

update.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/bin/bash
22

3+
set -euo pipefail
4+
35
cd /opt/minecraft || exit 1
46

57
LATEST_VERSION=$(curl -s https://api.papermc.io/v2/projects/paper | jq -r '.versions | last')
6-
LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/paper/versions/$LATEST_VERSION | jq -r '.builds | last')
8+
LATEST_BUILD=$(curl -s https://api.papermc.io/v2/projects/paper/versions/"$LATEST_VERSION" | jq -r '.builds | last')
79

810
wget -O server.jar "https://api.papermc.io/v2/projects/paper/versions/$LATEST_VERSION/builds/$LATEST_BUILD/downloads/paper-$LATEST_VERSION-$LATEST_BUILD.jar"
911

0 commit comments

Comments
 (0)