https://wzfou.com/5-vps-chongzhuang/

AutoReinstall.sh

  1. chmod +x AutoReinstall.sh
  2. bash AutoReinstall.sh
  3. 大致需要10分钟
  4. 2) centos 7
  5. 初始密码 root/cxthhhhh.com
  6. 修改密码 passwd
  1. #!/bin/sh
  2. if [[ $EUID -ne 0 ]]; then
  3. clear
  4. echo "Error: This script must be run as root!" 1>&2
  5. exit 1
  6. fi
  7. function CopyRight() {
  8. clear
  9. echo "########################################################"
  10. echo "# #"
  11. echo "# Auto Reinstall Script #"
  12. echo "# #"
  13. echo "# Author: hiCasper & Minijer #"
  14. echo "# Last Modified: 2021-09-09 #"
  15. echo "# #"
  16. echo "# Supported by MoeClub & cxthhhhh #"
  17. echo "# #"
  18. echo "########################################################"
  19. echo -e "\n"
  20. }
  21. function isValidIp() {
  22. local ip=$1
  23. local ret=1
  24. if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
  25. ip=(${ip//\./ })
  26. [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
  27. ret=$?
  28. fi
  29. return $ret
  30. }
  31. function ipCheck() {
  32. isLegal=0
  33. for add in $MAINIP $GATEWAYIP $NETMASK; do
  34. isValidIp $add
  35. if [ $? -eq 1 ]; then
  36. isLegal=1
  37. fi
  38. done
  39. return $isLegal
  40. }
  41. function GetIp() {
  42. MAINIP=$(ip route get 1 | awk -F 'src ' '{print $2}' | awk '{print $1}')
  43. GATEWAYIP=$(ip route | grep default | awk '{print $3}')
  44. SUBNET=$(ip -o -f inet addr show | awk '/scope global/{sub(/[^.]+\//,"0/",$4);print $4}' | head -1 | awk -F '/' '{print $2}')
  45. value=$(( 0xffffffff ^ ((1 << (32 - $SUBNET)) - 1) ))
  46. NETMASK="$(( (value >> 24) & 0xff )).$(( (value >> 16) & 0xff )).$(( (value >> 8) & 0xff )).$(( value & 0xff ))"
  47. }
  48. function UpdateIp() {
  49. read -r -p "Your IP: " MAINIP
  50. read -r -p "Your Gateway: " GATEWAYIP
  51. read -r -p "Your Netmask: " NETMASK
  52. }
  53. function SetNetwork() {
  54. isAuto='0'
  55. if [[ -f '/etc/network/interfaces' ]];then
  56. [[ ! -z "$(sed -n '/iface.*inet static/p' /etc/network/interfaces)" ]] && isAuto='1'
  57. [[ -d /etc/network/interfaces.d ]] && {
  58. cfgNum="$(find /etc/network/interfaces.d -name '*.cfg' |wc -l)" || cfgNum='0'
  59. [[ "$cfgNum" -ne '0' ]] && {
  60. for netConfig in `ls -1 /etc/network/interfaces.d/*.cfg`
  61. do
  62. [[ ! -z "$(cat $netConfig | sed -n '/iface.*inet static/p')" ]] && isAuto='1'
  63. done
  64. }
  65. }
  66. fi
  67. if [[ -d '/etc/sysconfig/network-scripts' ]];then
  68. cfgNum="$(find /etc/network/interfaces.d -name '*.cfg' |wc -l)" || cfgNum='0'
  69. [[ "$cfgNum" -ne '0' ]] && {
  70. for netConfig in `ls -1 /etc/sysconfig/network-scripts/ifcfg-* | grep -v 'lo$' | grep -v ':[0-9]\{1,\}'`
  71. do
  72. [[ ! -z "$(cat $netConfig | sed -n '/BOOTPROTO.*[sS][tT][aA][tT][iI][cC]/p')" ]] && isAuto='1'
  73. done
  74. }
  75. fi
  76. }
  77. function NetMode() {
  78. CopyRight
  79. if [ "$isAuto" == '0' ]; then
  80. read -r -p "Using DHCP to configure network automatically? [Y/n]:" input
  81. case $input in
  82. [yY][eE][sS]|[yY]) NETSTR='' ;;
  83. [nN][oO]|[nN]) isAuto='1' ;;
  84. *) clear; echo "Canceled by user!"; exit 1;;
  85. esac
  86. fi
  87. if [ "$isAuto" == '1' ]; then
  88. GetIp
  89. ipCheck
  90. if [ $? -ne 0 ]; then
  91. echo -e "Error occurred when detecting ip. Please input manually.\n"
  92. UpdateIp
  93. else
  94. CopyRight
  95. echo "IP: $MAINIP"
  96. echo "Gateway: $GATEWAYIP"
  97. echo "Netmask: $NETMASK"
  98. echo -e "\n"
  99. read -r -p "Confirm? [Y/n]:" input
  100. case $input in
  101. [yY][eE][sS]|[yY]) ;;
  102. [nN][oO]|[nN])
  103. echo -e "\n"
  104. UpdateIp
  105. ipCheck
  106. [[ $? -ne 0 ]] && {
  107. clear
  108. echo -e "Input error!\n"
  109. exit 1
  110. }
  111. ;;
  112. *) clear; echo "Canceled by user!"; exit 1;;
  113. esac
  114. fi
  115. NETSTR="--ip-addr ${MAINIP} --ip-gate ${GATEWAYIP} --ip-mask ${NETMASK}"
  116. fi
  117. }
  118. function Start() {
  119. CopyRight
  120. isCN='0'
  121. geoip=$(wget --no-check-certificate -qO- https://api.ip.sb/geoip | grep "\"country_code\":\"CN\"")
  122. if [[ "$geoip" != "" ]];then
  123. isCN='1'
  124. fi
  125. if [ "$isAuto" == '0' ]; then
  126. echo "Using DHCP mode."
  127. else
  128. echo "IP: $MAINIP"
  129. echo "Gateway: $GATEWAYIP"
  130. echo "Netmask: $NETMASK"
  131. fi
  132. [[ "$isCN" == '1' ]] && echo "Using domestic mode."
  133. if [ -f "/tmp/Core_Install.sh" ]; then
  134. rm -f /tmp/Core_Install.sh
  135. fi
  136. if [[ "$isCN" == '1' ]]; then
  137. wget --no-check-certificate -qO /tmp/Core_Install.sh 'https://cdn.jsdelivr.net/gh/fcurrk/reinstall@master/Core_Install_v3.1.sh' && chmod a+x /tmp/Core_Install.sh
  138. else
  139. wget --no-check-certificate -qO /tmp/Core_Install.sh 'https://raw.githubusercontent.com/fcurrk/reinstall/master/Core_Install_v3.1.sh' && chmod a+x /tmp/Core_Install.sh
  140. fi
  141. CMIRROR=''
  142. CVMIRROR=''
  143. DMIRROR=''
  144. UMIRROR=''
  145. SYSMIRROR1='http://disk.29296819.xyz/92shidai.com/dd/os/veip007/CentOS-7.img.gz'
  146. SYSMIRROR2='http://disk.29296819.xyz/92shidai.com/dd/os/cxthhhhh/CentOS_7.X_NetInstallation_Final.vhd.gz'
  147. SYSMIRROR3='http://disk.29296819.xyz/92shidai.com/dd/os/cxthhhhh/CentOS_8.X_NetInstallation.vhd.gz'
  148. SYSMIRROR12='http://disk.29296819.xyz/92shidai.com/dd/os/cxthhhhh/new/Disk_Windows_Server_2019_DataCenter_CN_v5.1.vhd.gz'
  149. SYSMIRROR13='http://disk.29296819.xyz/92shidai.com/dd/os/cxthhhhh/new/Disk_Windows_Server_2016_DataCenter_CN_v4.12.vhd.gz'
  150. SYSMIRROR14='http://disk.29296819.xyz/92shidai.com/dd/os/cxthhhhh/new/Disk_Windows_Server_2012R2_DataCenter_CN_v4.29.vhd.gz'
  151. SYSMIRROR15='http://disk.29296819.xyz/92shidai.com/dd/os/laosiji/WinSrv2012r2x64/lite/winsrv2012r2-data-x64-cn.vhd.gz'
  152. SYSMIRROR16='http://disk.29296819.xyz/92shidai.com/dd/os/cxthhhhh/new/Disk_Windows_Server_2008R2_DataCenter_CN_v3.27.vhd.gz'
  153. SYSMIRROR17='http://disk.29296819.xyz/92shidai.com/dd/os/laosiji/WinSrv2008x64/lite/winsrv2008r2-data-sp1-x64-cn.vhd.gz'
  154. SYSMIRROR18='http://disk.29296819.xyz/92shidai.com/dd/os/cxthhhhh/new/Disk_Windows_Server_2003_DataCenter_CN_v7.1.vhd.gz'
  155. SYSMIRROR19='http://disk.29296819.xyz/92shidai.com/dd/os/laosiji/WinSrv2003/10G/WinSrv2003x86-Chinese-C10G.vhd.gz'
  156. SYSMIRROR20='http://disk.29296819.xyz/92shidai.com/dd/os/laosiji/Win10/Win10_x64.vhd.gz'
  157. SYSMIRROR21='http://disk.29296819.xyz/92shidai.com/dd/os/laosiji/Win7/Windows7x86-Chinese.vhd.gz'
  158. SYSMIRROR22='http://disk.29296819.xyz/92shidai.com/dd/os/laosiji/Win7/win7-ent-sp1-x64-cn.vhd.gz'
  159. SYSMIRROR23='http://disk.29296819.xyz/92shidai.com/dd/os/laosiji/Win7/win7-ent-sp1-x64-cn-efi.vhd.gz'
  160. SYSMIRROR24='http://disk.29296819.xyz/92shidai.com/dd/os/laosiji/WinSrv2008x64/lite/winsrv2008r2-data-sp1-x64-cn-efi.vhd.gz'
  161. SYSMIRROR25='http://disk.29296819.xyz/92shidai.com/dd/os/laosiji/WinSrv2012r2x64/lite/winsrv2012r2-data-x64-cn-efi.vhd.gz'
  162. if [[ "$isCN" == '1' ]];then
  163. sed -i 's#http://disk.29296819.xyz/92shidai.cn/dd/img/wget_udeb_amd64.tar.gz#https://raw.githubusercontent.com/fcurrk/reinstall/master/wget_udeb_amd64.tar.gz#' /tmp/Core_Install.sh
  164. CMIRROR="--mirror http://mirrors.aliyun.com/centos/"
  165. CVMIRROR="--mirror http://mirrors.tuna.tsinghua.edu.cn/centos-vault/"
  166. DMIRROR="--mirror http://mirrors.aliyun.com/debian/"
  167. UMIRROR="--mirror http://mirrors.aliyun.com/ubuntu/"
  168. SYSMIRROR1='http://disk.29296819.xyz/92shidai.cn/dd/os/veip007/CentOS-7.img.gz'
  169. SYSMIRROR2='http://disk.29296819.xyz/92shidai.cn/dd/os/cxthhhhh/CentOS_7.X_NetInstallation_Final.vhd.gz'
  170. SYSMIRROR3='http://disk.29296819.xyz/92shidai.cn/dd/os/cxthhhhh/CentOS_8.X_NetInstallation.vhd.gz'
  171. SYSMIRROR12='http://disk.29296819.xyz/92shidai.cn/dd/os/cxthhhhh/new/Disk_Windows_Server_2019_DataCenter_CN_v5.1.vhd.gz'
  172. SYSMIRROR13='http://disk.29296819.xyz/92shidai.cn/dd/os/cxthhhhh/new/Disk_Windows_Server_2016_DataCenter_CN_v4.12.vhd.gz'
  173. SYSMIRROR14='http://disk.29296819.xyz/92shidai.cn/dd/os/cxthhhhh/new/Disk_Windows_Server_2012R2_DataCenter_CN_v4.29.vhd.gz'
  174. SYSMIRROR15='http://disk.29296819.xyz/92shidai.cn/dd/os/laosiji/WinSrv2012r2x64/lite/winsrv2012r2-data-x64-cn.vhd.gz'
  175. SYSMIRROR16='http://disk.29296819.xyz/92shidai.cn/dd/os/cxthhhhh/new/Disk_Windows_Server_2008R2_DataCenter_CN_v3.27.vhd.gz'
  176. SYSMIRROR17='http://disk.29296819.xyz/92shidai.cn/dd/os/laosiji/WinSrv2008x64/lite/winsrv2008r2-data-sp1-x64-cn.vhd.gz'
  177. SYSMIRROR18='http://disk.29296819.xyz/92shidai.cn/dd/os/cxthhhhh/new/Disk_Windows_Server_2003_DataCenter_CN_v7.1.vhd.gz'
  178. SYSMIRROR19='http://disk.29296819.xyz/92shidai.cn/dd/os/laosiji/WinSrv2003/10G/WinSrv2003x86-Chinese-C10G.vhd.gz'
  179. SYSMIRROR20='http://disk.29296819.xyz/92shidai.cn/dd/os/laosiji/Win10/Win10_x64.vhd.gz'
  180. SYSMIRROR21='http://disk.29296819.xyz/92shidai.cn/dd/os/laosiji/Win7/Windows7x86-Chinese.vhd.gz'
  181. SYSMIRROR22='http://disk.29296819.xyz/92shidai.cn/dd/os/laosiji/Win7/win7-ent-sp1-x64-cn.vhd.gz'
  182. SYSMIRROR23='http://disk.29296819.xyz/92shidai.cn/dd/os/laosiji/Win7/win7-ent-sp1-x64-cn-efi.vhd.gz'
  183. SYSMIRROR24='http://disk.29296819.xyz/92shidai.cn/dd/os/laosiji/WinSrv2008x64/lite/winsrv2008r2-data-sp1-x64-cn-efi.vhd.gz'
  184. SYSMIRROR25='http://disk.29296819.xyz/92shidai.cn/dd/os/laosiji/WinSrv2012r2x64/lite/winsrv2012r2-data-x64-cn-efi.vhd.gz'
  185. fi
  186. echo -e "\nPlease select an OS:"
  187. echo " 1) CentOS 7.7 (ext4)"
  188. echo " 2) CentOS 7 (cxthhhh)"
  189. echo " 3) CentOS 8 (cxthhhh)"
  190. echo " 4) CentOS 6"
  191. echo " 5) Debian 11"
  192. echo " 6) Debian 10"
  193. echo " 7) Debian 9"
  194. echo " 8) Debian 8"
  195. echo " 9) Ubuntu 20.04"
  196. echo " 10) Ubuntu 18.04"
  197. echo " 11) Ubuntu 16.04"
  198. echo " 12) Windows Server 2019"
  199. echo " 13) Windows Server 2016"
  200. echo " 14) Windows Server 2012"
  201. echo " 15) Windows Server 2012 Lite"
  202. echo " 16) Windows Server 2008"
  203. echo " 17) Windows Server 2008 Lite"
  204. echo " 18) Windows Server 2003"
  205. echo " 19) Windows Server 2003 Lite"
  206. echo " 20) Windows 10 LTSC Lite"
  207. echo " 21) Windows 7 x86 Lite"
  208. echo " 22) Windows 7 Ent Lite"
  209. echo " 23) Windows 7 Ent Lite(UEFI)"
  210. echo " 24) Windows Server 2008 Lite(UEFI)"
  211. echo " 25) Windows Server 2012 Lite(UEFI)"
  212. echo " 99) Custom image"
  213. echo " 0) Exit"
  214. echo -ne "\nYour option: "
  215. read N
  216. case $N in
  217. 1) echo -e "\nPassword: Pwd@CentOS\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR1 $DMIRROR ;;
  218. 2) echo -e "\nPassword: cxthhhhh.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR2 $DMIRROR ;;
  219. 3) echo -e "\nPassword: cxthhhhh.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR3 $DMIRROR ;;
  220. 4) echo -e "\nPassword: Minijer.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh -c 6.10 -v 64 -a $NETSTR $CMIRROR ;;
  221. 5) echo -e "\nPassword: Minijer.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh -d 11 -v 64 -a $NETSTR $DMIRROR ;;
  222. 6) echo -e "\nPassword: Minijer.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh -d 10 -v 64 -a $NETSTR $DMIRROR ;;
  223. 7) echo -e "\nPassword: Minijer.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh -d 9 -v 64 -a $NETSTR $DMIRROR ;;
  224. 8) echo -e "\nPassword: Minijer.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh -d 8 -v 64 -a $NETSTR $DMIRROR ;;
  225. 9) echo -e "\nPassword: Minijer.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh -u 20.04 -v 64 -a $NETSTR $UMIRROR ;;
  226. 10) echo -e "\nPassword: Minijer.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh -u 18.04 -v 64 -a $NETSTR $UMIRROR ;;
  227. 11) echo -e "\nPassword: Minijer.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh -u 16.04 -v 64 -a $NETSTR $UMIRROR ;;
  228. 12) echo -e "\nPassword: cxthhhhh.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR12 $DMIRROR ;;
  229. 13) echo -e "\nPassword: cxthhhhh.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR13 $DMIRROR ;;
  230. 14) echo -e "\nPassword: cxthhhhh.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR14 $DMIRROR ;;
  231. 15) echo -e "\nPassword: nat.ee\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR15 $DMIRROR ;;
  232. 16) echo -e "\nPassword: cxthhhhh.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR16 $DMIRROR ;;
  233. 17) echo -e "\nPassword: nat.ee\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR17 $DMIRROR ;;
  234. 18) echo -e "\nPassword: cxthhhhh.com\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR18 $DMIRROR ;;
  235. 19) echo -e "\nPassword: WinSrv2003x86-Chinese\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR19 $DMIRROR ;;
  236. 20) echo -e "\nPassword: www.nat.ee\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR20 $DMIRROR ;;
  237. 21) echo -e "\nPassword: Windows7x86-Chinese\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR21 $DMIRROR ;;
  238. 22) echo -e "\nPassword: nat.ee\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR22 $DMIRROR ;;
  239. 23) echo -e "\nPassword: nat.ee\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR23 $DMIRROR ;;
  240. 24) echo -e "\nPassword: nat.ee\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR24 $DMIRROR ;;
  241. 25) echo -e "\nPassword: nat.ee\n"; read -s -n1 -p "Press any key to continue..." ; bash /tmp/Core_Install.sh $NETSTR -dd $SYSMIRROR25 $DMIRROR ;;
  242. 99)
  243. echo -e "\n"
  244. read -r -p "Custom image URL: " imgURL
  245. echo -e "\n"
  246. read -r -p "Are you sure start reinstall? [Y/n]: " input
  247. case $input in
  248. [yY][eE][sS]|[yY]) bash /tmp/Core_Install.sh $NETSTR -dd $imgURL $DMIRROR ;;
  249. *) clear; echo "Canceled by user!"; exit 1;;
  250. esac
  251. ;;
  252. 0) exit 0;;
  253. *) echo "Wrong input!"; exit 1;;
  254. esac
  255. }
  256. SetNetwork
  257. NetMode
  258. Start