#! /usr/bin/perl

#
# Author: Sebastian Enger, M.Sc.
# Date: 3/13/2016
# Website: www.OneTIPP.com
# Email: Sebastian.Enger@gmail.com
# Topic: Install Docker Environment on Ubuntu Server
# Based: https://docs.docker.com/v1.8/installation/ubuntulinux/
# Version: 1.0.0
#

use strict;

my $kernel 				= `uname -r`;
my ($id,undef) 			= split("-", $kernel);
my ($one,$two,$three) 	= split("-", $kernel);
if ($one > 3 && $two > 10 ){
	print "Linux Kernel requirements met -> Installation go on\n";
	sleep 3;
} else {
	print "Linux Kernel requirements not meet\n";
	exit;
}

# apt-get 
system("apt-get update");
system("apt-get upgrade");
#system("apt-get dist-upgrade");
system("apt-get -o Dpkg::Options::='--force-confold' --force-yes -fuy dist-upgrade");

system("apt-get install -y nasm build-essential python pip perl");

# follow those installation requirements on Docker documentation page
system("apt-get install -y linux-image-generic-lts-trusty");
system("apt-get install -y linux-headers-generic-lts-trusty");

system("apt-get install -y curl wget");

system("curl -sSL https://get.docker.com/gpg | sudo apt-key add -");
system("curl -sSL https://get.docker.com/ | sh");

system("docker run hello-world");

###
# Download an ubuntu image
### docker pull ubuntu

#To run an interactive shell in the Ubuntu image:
### docker run -i -t ubuntu /bin/bash      