Featured Post

HOW TO: Install VPN server on Ubuntu when server is behind firewall

The whole point in this post is to run your own VPN service, and allow you to connect remote devices to your home network. To start off yo...

Oct 12, 2017

HOWTO: Notify user joined your Minecraft server (Nukkit or similar) using Notify My Android



So I setup a Minecraft server for my son and his friends, but it is hard to coordinate when they will all get online - so I decided to look into my options for notifications. In the end I went with Notify My Android (NMA). The NMA website provides a complete script for sending notifications via the Raspbian shell. The script can be found at the following location, I used the shell script, but there are other options - this guide focuses on the shell script:

http://www.notifymyandroid.com/dev.jsp

First thing we are going to do is log into our Raspbian system and let's make sure timezone is configured correctly:

sudo dpkg-reconfigure tzdata

Now let's download the notification script from NMA to your Raspberry Pi Minecraft server:

wget http://storage.locked.io/files/nma.sh

We need to do a couple of things with this file, first we need to make a change so that our NMA API key is in the file, using the following command:

sudo nano nma.sh

Edit APIKey= to use your API Key, you can find your own API Key from the NMA site.

Now we have to make the shell script executable:

chmod +x nma.sh

At this point we have a shell script that allows us to send notifications from Raspbian to NMA servers, and then to your Android. The next step is to create a short Perl file to monitor the Nukkit server.log (or any other log file for that matter). This script looks at the entire file, not just the tail, so if you run it against an existing server you are going to get a few notifications when first run. I called my file notify.pl:

sudo nano notify.pl

Enter the following into the notify.pl Perl script:

#Change /location/of/server.log in the following line to the real location of your server.log file

open(my $fd, "<", "/location/of/server.log") or die "Can't open log";
while(1) {
    if(eof $fd) {
        sleep 1;
        $fd->clearerr;
        next;
    }
    my $line = <$fd>;
#Parse the line into variables
my ($date, $time, $loglevel, $user, $operation) = split / /,$line;
    chomp($line);
    if($line =~ m/joined/) {
        system("./nma.sh \"Minecraft\" \"$user Joined\" \"At $time on $date $user $operation.\" 1");
    } elsif($line =~ m/left/) {
        system("./nma.sh \"Minecraft\" \"$user Left\" \"At $time on $date $user $operation.\" 1");
    }
}

Much like the NMA script we have to make our Perl script executable:

chmod +x notify.pl

That's it! Now you are going to have to run this at startup, much like you run your Minecraft server, so edit crontab:

crontab -e

Enter the following at the end of your file:

@reboot sleep 30 && sudo /usr/bin/perl /home/pi/notify.pl

The sleep is required to make sure the server has the log file available (didn't work for me without the sleep, I can only assume as the file is deleted on startup):

Reboot your server and you are good to go!

Oct 8, 2017

HOWTO: Setup Minecraft Server on Raspberry Pi 3



Download the Rasbian Lite IMG:

https://www.raspberrypi.org/downloads/

Use Etcher to write the image to your microSD card.

https://etcher.io

Once written boot up Raspbian in your Pi and carry out the following:

Configure your wireless connection if needed:

wpa_passphrase "ESSID" "Password" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null

Where ESSID and Password are wireless network name and connection password respectively.

Upgrade your system:

sudo apt-get update
sudo apt-get upgrade

Install Java:

sudo apt-get install oracle-java8-jdk

Enable SSH via Interface Options

sudo raspi-config

Finish and Reboot

Install Nukkit (the git clone link by default would be https://github.com/Nukkit/, but it didn't support the latest Minecraft version so I found another fork and specific branch)

sudo apt-get install -y git
sudo apt-get install -y maven
git clone -b GT1.2 https://github.com/Creeperface01/Nukkit.git
cd Nukkit
git submodule update --init
mvn clean
mvn package

Now run for the first time and setup the appropriate language:

/usr/bin/java -jar /home/pi/Nukkit/target/nukkit-1.0-SNAPSHOT.jar

Now run the server at boot by adding a command to crontab:

crontab -e

Paste the following into crontab:

@reboot sudo /usr/bin/java -jar /home/pi/Nukkit/target/nukkit-1.0-SNAPSHOT.jar

If you want to access this from anywhere in the world, and not just your local network then your should have your own domain name, then you can forward all connections to your specific machine. Go into your router, forward the specific port (for me it was 19678) to the IP of the machine running Nukkit.

Sep 29, 2017

HOW TO: Install VPN server on Ubuntu when server is behind firewall

The whole point in this post is to run your own VPN service, and allow you to connect remote devices to your home network.

To start off you need to choose a server that is going to be always available, or at least you should try to do that. Next thing is to install OpenVPN on the server and configure it, this can be done in no time at all with the help of the following site:

https://github.com/Nyr/openvpn-install

The first command you are going to need to do is as follows:

wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh

This downloads and executes the installation script, I had to run this as sudo, so:

sudo wget https://git.io/vpn -O openvpn-install.sh && bash sudo openvpn-install.sh

This script will take you through a variety of questions where you are prompted for entry, in most cases the default option will be appropriate and filled - however if you are running behind a firewall (which you probably will be, I'd like to point out a couple of gotchas).

The IP address of the local machine should indeed be the local IP, there are other sites that suggest this should be the WAN IP of the server, that's fine if the server has direct access to the internet - which mine does not, since it is behind the firewall I choose the local IP so it configures the correct interface to be monitoring.

Next major question is configuring your external IP if you are behind a NAT, honestly you should be using a FQDN and not an IP - check out my previous post on dynu.com options [http://www.geekfreely.com/2015/10/configuring-ddclient-on-ubuntu-server.html]

Once you are finished answering the questions you are ready to make client profiles, run the installer again and you will be prompted a variety of options, you are going to want to add a user:

1) Add a new user
2) Revoke an existing user
3) Remove OpenVPN
4) Exit

Now that you have OpenVPN server installed in Ubuntu, and a client profile created for your device - all you have to do is setup any port forwarding required to the OpenVPN server.

So in my case I setup a rule to forward all 1178 (1194 if you followed the default options) UDP VPN requests from my external IP address to the local IP address of the server running OpenVPN. This was done at my cable modem/router.

That's it, you're done. Let me know if you have any questions or comments below - feel free to donate/tip the creator of the script on the following site:

https://github.com/Nyr/openvpn-install