#!/bin/bash
echo -e "\n\n\n"
clear
echo -e "\n"
echo "---------------------------------------------------------------------------------------------------------------------"
echo -e "\033[33m Network-Reinstall-System-Modify Tools V3.1.0 2020/09/15 \033[0m"
echo -e "\033[33m [Magic Modify] Reinstall the system (any Windows / Linux) requires only network and one click \033[0m"
echo -e "\033[33m System requirements: Any Linux system with GRUB or GRUB2, recommended CentOS8/Debian10/Ubuntu20 \033[0m"
echo -e "\n"
echo -e "\033[33m [Original] One-click Network Reinstall System - Magic Modify version (For Linux/Windows) \033[0m"
echo "---------------------------------------------------------------------------------------------------------------------"
echo -e "\n"
sleep 6s

echo "---------------------------------------------------------------------------------------------------------------------"
echo " Pre-environment preparation. . ."
echo "---------------------------------------------------------------------------------------------------------------------"
echo -e "\n"
sleep 2s

if [ -f "/usr/bin/apt-get" ];then
	isDebian=`cat /etc/issue|grep Debian`
	if [ "$isDebian" != "" ];then
		echo 'Current system is Debian'
		apt-get install -y xz-utils openssl gawk file wget curl
		apt install -y xz-utils openssl gawk file wget curl
		sleep 3s
	else
		echo 'Current system is Ubuntu'
		apt-get install -y xz-utils openssl gawk file wget curl
		apt install -y xz-utils openssl gawk file wget curl
		sleep 3s
	fi
else
    echo 'Current system is CentOS'
    yum install -y xz openssl gawk file wget curl
    sleep 3s
fi

echo "---------------------------------------------------------------------------------------------------------------------"
echo " Pre-environment preparation. . .  【OK】"
echo -e "\n"
echo " Start system installation. . . "
echo "---------------------------------------------------------------------------------------------------------------------"
echo -e "\n"
sleep 2s


if [ $1 = '-CentOS_8' ]
then
	echo -e "\033[33m You have chosen to install the latest CentOS_8 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/centos/CentOS_8.X_NetInstallation.vhd.gz'
fi

if [ $1 = '-CentOS_7' ]
then
	echo -e "\033[33m You have chosen to install the latest CentOS_7 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/centos/CentOS_7.X_NetInstallation_Final.vhd.gz'
fi

if [ $1 = '-Debian_10' ]
then
	echo -e "\033[33m You have chosen to install the latest Debian_10 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -d 10 -v 64 -a -p 815494.com
fi

if [ $1 = '-Debian_11' ]
then
	echo -e "\033[33m You have chosen to install the latest Debian_11 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -d 11 -v 64 -a -p 815494.com
fi

if [ $1 = '-Debian_9' ]
then
	echo -e "\033[33m You have chosen to install the latest Debian_9 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -d 9 -v 64 -a -p 815494.com
fi

if [ $1 = '-Ubuntu_20.04' ]
then
	echo -e "\033[33m You have chosen to install the latest Ubuntu_20.04 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -u 20.04 -v 64 -a -p 815494.com
fi

if [ $1 = '-Ubuntu_18.04' ]
then
	echo -e "\033[33m You have chosen to install the latest Ubuntu_18.04 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -u 18.04 -v 64 -a -p 815494.com
fi

if [ $1 = '-Ubuntu_16.04' ]
then
	echo -e "\033[33m You have chosen to install the latest Ubuntu_16.04 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -u 16.04 -v 64 -a -p 815494.com
fi

if [ $1 = '-Windows_Server_2022' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_Server_2022 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/2022/winsrv2022-data-x64-cn.vhd.gz'
fi

if [ $1 = '-Windows_Server_2019' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_Server_2019 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/2019/Disk_Windows_Server_2019_DataCenter_CN.vhd.gz'
fi

if [ $1 = '-Windows_Server_2016' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_Server_2016 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/2016/winsrv2016-data-x64-cn.vhd.gz'
fi

if [ $1 = '-Windows_Server_2016_EFI' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_Server_2016 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/2016/winsrv2016-data-x64-cn-efi.vhd.gz'
fi

if [ $1 = '-Windows_Server_2012R2' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_Server_2012R2 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/2012/winsrv2012r2-data-x64-cn.vhd.gz'
fi

if [ $1 = '-Windows_Server_2012R2_LSJ' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_Server_2012R2 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/2012/WinSrv2012r2x64-Chinese.vhd.gz'
fi

if [ $1 = '-DD' ]
then
	echo -e "\033[33m You have chosen to install the DD package provided by you \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd $2
fi




if [ $1 = '-CentOS_6' ]
then
	echo -e "\033[33m You have chosen to install the latest CentOS_6 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -c 6.10 -v 64 -a -p 815494.com
fi

if [ $1 = '-Debian_8' ]
then
	echo -e "\033[33m You have chosen to install the latest Debian_8 \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -d 8 -v 64 -a -p 815494.com
fi

if [ $1 = '-Debian_7' ]
then
	echo -e "\033[33m You have chosen to install the latest Debian_7 \033[0m"
	echo -e "\033[41;30m !!! Installing the old system will lead to security risks !!! \033[0m"
	echo -e "\n"
	sleep 8s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -d 7 -v 64 -a -p 815494.com
fi

if [ $1 = '-Ubuntu_14.04' ]
then
	echo -e "\033[33m You have chosen to install the latest Ubuntu_14.04 \033[0m"
	echo -e "\033[41;30m !!! Installing the old system will lead to security risks !!! \033[0m"
	echo -e "\n"
	sleep 8s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -u 14.04 -v 64 -a -p 815494.com
fi

if [ $1 = '-Windows_10_Lite' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_10_Lite \033[0m"
	echo -e "\n"
	sleep 5s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/win10/Disk_Windows_10_x64_Lite_by_CXT.vhd.gz'
fi

if [ $1 = '-Windows_Server_2008R2' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_Server_2008R2 \033[0m"
	echo -e "\033[41;30m !!! Installing the old system will lead to security risks !!! \033[0m"
	echo -e "\n"
	sleep 8s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/2008/winsrv2008r2-data-sp1-x64-cn.vhd.gz'
fi

if [ $1 = '-Windows_Server_2008R2EFI' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_Server_2008R2 \033[0m"
	echo -e "\033[41;30m !!! Installing the old system will lead to security risks !!! \033[0m"
	echo -e "\n"
	sleep 8s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/2008/winsrv2008r2-data-sp1-x64-efi.vhd.gz'
fi

if [ $1 = '-Windows_7' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_7_Vienna \033[0m"
	echo -e "\033[41;30m !!! Installing the old system will lead to security risks !!! \033[0m"
	echo -e "\n"
	sleep 8s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/win7/win7-ent-sp1-x64-cn.vhd.gz'
fi

if [ $1 = '-Win7-EFI' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_7_Vienna \033[0m"
	echo -e "\033[41;30m !!! Installing the old system will lead to security risks !!! \033[0m"
	echo -e "\n"
	sleep 8s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/win7/win7-ent-sp1-x64-efi.vhd.gz'
fi

if [ $1 = '-Windows_Server_2003' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_Server_2003 \033[0m"
	echo -e "\033[41;30m !!! Installing the old system will lead to security risks !!! \033[0m"
	echo -e "\n"
	sleep 8s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/2003/Disk_Windows_Server_2003_DataCenter_CN.vhd.gz'
fi

if [ $1 = '-LSJ2003' ]
then
	echo -e "\033[33m You have chosen to install the latest Windows_Server_2003 \033[0m"
	echo -e "\033[41;30m !!! Installing the old system will lead to security risks !!! \033[0m"
	echo -e "\n"
	sleep 8s
	wget --no-check-certificate -qO InstallNET2022.sh 'https://www.815494.com/html/shell/reinstall/InstallNET2022.sh' && bash InstallNET2022.sh -dd 'http://d.p1e.cn/os/windows/2003/WinSrv2003x86-Chinese.vhd.gz'
fi


echo "---------------------------------------------------------------------------------------------------------------------"
echo -e "\033[35m Start Installation \033[0m"
echo -e "\033[32m Start Installation \033[0m"
echo "---------------------------------------------------------------------------------------------------------------------"
echo -e "\n"
exit