#!/bin/bash
# Networking project - N7 IR2020
# Deploy network architecture for the group 2
# Author: purerstamp
# Version: 2019-03-26
# Syntax: deploy.sh name
# Args:
## name = name of the equipement (SHOULD be R1, R2, R3 or RE)
# Examples:
## deploy.sh R1
# Warnings:
## You MUST to be root to run this script
logfile=/tmp/deploy.log
echo "Please all messages won't be displayed here. See $logfile"

# Configure your interfaces
config_IP()
{
	systemctl stop network-manager
	sysctl -w net.ipv4.ip_forward=1
	mv interfaces /etc/network/ 
	systemctl restart networking
}

# Configure the router R1
config_R1()
{
	echo "Running the configuration for R1"
	echo "Check for the following conf in $PWD :"
	echo -e "\tinterfaces"
	config_IP > $logfile 2>&1
}

# Configure the router R2
config_R2()
{
	echo "Running the configuration for R2"
	echo "Check for the following conf in $PWD :"
	echo -e "\tinterfaces"
	config_IP > $logfile 2>&1
}

# Configure the router R3
config_R3()
{
	echo "Running the configuration for R3"
	echo "Check for the following conf in $PWD :"
	echo -e "\tinterfaces"
	config_IP > $logfile 2>&1
}

# Configure the router RE
config_RE()
{
	echo "Running the configuration for RE"
	echo "Check for the following conf in $PWD :"
	echo -e "\tinterfaces"
	config_IP > $logfile 2>&1
}

case "$1" in
"R1")
	config_R1 
	;;
"R2")
	config_R2
	;;
"R3")
	config_R3
	;;
"RE")
	config_RE
	;;
*)
	echo "[FATAL] Wrong equipement name. RTFM."
	exit 1;;
esac
exit 0
