graphics and nice look

This commit is contained in:
godot 2024-07-13 23:32:09 +02:00
parent 7074706667
commit f3046ecf48
2 changed files with 75 additions and 36 deletions

View File

@ -1,15 +1,58 @@
#!/bin/bash
# better to run as root
echo "Better to run as root, because of permisions handeling."
sleep 2
echo "Do you want to set up firewall rules by iptables? [Y/n]: "
read ansFirewallSetup
if [[ "n" != "$ansFirewallSetup" ]]; then
echo "\n Do you want to block non-LAN ssh connections? [Y/n/ip range]: "
read -n 1 sshBlockRange
if [[ "$sshBlockRange" == "y"
||"$sshBlockRange" == "Y"
||"$sshBlockRange" == "" ]]; then
### Have to found how to locate LAN
$sshBlockRange = "y"
elif [[ "$sshBlockRange" == "n"
|| "$sshBlockRange" == "N"]]; then
$sshBlockRange = ""
elif [[ -n "$sshBlockRange" ]]; then
echo "Hope you know what you are doing, I am not checking these :]"
echo "You have 5 seconds to stope this by pressing Ctrl+C"
sleep 5
echo "OK, lets go now"
echo "Dont worry you will have time to chack if it is looking righ later."
sleep 2
fi
fi
# Just to be shure
echo "\n+ Starting to upgrade base system\n\n"
sudo apt update
sudo apt upgrade -y
# Installing depandencies
echo "\n+ Installing depandencies \n\n"
sudo apt install openjdk-17-jre-headless screen p7zip-full iptables -y
# User and groupe managment
echo "\n+ Creating user minecraft and basic file structure"
groupadd minecraft
useradd --system --shell /usr/sbin/nologin --home /opt/minecraft -g minecraft minecraft
@ -22,38 +65,30 @@ mv Forge-1.20.1.jar /opt/minecraft/
cd /opt/minecraft/
# Installing server
java -Xms512M -Xmx2048M -jar Forge-1.20.1.jar --installServer
echo "+ Installing Forge 1.20.1 \n \n"
/bin/sleep 10
java -Xms512M -Xmx2048M -jar Forge-1.20.1.jar --installServer
cd -
# /opt/minecraft/run.sh # it may needs to run before copying eula. But I dont want to mess with timing
# rm eula.txt # I hope this is not needed
mv eula.txt /opt/minecraft/
# it may need to run run.sh but i dont want to >]^C
# rm -rf world/
# rm server.properties
mv server-icon.png /opt/minecraft/
mv server.properties /opt/minecraft/
# rm run.sh
mv run.sh /opt/minecraft
mkdir /opt/minecraft/mods
echo "\n+ Unpacking mods \n \n"
7z x Mods.zip -o/opt/minecraft/mods/
# Permision handeling
echo "\n+ Permision handeling"
chown -R minecraft:minecraft /opt/minecraft
# SystemD service
echo "+ Preparign systemD service"
cp mc-forge.service /etc/systemd/system/
systemctl daemon-reload
@ -63,8 +98,14 @@ systemctl start mc-forge.service
systemctl enable mc-forge
# ipTable script integration
# integration of Maxopoly's instructions on firewall
if [[ "n" != "$ansFirewallSetup" ]]; then
echo "+ Executing firewall setup"
iptables -P INPUT ACCEPT #Clears existing rules
iptables -A INPUT -i lo -j ACCEPT #Allow loopback
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT #Allow continuing connections
@ -73,13 +114,14 @@ iptables -A INPUT -p tcp --dport 22 --source 172.18.42.0/24 -j ACCEPT #Allow ssh
iptables -A INPUT -p tcp --dport 25565 -j ACCEPT #Allow MC port
iptables -L ### Good place to paste a manual check to not lock yourself out
echo -n "Proceed? [Y/n]: "
read ans
echo "\n Does it looks right? [Y/n]: "
read ansFirewallOK
if [[ "n" != "$ans" ]]; then
if [[ "n" != "$ansFirewallOK" ]]; then
iptables -P INPUT DROP #Disallow everythink else
@ -88,9 +130,6 @@ if [[ "n" != "$ans" ]]; then
iptables -P OUTPUT ACCEPT #Allow all outgouing
fi
#### Intervention needed, after install it runs something and i dont know how to set it here
apt install iptables-persistent -y
# iptables-save > /etc/iptables/rules.v4
fi

BIN
server-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B