graphics and nice look
This commit is contained in:
parent
7074706667
commit
f3046ecf48
111
script.sh
111
script.sh
@ -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,34 +98,38 @@ systemctl start mc-forge.service
|
||||
systemctl enable mc-forge
|
||||
|
||||
|
||||
# ipTable script integration
|
||||
iptables -P INPUT ACCEPT #Clears existing rules
|
||||
iptables -A INPUT -i lo -j ACCEPT #Allow loopback
|
||||
# integration of Maxopoly's instructions on firewall
|
||||
|
||||
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT #Allow continuing connections
|
||||
if [[ "n" != "$ansFirewallSetup" ]]; then
|
||||
|
||||
iptables -A INPUT -p tcp --dport 22 --source 172.18.42.0/24 -j ACCEPT #Allow ssh from set network
|
||||
echo "+ Executing firewall setup"
|
||||
|
||||
iptables -A INPUT -p tcp --dport 25565 -j ACCEPT #Allow MC port
|
||||
iptables -P INPUT ACCEPT #Clears existing rules
|
||||
|
||||
iptables -L ### Good place to paste a manual check to not lock yourself out
|
||||
iptables -A INPUT -i lo -j ACCEPT #Allow loopback
|
||||
|
||||
echo -n "Proceed? [Y/n]: "
|
||||
read ans
|
||||
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT #Allow continuing connections
|
||||
|
||||
iptables -A INPUT -p tcp --dport 22 --source 172.18.42.0/24 -j ACCEPT #Allow ssh from set network
|
||||
|
||||
iptables -A INPUT -p tcp --dport 25565 -j ACCEPT #Allow MC port
|
||||
|
||||
|
||||
if [[ "n" != "$ans" ]]; then
|
||||
iptables -L ### Good place to paste a manual check to not lock yourself out
|
||||
|
||||
iptables -P INPUT DROP #Disallow everythink else
|
||||
echo "\n Does it looks right? [Y/n]: "
|
||||
read ansFirewallOK
|
||||
|
||||
iptables -P FORWARD DROP #Block all forwarding
|
||||
|
||||
iptables -P OUTPUT ACCEPT #Allow all outgouing
|
||||
if [[ "n" != "$ansFirewallOK" ]]; then
|
||||
|
||||
iptables -P INPUT DROP #Disallow everythink else
|
||||
|
||||
iptables -P FORWARD DROP #Block all forwarding
|
||||
|
||||
iptables -P OUTPUT ACCEPT #Allow all outgouing
|
||||
fi
|
||||
|
||||
apt install iptables-persistent -y
|
||||
|
||||
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
|
||||
|
||||
|
||||
BIN
server-icon.png
Normal file
BIN
server-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 714 B |
Loading…
x
Reference in New Issue
Block a user