#!/bin/bash
#
# Ubuntu Linux Essentials Packages
# By Dimas Restu Hidayanto <dimas.restu@student.upi.edu>
#
# WARNING PLEASE DO WITH YOUR OWN RISK
#
# This instruction will guide you to install
# essentials packages that might be useful for your systems
# or your opeartions
#
# Please do the following command before applying
# ...
# sudo -i
# -- Or --
# su
# ...
#

# Install and Upgrade Base Packages
apt-get update
apt-get -y dist-upgrade
apt-get -y install bash bash-completion
apt-get -y install ca-certificates tzdata
apt-get -y install sudo sed grep byobu lsb-release
apt-get -y install curl wget rsync nano vim-tiny
apt-get -y install tar gzip bzip2 xz-utils p7zip-full zip unzip
apt-get -y install xfsprogs fdisk gdisk parted lvm2
apt-get -y install binutils util-linux logrotate
apt-get -y install dpkg dirmngr gnupg apt-transport-https software-properties-common
apt-get -y install htop iftop iotop sysstat nmon
apt-get -y install net-tools netcat socat dnsutils bridge-utils
apt-get -y install inetutils-traceroute inetutils-ping openssh-client
apt-get -y install open-vm-tools

# Install Development Tools Packages
apt-get -y install python2 python2-dev
apt-get -y install python3 python3-dev
apt-get -y install git git-flow

# Clean-up Packages
apt-get -y purge --autoremove
apt-get -y clean

# Install Python 2 PIP
wget -q -O - https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2 -
pip2 install --no-cache-dir --upgrade pip setuptools wheel

# Install Python 3 PIP
wget -q -O - https://bootstrap.pypa.io/get-pip.py | python3 -
pip3 install --no-cache-dir --upgrade pip setuptools wheel

# Enable Sysctl Tweaks
cat << EOF >> /etc/sysctl.conf
vm.max_map_count=262144
net.core.somaxconn=4096
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.core.netdev_max_backlog=2500

net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
net.ipv6.conf.eth0.disable_ipv6=1

net.ipv4.tcp_mem=116730 155640 233460
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 65536 16777216
net.ipv4.tcp_max_orphans=24576

net.ipv4.ip_no_pmtu_disc=0
net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.all.log_martians=1
net.ipv4.conf.all.accept_source_route=0
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.default.send_redirects=0
net.ipv4.icmp_echo_ignore_broadcasts=1
EOF

# Reload Sysctl
sysctl -p