#!/bin/bash

echo -e "Current hostname :\n $(cat /etc/hostname)\n"
read -p "Change configuration ? [y/n] : " QUESTION
if [ "$QUESTION" = "y" ] || [ "$QUESTION" = "Y" ]; then
	nano /etc/hostname || vim /etc/hostname
	echo -e "\nNew hostname configuration :\n $(cat /etc/hostname)"
fi

unset QUESTION
echo -e "Current ip/DNS :\n$(cat /etc/hosts)"
read -p "Change configuration ? [y/n] : " QUESTION
if [ "$QUESTION" = "y" ] || [ "$QUESTION" = "Y" ]; then
	nano /etc/hosts || vim /etc/hosts
	echo -e "\nNew ip/DNS configuration :\n $(cat /etc/hosts)"
fi

unset QUESTION
echo -e "Current network configuration :\n$(cat /etc/network/interfaces)"
read -p "Change configuration ? [y/n] : " QUESTION
if [ "$QUESTION" = "y" ] || [ "$QUESTION" = "Y" ]; then
	nano /etc/network/interfaces || vim /etc/network/interfaces
	echo -e "\nNew network configuration :\n $(cat /etc/network/interfaces)"
fi

unset QUESTION
echo -e "Names and addresses of your own network :\n$(cat /etc/networks)"
read -p "Change configuration ? [y/n] : " QUESTION
if [ "$QUESTION" = "y" ] || [ "$QUESTION" = "Y" ]; then
	nano /etc/networks || vim /etc/networks
	echo -e "\nNew names and addresses of your own network :\n $(cat /etc/networks)"
fi

unset QUESTION
cat /etc/shadow |grep "root:\$y\$j9T\$Rw2sdZhlOTINlzcwvigse1\$KK002qt60Ds.Aj54geoxwAhOjHtdzs2ykBgnwks.hOC:" &>/dev/null ; ROOTCHECK="$?"
if [ "$ROOTCHECK" = "0" ]; then
	echo -e "Detection of the default \"root\" password of the model.\nPlease change the password !"
	passwd root && echo "Password changed !" || echo "Password not changed !"
fi
