From f3046ecf48792aac4b47c32c004859fc3a59800d Mon Sep 17 00:00:00 2001 From: godot Date: Sat, 13 Jul 2024 23:32:09 +0200 Subject: [PATCH] graphics and nice look --- script.sh | 111 ++++++++++++++++++++++++++++++++---------------- server-icon.png | Bin 0 -> 714 bytes 2 files changed, 75 insertions(+), 36 deletions(-) create mode 100644 server-icon.png diff --git a/script.sh b/script.sh index bb915df..6d1ab9d 100755 --- a/script.sh +++ b/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 - diff --git a/server-icon.png b/server-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c00f0bce4032324886001b11bc2cb39e13acc6ac GIT binary patch literal 714 zcmV;*0yX`KP)Px#1ZP1_K>z@;j|==^1poj5Ay7VGd00J0EL_t(Y$JLX+j@vK{#&w0A z!K0txKoy0PDZ}B0OlgsH=;Rh~=XA+4bj~ENp4u%5I`JthlKMkOL9=u@4w5YW{P80# zn|ZVV)|9c^X&^tP^X&tLY9}(gAp+H{$bOKyjtVn^5>&nNP*~Xat)F_zqC6}t3DMg_ z{}JAA3zP5QCDr4%InzM{s-7nR_&~)TfukCF5&&2S5B@chs6P4W=jey$+Vn&Qi6aBg z{8H!K6xR`094G}q{ml=~IhLq6*V<&05?+8MB;|>ep^%G!Cm58T% zz&d;e?Lq_AG-p0*l!W%MHVra>dsBb^QC2|!OVC(<4S7Q!C|(URAXu9lk%~AXA_Ms4 zoLiLyz#;*Sp$RW=CsuqUK%06qEDo)fD1iR>`3{gWy!H$AWi|!CzeJrJ3(#g)7XKJL z_`3Ao960;#Zt))gMe_*2{{#Gf0CeL6z@0KMYg80)u!ORc-6UHVT8%S6Z2PNX!^7B} z%CAYr1Xxa#W75C{)c-)M(GMF1c!^w@e;vACE;vqr5;*ZN2QH$}iI?T%SDPDvC0NEy zJQaYiOnh{sg92!y{bT}W9zrWaAz|L!G)i?s7Ui{HrcRu)gvkO$*a(OKUh~lklZ1%^ z{#U)`b6MK}@Fvay)BqjGzYdX=&6tArr7M^lgvz9+S0!-OS1t-@0QHT+djP%_0P!#M wzE*}3uj@Vl000hUSV?A0O#mtY000O800000007cclK=n!07*qoM6N<$f={9)-~a#s literal 0 HcmV?d00001