{"id":93,"date":"2018-06-21T00:21:09","date_gmt":"2018-06-20T16:21:09","guid":{"rendered":"http:\/\/www.zhangyijun.com\/?p=93"},"modified":"2018-06-21T00:21:09","modified_gmt":"2018-06-20T16:21:09","slug":"ikoula-dd-win8-%e8%90%8c%e5%92%96","status":"publish","type":"post","link":"http:\/\/www.zhangyijun.com\/?p=93","title":{"rendered":"IKOULA DD win8 \u840c\u5496"},"content":{"rendered":"<pre class=\"lang:sh decode:true\">wget --no-check-certificate -qO InstallNET.sh 'https:\/\/moeclub.org\/attachment\/LinuxShell\/InstallNET.sh' &amp;&amp; bash InstallNET.sh -dd \"$(echo \"1cqVl2wSGx92UTdhOxU9pW3wJgmvZMT_J\" |xargs -n1 bash &lt;(wget --no-check-certificate -qO- 'https:\/\/moeclub.org\/get-gdlink'))\" -rdp 3389<\/pre>\n<p>&nbsp;<\/p>\n<p>20181017\u66f4\u65b0\u4e0b\u9762\u7684GOOGLE DRIVE\u94fe\u63a5<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">wget --no-check-certificate -qO InstallNET.sh 'https:\/\/moeclub.org\/attachment\/LinuxShell\/InstallNET.sh' &amp;&amp; bash InstallNET.sh -dd \"$(echo \"1cqVl2wSGx92UTdhOxU9pW3wJgmvZMT_J\" |xargs -n1 bash &lt;(wget --no-check-certificate -qO- 'https:\/\/moeclub.org\/get-gdlink'))\" -rdp 3389<\/code><\/pre>\n<p>DDwin2003\u6781\u9650\u7cbe\u7b80<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">wget --no-check-certificate -qO InstallNET.sh 'https:\/\/moeclub.org\/attachment\/LinuxShell\/InstallNET.sh' &amp;&amp; bash InstallNET.sh -dd \"$(echo \"1xizzlzzJDC8TZ70AzFWt5hZYWyCPoeTq\" |xargs -n1 bash &lt;(wget --no-check-certificate -qO- 'https:\/\/moeclub.org\/get-gdlink'))\" -rdp 3389<\/code><\/pre>\n<p>DDWIN2016\uff0c\u53c2\u8003\u7b2c\u4e8c\u6761\u4fee\u6539<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">wget --no-check-certificate -qO InstallNET.sh 'https:\/\/moeclub.org\/attachment\/LinuxShell\/InstallNET.sh' &amp;&amp; bash InstallNET.sh -dd \"$(echo \"18-lK9gB_9MkjvwOoRjv34beVWbP57VRX\" |xargs -n1 bash &lt;(wget --no-check-certificate -qO- 'https:\/\/moeclub.org\/get-gdlink'))\" -rdp 3389<\/code><\/pre>\n<pre class=\"pure-highlightjs\"><code class=\"\">wget --no-check-certificate -qO InstallNET.sh 'https:\/\/moeclub.org\/attachment\/LinuxShell\/InstallNET.sh' &amp;&amp; bash InstallNET.sh --ip-addr 178.128.30.167 --ip-mask 255.255.240.0 --ip-gate 178.128.16.1 -dd 'https:\/\/ytbcn.me\/iso\/en_windows2016.gz' -rdp 3389<\/code><\/pre>\n<p>\u53c2\u8003\u4e0a\u9762\u7684\u547d\u4ee4<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:sh decode:true \">#!\/bin\/bash\n\n## It can reinstall Debian, Ubuntu, CentOS system with network.\n## Suitable for using by GRUB.\n## Default root password: Vicer\n## Blog: https:\/\/moeclub.org\n## Written By Vicer\n\nexport tmpVER=''\nexport tmpDIST=''\nexport tmpURL=''\nexport tmpWORD=''\nexport tmpMirror=''\nexport tmpSSL=''\nexport tmpINS=''\nexport tmpFW=''\nexport ipAddr=''\nexport ipMask=''\nexport ipGate=''\nexport linuxdists=''\nexport ddMode='0'\nexport setNet='0'\nexport setRDP='0'\nexport isMirror='0'\nexport FindDists='0'\nexport SpikCheckDIST='0'\nexport UNKNOWHW='0'\nexport UNVER='6.4'\n\nwhile [[ $# -ge 1 ]]; do\n  case $1 in\n    -v|--ver)\n      shift\n      tmpVER=\"$1\"\n      shift\n      ;;\n    -d|--debian)\n      shift\n      linuxdists='debian'\n      tmpDIST=\"$1\"\n      shift\n      ;;\n    -u|--ubuntu)\n      shift\n      linuxdists='ubuntu'\n      tmpDIST=\"$1\"\n      shift\n      ;;\n    -c|--centos)\n      shift\n      linuxdists='centos'\n      tmpDIST=\"$1\"\n      shift\n      ;;\n    -dd|--image)\n      shift\n      ddMode='1'\n      tmpURL=\"$1\"\n      shift\n      ;;\n    -p|--password)\n      shift\n      tmpWORD=\"$1\"\n      shift\n      ;;\n    -i|--interface)\n      shift\n      interface=\"$1\"\n      shift\n      ;;\n    --ip-addr)\n      shift\n      ipAddr=\"$1\"\n      shift\n      ;;\n    --ip-mask)\n      shift\n      ipMask=\"$1\"\n      shift\n      ;;\n    --ip-gate)\n      shift\n      ipGate=\"$1\"\n      shift\n      ;;\n    -a|--auto)\n      shift\n      tmpINS='auto'\n      ;;\n    -m|--manual)\n      shift\n      tmpINS='manual'\n      ;;\n    -apt|-yum|--mirror)\n      shift\n      isMirror='1'\n      tmpMirror=\"$1\"\n      shift\n      ;;\n    -rdp)\n      shift\n      setRDP='1'\n      WinRemote=\"$1\"\n      shift\n      ;;\n    -ssl)\n      shift\n      tmpSSL=\"$1\"\n      shift\n      ;;\n    --firmware)\n      shift\n      tmpFW='1'\n      ;;\n    *)\n      if [[ \"$1\" != 'error' ]]; then echo -ne \"\\nInvaild option: '$1'\\n\\n\"; fi\n      echo -ne \" Usage:\\n\\tbash DebianNET.sh\\t-d\/--debian [\\033[33m\\033[04mdists-name\\033[0m]\\n\\t\\t\\t\\t-u\/--ubuntu [\\033[04mdists-name\\033[0m]\\n\\t\\t\\t\\t-c\/--centos [\\033[33m\\033[04mdists-verison\\033[0m]\\n\\t\\t\\t\\t-v\/--ver [32\/\\033[33m\\033[04mi386\\033[0m|64\/amd64]\\n\\t\\t\\t\\t--ip-addr\/--ip-gate\/--ip-mask\\n\\t\\t\\t\\t-apt\/-yum\/--mirror\\n\\t\\t\\t\\t-dd\/--image\\n\\t\\t\\t\\t-a\/--auto\\n\\t\\t\\t\\t-m\/--manual\\n\"\n      exit 1;\n      ;;\n    esac\n  done\n\n[[ \"$EUID\" -ne '0' ]] &amp;&amp; echo \"Error:This script must be run as root!\" &amp;&amp; exit 1;\n\nfunction CheckDependence(){\nFullDependence='0';\nfor BIN_DEP in `echo \"$1\" |sed 's\/,\/\\n\/g'`\n  do\n    if [[ -n \"$BIN_DEP\" ]]; then\n      Founded='0';\n      for BIN_PATH in `echo \"$PATH\" |sed 's\/:\/\\n\/g'`\n        do\n          ls $BIN_PATH\/$BIN_DEP &gt;\/dev\/null 2&gt;&amp;1;\n          if [ $? == '0' ]; then\n            Founded='1';\n            break;\n          fi\n        done\n      if [ \"$Founded\" == '1' ]; then\n        echo -en \"[\\033[32mok\\033[0m]\\t\";\n      else\n        FullDependence='1';\n        echo -en \"[\\033[31mNot Install\\033[0m]\";\n      fi\n      echo -en \"\\t$BIN_DEP\\n\";\n    fi\n  done\nif [ \"$FullDependence\" == '1' ]; then\n  echo -ne \"\\n\\033[31mError! \\033[0mPlease use '\\033[33mapt-get\\033[0m' or '\\033[33myum\\033[0m' install it.\\n\\n\\n\"\n  exit 1;\nfi\n}\n\nif [[ -z \"$linuxdists\" ]]; then\n  linuxdists='debian';\nfi\n\nclear &amp;&amp; echo -e \"\\n\\033[36m# Check Dependence\\033[0m\\n\"\n\nif [[ \"$ddMode\" == '1' ]]; then\n  CheckDependence iconv;\n  linuxdists='debian';\n  tmpDIST='jessie';\n  tmpVER='amd64';\n  tmpINS='auto';\nfi\n\nif [[ \"$linuxdists\" == 'debian' ]] || [[ \"$linuxdists\" == 'ubuntu' ]]; then\n  CheckDependence wget,awk,grep,sed,cut,cat,cpio,gzip,find,dirname,basename;\nelif [[ \"$linuxdists\" == 'centos' ]]; then\n  CheckDependence wget,awk,grep,sed,cut,cat,cpio,gzip,find,dirname,basename,file,xz;\nfi\n\nif [[ -n \"$tmpWORD\" ]]; then\n  CheckDependence openssl;\nfi\n\n[[ -f '\/boot\/grub\/grub.cfg' ]] &amp;&amp; GRUBOLD='0' &amp;&amp; GRUBDIR='\/boot\/grub' &amp;&amp; GRUBFILE='grub.cfg';\n[[ -z \"$GRUBDIR\" ]] &amp;&amp; [[ -f '\/boot\/grub2\/grub.cfg' ]] &amp;&amp; GRUBOLD='0' &amp;&amp; GRUBDIR='\/boot\/grub2' &amp;&amp; GRUBFILE='grub.cfg';\n[[ -z \"$GRUBDIR\" ]] &amp;&amp; [[ -f '\/boot\/grub\/grub.conf' ]] &amp;&amp; GRUBOLD='1' &amp;&amp; GRUBDIR='\/boot\/grub' &amp;&amp; GRUBFILE='grub.conf';\n[ -z \"$GRUBDIR\" -o -z \"$GRUBFILE\" ] &amp;&amp; echo -ne \"Error! \\nNot Found grub path.\\n\" &amp;&amp; exit 1;\n\nif [[ \"$isMirror\" == '1' ]]; then\n  if [[ -n \"$tmpMirror\" ]]; then\n    TMPMirrorHost=\"$(echo -n \"$tmpMirror\" |grep -Eo '.*\\.(\\w+)')\";\n    echo \"$TMPMirrorHost\" |grep -q ':\/\/';\n    if [[ $? == '0' ]]; then\n      MirrorHost=\"$(echo \"$TMPMirrorHost\" |awk -F':\/\/' '{print $2}')\";\n    else\n      echo -en \"\\n\\033[31mInvaild Mirror! \\033[0m\\n\";\n      [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; echo -en \"\\033[33mexample:\\033[0m http:\/\/deb.debian.org\/debian\\n\\n\";\n      [[ \"$linuxdists\" == 'ubuntu' ]] &amp;&amp; echo -en \"\\033[33mexample:\\033[0m http:\/\/archive.ubuntu.com\/ubuntu\\n\\n\";\n      [[ \"$linuxdists\" == 'centos' ]] &amp;&amp; echo -en \"\\033[33mexample:\\033[0m http:\/\/mirror.centos.org\/centos\\n\\n\";\n      exit 1\n    fi\n    if [[ -n \"$MirrorHost\" ]]; then\n      MirrorFolder=\"$(echo -n \"$tmpMirror\" |awk -F''${MirrorHost}'' '{print $2}' |sed 's\/\\\/$\/\/g')\";\n      if [[ -z \"$MirrorFolder\" ]]; then\n        [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; MirrorFolder='\/debian';\n        [[ \"$linuxdists\" == 'ubuntu' ]] &amp;&amp; MirrorFolder='\/ubuntu';\n        [[ \"$linuxdists\" == 'centos' ]] &amp;&amp; MirrorFolder='\/centos';\n      fi\n      DISTMirror=\"${MirrorHost}${MirrorFolder}\";\n    fi\n  fi\nfi\n\nif [[ -z \"$DISTMirror\" ]]; then\n  [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; MirrorHost='deb.debian.org' &amp;&amp; MirrorFolder='\/debian' &amp;&amp; DISTMirror=\"${MirrorHost}${MirrorFolder}\";\n  [[ \"$linuxdists\" == 'ubuntu' ]] &amp;&amp; MirrorHost='archive.ubuntu.com' &amp;&amp; MirrorFolder='\/ubuntu' &amp;&amp; DISTMirror=\"${MirrorHost}${MirrorFolder}\";\n  [[ \"$linuxdists\" == 'centos' ]] &amp;&amp; DISTMirror='vault.centos.org';\nfi\n\nif [[ -n \"$tmpVER\" ]]; then\n  tmpVER=\"$(echo \"$tmpVER\" |sed -r 's\/(.*)\/\\L\\1\/')\";\n  if  [[ \"$tmpVER\" == '32' ]] || [[ \"$tmpVER\" == 'i386' ]] || [[ \"$tmpVER\" == 'x86' ]]; then\n    VER='i386';\n  fi\n  if  [[ \"$tmpVER\" == '64' ]] || [[ \"$tmpVER\" == 'amd64' ]] || [[ \"$tmpVER\" == 'x86_64' ]] || [[ \"$tmpVER\" == 'x64' ]]; then\n    if [[ \"$linuxdists\" == 'debian' ]] || [[ \"$linuxdists\" == 'ubuntu' ]]; then\n      VER='amd64';\n    elif [[ \"$linuxdists\" == 'centos' ]]; then\n      VER='x86_64';\n    fi\n  fi\nfi\n\nif [[ -z \"$VER\" ]]; then\n  VER='i386';\nfi\n\nif [[ -z \"$tmpDIST\" ]]; then\n  [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; DIST='jessie';\n  [[ \"$linuxdists\" == 'ubuntu' ]] &amp;&amp; DIST='xenial';\n  [[ \"$linuxdists\" == 'centos' ]] &amp;&amp; DIST='6.8';\nfi\n\nif [[ -z \"$DIST\" ]]; then\n  if [[ \"$linuxdists\" == 'debian' ]]; then\n    SpikCheckDIST='0'\n    DIST=\"$(echo \"$tmpDIST\" |sed -r 's\/(.*)\/\\L\\1\/')\";\n    echo \"$DIST\" |grep -q '[0-9]';\n    [[ $? -eq '0' ]] &amp;&amp; {\n      isDigital=\"$(echo \"$DIST\" |grep -o '[\\.0-9]\\{1,\\}' |sed -n '1h;1!H;$g;s\/\\n\/\/g;$p' |cut -d'.' -f1)\";\n      [[ -n $isDigital ]] &amp;&amp; {\n        [[ \"$isDigital\" == '7' ]] &amp;&amp; DIST='wheezy';\n        [[ \"$isDigital\" == '8' ]] &amp;&amp; DIST='jessie';\n        [[ \"$isDigital\" == '9' ]] &amp;&amp; DIST='stretch';\n        [[ \"$isDigital\" == '10' ]] &amp;&amp; DIST='buster';\n      }\n    }\n  fi\n  if [[ \"$linuxdists\" == 'ubuntu' ]]; then\n    SpikCheckDIST='0'\n    DIST=\"$(echo \"$tmpDIST\" |sed -r 's\/(.*)\/\\L\\1\/')\";\n    echo \"$DIST\" |grep -q '[0-9]';\n    [[ $? -eq '0' ]] &amp;&amp; {\n      isDigital=\"$(echo \"$DIST\" |grep -o '[\\.0-9]\\{1,\\}' |sed -n '1h;1!H;$g;s\/\\n\/\/g;$p')\";\n      [[ -n $isDigital ]] &amp;&amp; {\n        [[ \"$isDigital\" == '12.04' ]] &amp;&amp; DIST='precise';\n        [[ \"$isDigital\" == '14.04' ]] &amp;&amp; DIST='trusty';\n        [[ \"$isDigital\" == '16.04' ]] &amp;&amp; DIST='xenial';\n        [[ \"$isDigital\" == '18.04' ]] &amp;&amp; DIST='bionic';\n      }\n    }\n  fi\n  if [[ \"$linuxdists\" == 'centos' ]]; then\n    SpikCheckDIST='1'\n    DISTCheck=\"$(echo \"$tmpDIST\" |grep -o '[\\.0-9]\\{1,\\}')\";\n    ListDIST=\"$(wget --no-check-certificate -qO- \"http:\/\/$DISTMirror\/dir_sizes\" |cut -f2 |grep '^[0-9]')\"\n    DIST=\"$(echo \"$ListDIST\" |grep \"^$DISTCheck\" |head -n1)\"\n    [[ -z \"$DIST\" ]] &amp;&amp; {\n      echo -ne '\\nThe dists version not found in this mirror, Please check it! \\n\\n'\n      bash $0 error;\n      exit 1;\n    }\n    wget --no-check-certificate -qO- \"http:\/\/$DISTMirror\/$DIST\/os\/$VER\/.treeinfo\" |grep -q 'general';\n    [[ $? != '0' ]] &amp;&amp; {\n      wget --no-check-certificate -qO- \"http:\/\/$DISTMirror\/centos\/$DIST\/os\/$VER\/.treeinfo\" |grep -q 'general';\n      [[ $? == '0' ]] &amp;&amp; {\n        DISTMirror=\"${DISTMirror}\/${linuxdists}\"\n      } || {\n        echo -ne \"\\nThe version not found in this mirror, Please change mirror try again! \\n\\n\";\n        exit 1;\n      }\n    }\n\n  fi\nfi\n\nif [[ \"$SpikCheckDIST\" == '0' ]]; then\n  DistsList=\"$(wget --no-check-certificate -qO- \"http:\/\/$DISTMirror\/dists\/\" |grep -o 'href=.*\/\"' |cut -d'\"' -f2 |sed '\/-\\|old\\|Debian\\|experimental\\|stable\\|test\\|sid\\|devel\/d' |grep '^[^\/]' |sed -n '1h;1!H;$g;s\/\\n\/\/g;s\/\\\/\/\\;\/g;$p')\";\n  for CheckDEB in `echo \"$DistsList\" |sed 's\/;\/\\n\/g'`\n    do\n      [[ \"$CheckDEB\" == \"$DIST\" ]] &amp;&amp; FindDists='1';\n      [[ \"$FindDists\" == '1' ]] &amp;&amp; break;\n    done\n  [[ \"$FindDists\" == '0' ]] &amp;&amp; {\n    echo -ne '\\nThe dists version not found, Please check it! \\n\\n'\n    bash $0 error;\n    exit 1;\n  }\nfi\n\n[[ \"$ddMode\" == '1' ]] &amp;&amp; {\n  export SSL_SUPPORT='https:\/\/moeclub.org\/get-wget_udeb_amd64';\n  if [[ -n \"$tmpURL\" ]]; then\n    DDURL=\"$tmpURL\"\n    echo \"$DDURL\" |grep -q '^http:\/\/\\|^ftp:\/\/\\|^https:\/\/';\n    [[ $? -ne '0' ]] &amp;&amp; echo 'Please input vaild URL,Only support http:\/\/, ftp:\/\/ and https:\/\/ !' &amp;&amp; exit 1;\n    [[ -n \"$tmpSSL\" ]] &amp;&amp; SSL_SUPPORT=\"$tmpSSL\";\n  else\n    echo 'Please input vaild image URL! ';\n    exit 1;\n  fi\n}\n\n[[ -n \"$tmpINS\" ]] &amp;&amp; {\n  [[ \"$tmpINS\" == 'auto' ]] &amp;&amp; inVNC='n';\n  [[ \"$tmpINS\" == 'manual' ]] &amp;&amp; inVNC='y';\n}\n\n[ -n \"$ipAddr\" ] &amp;&amp; [ -n \"$ipMask\" ] &amp;&amp; [ -n \"$ipGate\" ] &amp;&amp; setNet='1';\n[[ -n \"$tmpWORD\" ]] &amp;&amp; myPASSWORD=\"$(openssl passwd -1 \"$tmpWORD\")\";\n[[ -z \"$myPASSWORD\" ]] &amp;&amp; myPASSWORD='$1$0shYGfBd$8v189JOozDO1jPqPO645e1';\n[[ -n \"$tmpFW\" ]] &amp;&amp; INCFW=\"$tmpFW\";\n[[ -z \"$INCFW\" ]] &amp;&amp; INCFW='0';\n\nif [[ -n \"$interface\" ]]; then\n  IFETH=\"$interface\"\nelse\n  if [[ \"$linuxdists\" == 'centos' ]]; then\n    IFETH=\"link\"\n  else\n    IFETH=\"auto\"\n  fi\nfi\n\nclear &amp;&amp; echo -e \"\\n\\033[36m# Install\\033[0m\\n\"\n\nASKVNC(){\n  inVNC='y';\n  [[ \"$ddMode\" == '0' ]] &amp;&amp; {\n    echo -ne \"\\033[34mCan you login VNC?\\033[0m\\e[33m[\\e[32my\\e[33m\/n]\\e[0m \"\n    read tmpinVNC\n    [[ -n \"$inVNCtmp\" ]] &amp;&amp; inVNC=\"$tmpinVNC\"\n  }\n  [ \"$inVNC\" == 'y' -o \"$inVNC\" == 'Y' ] &amp;&amp; inVNC='y';\n  [ \"$inVNC\" == 'n' -o \"$inVNC\" == 'N' ] &amp;&amp; inVNC='n';\n}\n\n[ \"$inVNC\" == 'y' -o \"$inVNC\" == 'n' ] || ASKVNC;\n[[ \"$linuxdists\" == 'debian' ]] &amp;&amp; LinuxName='Debian';\n[[ \"$linuxdists\" == 'ubuntu' ]] &amp;&amp; LinuxName='Ubuntu';\n[[ \"$linuxdists\" == 'centos' ]] &amp;&amp; LinuxName='CentOS';\n[[ \"$ddMode\" == '0' ]] &amp;&amp; { \n  [[ \"$inVNC\" == 'y' ]] &amp;&amp; echo -e \"\\033[34mManual Mode\\033[0m insatll \\033[33m$LinuxName\\033[0m [\\033[33m$DIST\\033[0m] [\\033[33m$VER\\033[0m] in VNC. \"\n  [[ \"$inVNC\" == 'n' ]] &amp;&amp; echo -e \"\\033[34mAuto Mode\\033[0m insatll \\033[33m$LinuxName\\033[0m [\\033[33m$DIST\\033[0m] [\\033[33m$VER\\033[0m]. \"\n}\n[[ \"$ddMode\" == '1' ]] &amp;&amp; {\n  echo -ne \"\\033[34mAuto Mode\\033[0m insatll \\033[33mWindows\\033[0m\\n[\\033[33m$DDURL\\033[0m]\\n\"\n}\n\nif [[ \"$linuxdists\" == 'centos' ]]; then\n  if [[ \"$DIST\" != \"$UNVER\" ]]; then\n    awk 'BEGIN{print '${UNVER}'-'${DIST}'}' |grep -q '^-'\n    if [ $? != '0' ]; then\n      UNKNOWHW='1';\n      echo -en \"\\033[33mThe version lower then \\033[31m$UNVER\\033[33m may not support in auto mode! \\033[0m\\n\";\n      if [[ \"$inVNC\" == 'n' ]]; then\n        echo -en \"\\033[35mYou can connect VNC with \\033[32mPublic IP\\033[35m and port \\033[32m1\\033[35m\/\\033[32m5901\\033[35m in vnc viewer.\\033[0m\\n\"\n        read -n 1 -p \"Press Enter to continue...\" INP\n        [[ \"$INP\" != '' ]] &amp;&amp; echo -ne '\\b \\n\\n';\n      fi\n    fi\n    awk 'BEGIN{print '${UNVER}'-'${DIST}'+0.59}' |grep -q '^-'\n    if [ $? == '0' ]; then\n      echo -en \"\\n\\033[31mThe version higher then \\033[33m6.9 \\033[31mis not support in current! \\033[0m\\n\\n\"\n      exit 1;\n    fi\n  fi\nfi\n\necho -e \"\\n[\\033[33m$LinuxName\\033[0m] [\\033[33m$DIST\\033[0m] [\\033[33m$VER\\033[0m] Downloading...\"\n\n[[ -z \"$DISTMirror\" ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mInvaild mirror! \\n\" &amp;&amp; exit 1\n\nif [[ \"$linuxdists\" == 'debian' ]] || [[ \"$linuxdists\" == 'ubuntu' ]]; then\nwget --no-check-certificate -qO '\/boot\/initrd.img' \"http:\/\/$DISTMirror\/dists\/$DIST\/main\/installer-$VER\/current\/images\/netboot\/$linuxdists-installer\/$VER\/initrd.gz\"\n[[ $? -ne '0' ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mDownload 'initrd.img' for \\033[33m$linuxdists\\033[0m failed! \\n\" &amp;&amp; exit 1\nwget --no-check-certificate -qO '\/boot\/vmlinuz' \"http:\/\/$DISTMirror\/dists\/$DIST\/main\/installer-$VER\/current\/images\/netboot\/$linuxdists-installer\/$VER\/linux\"\n[[ $? -ne '0' ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mDownload 'vmlinuz' for \\033[33m$linuxdists\\033[0m failed! \\n\" &amp;&amp; exit 1\nelif [[ \"$linuxdists\" == 'centos' ]]; then\nwget --no-check-certificate -qO '\/boot\/initrd.img' \"http:\/\/$DISTMirror\/$DIST\/os\/$VER\/isolinux\/initrd.img\"\n[[ $? -ne '0' ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mDownload 'initrd.img' for \\033[33m$linuxdists\\033[0m failed! \\n\" &amp;&amp; exit 1\nwget --no-check-certificate -qO '\/boot\/vmlinuz' \"http:\/\/$DISTMirror\/$DIST\/os\/$VER\/isolinux\/vmlinuz\"\n[[ $? -ne '0' ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mDownload 'vmlinuz' for \\033[33m$linuxdists\\033[0m failed! \\n\" &amp;&amp; exit 1\nfi\nif [[ \"$linuxdists\" == 'debian' ]]; then\n  if [[ \"$INCFW\" == '1' ]]; then\n    wget --no-check-certificate -qO '\/boot\/firmware.cpio.gz' \"http:\/\/cdimage.debian.org\/cdimage\/unofficial\/non-free\/firmware\/$DIST\/current\/firmware.cpio.gz\"\n    [[ $? -ne '0' ]] &amp;&amp; echo -ne \"\\033[31mError! \\033[0mDownload 'firmware' for \\033[33m$linuxdists\\033[0m failed! \\n\" &amp;&amp; exit 1\n  fi\n  if [[ \"$ddMode\" == '1' ]]; then\n    vKernel_udeb=$(wget --no-check-certificate -qO- \"http:\/\/$DISTMirror\/dists\/$DIST\/main\/installer-$VER\/current\/images\/udeb.list\" |grep '^acpi-modules' |head -n1 |grep -o '[0-9]\\{1,2\\}.[0-9]\\{1,2\\}.[0-9]\\{1,2\\}-[0-9]\\{1,2\\}' |head -n1)\n    [[ -z \"vKernel_udeb\" ]] &amp;&amp; vKernel_udeb=\"3.16.0-4\"\n  fi\nfi\n\n[[ \"$setNet\" == '1' ]] &amp;&amp; {\n  IPv4=\"$ipAddr\";\n  MASK=\"$ipMask\";\n  GATE=\"$ipGate\";\n} || {\n  DEFAULTNET=\"$(ip route show |grep -o 'default via [0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.*' |head -n1 |sed 's\/proto.*\\|onlink.*\/\/g' |awk '{print $NF}')\";\n  [[ -n \"$DEFAULTNET\" ]] &amp;&amp; IPSUB=\"$(ip addr |grep ''${DEFAULTNET}'' |grep 'global' |grep 'brd' |head -n1 |grep -o '[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}\/[0-9]\\{1,2\\}')\";\n  IPv4=\"$(echo -n \"$IPSUB\" |cut -d'\/' -f1)\";\n  NETSUB=\"$(echo -n \"$IPSUB\" |grep -o '\/[0-9]\\{1,2\\}')\";\n  GATE=\"$(ip route show |grep -o 'default via [0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}' |head -n1 |grep -o '[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}')\";\n  [[ -n \"$NETSUB\" ]] &amp;&amp; MASK=\"$(echo -n '128.0.0.0\/1,192.0.0.0\/2,224.0.0.0\/3,240.0.0.0\/4,248.0.0.0\/5,252.0.0.0\/6,254.0.0.0\/7,255.0.0.0\/8,255.128.0.0\/9,255.192.0.0\/10,255.224.0.0\/11,255.240.0.0\/12,255.248.0.0\/13,255.252.0.0\/14,255.254.0.0\/15,255.255.0.0\/16,255.255.128.0\/17,255.255.192.0\/18,255.255.224.0\/19,255.255.240.0\/20,255.255.248.0\/21,255.255.252.0\/22,255.255.254.0\/23,255.255.255.0\/24,255.255.255.128\/25,255.255.255.192\/26,255.255.255.224\/27,255.255.255.240\/28,255.255.255.248\/29,255.255.255.252\/30,255.255.255.254\/31,255.255.255.255\/32' |grep -o '[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}'${NETSUB}'' |cut -d'\/' -f1)\";\n}\n\n[[ -n \"$GATE\" ]] &amp;&amp; [[ -n \"$MASK\" ]] &amp;&amp; [[ -n \"$IPv4\" ]] || {\necho \"Not found \\`ip command\\`, It will use \\`route command\\`.\"\nipNum() {\n  local IFS='.';\n  read ip1 ip2 ip3 ip4 &lt;&lt;&lt;\"$1\";\n  echo $((ip1*(1&lt;&lt;24)+ip2*(1&lt;&lt;16)+ip3*(1&lt;&lt;8)+ip4));\n}\n\nSelectMax(){\nii=0;\nfor IPITEM in `route -n |awk -v OUT=$1 '{print $OUT}' |grep '[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}'`\n  do\n    NumTMP=\"$(ipNum $IPITEM)\";\n    eval \"arrayNum[$ii]='$NumTMP,$IPITEM'\";\n    ii=$[$ii+1];\n  done\necho ${arrayNum[@]} |sed 's\/\\s\/\\n\/g' |sort -n -k 1 -t ',' |tail -n1 |cut -d',' -f2;\n}\n\n[[ -z $IPv4 ]] &amp;&amp; IPv4=\"$(ifconfig |grep 'Bcast' |head -n1 |grep -o '[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}.[0-9]\\{1,3\\}' |head -n1)\";\n[[ -z $GATE ]] &amp;&amp; GATE=\"$(SelectMax 2)\";\n[[ -z $MASK ]] &amp;&amp; MASK=\"$(SelectMax 3)\";\n\n[[ -n \"$GATE\" ]] &amp;&amp; [[ -n \"$MASK\" ]] &amp;&amp; [[ -n \"$IPv4\" ]] || {\n  echo \"Error! Not configure network. \";\n  exit 1;\n}\n}\n\n[[ \"$setNet\" != '1' ]] &amp;&amp; [[ -f '\/etc\/network\/interfaces' ]] &amp;&amp; {\n  [[ -z \"$(sed -n '\/iface.*inet static\/p' \/etc\/network\/interfaces)\" ]] &amp;&amp; AutoNet='1' || AutoNet='0';\n  [[ -d \/etc\/network\/interfaces.d ]] &amp;&amp; {\n    ICFGN=\"$(find \/etc\/network\/interfaces.d -name '*.cfg' |wc -l)\" || ICFGN='0';\n    [[ \"$ICFGN\" -ne '0' ]] &amp;&amp; {\n      for NetCFG in `ls -1 \/etc\/network\/interfaces.d\/*.cfg`\n        do \n          [[ -z \"$(cat $NetCFG | sed -n '\/iface.*inet static\/p')\" ]] &amp;&amp; AutoNet='1' || AutoNet='0';\n          [[ \"$AutoNet\" -eq '0' ]] &amp;&amp; break;\n        done\n    }\n  }\n}\n\n[[ \"$setNet\" != '1' ]] &amp;&amp; [[ -d '\/etc\/sysconfig\/network-scripts' ]] &amp;&amp; {\n  ICFGN=\"$(find \/etc\/sysconfig\/network-scripts -name 'ifcfg-*' |grep -v 'lo'|wc -l)\" || ICFGN='0';\n  [[ \"$ICFGN\" -ne '0' ]] &amp;&amp; {\n    for NetCFG in `ls -1 \/etc\/sysconfig\/network-scripts\/ifcfg-* |grep -v 'lo$' |grep -v ':[0-9]\\{1,\\}'`\n      do \n        [[ -n \"$(cat $NetCFG | sed -n '\/BOOTPROTO.*[dD][hH][cC][pP]\/p')\" ]] &amp;&amp; AutoNet='1' || {\n          AutoNet='0' &amp;&amp; . $NetCFG;\n          [[ -n $NETMASK ]] &amp;&amp; MASK=\"$NETMASK\";\n          [[ -n $GATEWAY ]] &amp;&amp; GATE=\"$GATEWAY\";\n        }\n        [[ \"$AutoNet\" -eq '0' ]] &amp;&amp; break;\n      done\n  }\n}\n\n[[ ! -f $GRUBDIR\/$GRUBFILE ]] &amp;&amp; echo \"Error! Not Found $GRUBFILE. \" &amp;&amp; exit 1;\n\n[[ ! -f $GRUBDIR\/$GRUBFILE.old ]] &amp;&amp; [[ -f $GRUBDIR\/$GRUBFILE.bak ]] &amp;&amp; mv -f $GRUBDIR\/$GRUBFILE.bak $GRUBDIR\/$GRUBFILE.old;\nmv -f $GRUBDIR\/$GRUBFILE $GRUBDIR\/$GRUBFILE.bak;\n[[ -f $GRUBDIR\/$GRUBFILE.old ]] &amp;&amp; cat $GRUBDIR\/$GRUBFILE.old &gt;$GRUBDIR\/$GRUBFILE || cat $GRUBDIR\/$GRUBFILE.bak &gt;$GRUBDIR\/$GRUBFILE;\n\n[[ \"$GRUBOLD\" == '0' ]] &amp;&amp; {\n  READGRUB='\/tmp\/grub.read'\n  cat $GRUBDIR\/$GRUBFILE |sed -n '1h;1!H;$g;s\/\\n\/%%%%%%%\/g;$p' |grep -om 1 'menuentry\\ [^{]*{[^}]*}%%%%%%%' |sed 's\/%%%%%%%\/\\n\/g' &gt;$READGRUB\n  LoadNum=\"$(cat $READGRUB |grep -c 'menuentry ')\"\n  if [[ \"$LoadNum\" -eq '1' ]]; then\n    cat $READGRUB |sed '\/^$\/d' &gt;\/tmp\/grub.new;\n  elif [[ \"$LoadNum\" -gt '1' ]]; then\n    CFG0=\"$(awk '\/menuentry \/{print NR}' $READGRUB|head -n 1)\";\n    CFG2=\"$(awk '\/menuentry \/{print NR}' $READGRUB|head -n 2 |tail -n 1)\";\n    CFG1=\"\";\n    for tmpCFG in `awk '\/}\/{print NR}' $READGRUB`\n      do\n        [ \"$tmpCFG\" -gt \"$CFG0\" -a \"$tmpCFG\" -lt \"$CFG2\" ] &amp;&amp; CFG1=\"$tmpCFG\";\n      done\n    [[ -z \"$CFG1\" ]] &amp;&amp; {\n      echo \"Error! read $GRUBFILE. \";\n      exit 1;\n    }\n\n    sed -n \"$CFG0,$CFG1\"p $READGRUB &gt;\/tmp\/grub.new;\n    [[ -f \/tmp\/grub.new ]] &amp;&amp; [[ \"$(grep -c '{' \/tmp\/grub.new)\" -eq \"$(grep -c '}' \/tmp\/grub.new)\" ]] || {\n      echo -ne \"\\033[31mError! \\033[0mNot configure $GRUBFILE. \\n\";\n      exit 1;\n    }\n  fi\n  [ ! -f \/tmp\/grub.new ] &amp;&amp; echo \"Error! $GRUBFILE. \" &amp;&amp; exit 1;\n  sed -i \"\/menuentry.*\/c\\menuentry\\ \\'Install OS \\[$DIST\\ $VER\\]\\'\\ --class debian\\ --class\\ gnu-linux\\ --class\\ gnu\\ --class\\ os\\ \\{\" \/tmp\/grub.new\n  sed -i \"\/echo.*Loading\/d\" \/tmp\/grub.new;\n  INSERTGRUB=\"$(awk '\/menuentry \/{print NR}' $GRUBDIR\/$GRUBFILE|head -n 1)\"\n}\n\n[[ \"$GRUBOLD\" == '1' ]] &amp;&amp; {\n  CFG0=\"$(awk '\/title[\\ ]|title[\\t]\/{print NR}' $GRUBDIR\/$GRUBFILE|head -n 1)\";\n  CFG1=\"$(awk '\/title[\\ ]|title[\\t]\/{print NR}' $GRUBDIR\/$GRUBFILE|head -n 2 |tail -n 1)\";\n  [[ -n $CFG0 ]] &amp;&amp; [ -z $CFG1 -o $CFG1 == $CFG0 ] &amp;&amp; sed -n \"$CFG0,$\"p $GRUBDIR\/$GRUBFILE &gt;\/tmp\/grub.new;\n  [[ -n $CFG0 ]] &amp;&amp; [ -z $CFG1 -o $CFG1 != $CFG0 ] &amp;&amp; sed -n \"$CFG0,$[$CFG1-1]\"p $GRUBDIR\/$GRUBFILE &gt;\/tmp\/grub.new;\n  [[ ! -f \/tmp\/grub.new ]] &amp;&amp; echo \"Error! configure append $GRUBFILE. \" &amp;&amp; exit 1;\n  sed -i \"\/title.*\/c\\title\\ \\'Install OS \\[$DIST\\ $VER\\]\\'\" \/tmp\/grub.new;\n  sed -i '\/^#\/d' \/tmp\/grub.new;\n  INSERTGRUB=\"$(awk '\/title[\\ ]|title[\\t]\/{print NR}' $GRUBDIR\/$GRUBFILE|head -n 1)\"\n}\n\n[[ -n \"$(grep 'linux.*\/\\|kernel.*\/' \/tmp\/grub.new |awk '{print $2}' |tail -n 1 |grep '^\/boot\/')\" ]] &amp;&amp; Type='InBoot' || Type='NoBoot';\n\nLinuxKernel=\"$(grep 'linux.*\/\\|kernel.*\/' \/tmp\/grub.new |awk '{print $1}' |head -n 1)\";\n[[ -z \"$LinuxKernel\" ]] &amp;&amp; echo \"Error! read grub config! \" &amp;&amp; exit 1;\nLinuxIMG=\"$(grep 'initrd.*\/' \/tmp\/grub.new |awk '{print $1}' |tail -n 1)\";\n[ -z \"$LinuxIMG\" ] &amp;&amp; sed -i \"\/$LinuxKernel.*\\\/\/a\\\\\\tinitrd\\ \\\/\" \/tmp\/grub.new &amp;&amp; LinuxIMG='initrd';\n\nif [[ \"$linuxdists\" == 'debian' ]] || [[ \"$linuxdists\" == 'ubuntu' ]]; then\n  BOOT_OPTION=\"auto=true hostname=$linuxdists domain= -- quiet\"\nelif [[ \"$linuxdists\" == 'centos' ]]; then\n  BOOT_OPTION=\"ks=file:\/\/ks.cfg ksdevice=$IFETH\"\nfi\n\n[[ \"$Type\" == 'InBoot' ]] &amp;&amp; {\n  sed -i \"\/$LinuxKernel.*\\\/\/c\\\\\\t$LinuxKernel\\\\t\\\/boot\\\/vmlinuz $BOOT_OPTION\" \/tmp\/grub.new;\n  sed -i \"\/$LinuxIMG.*\\\/\/c\\\\\\t$LinuxIMG\\\\t\\\/boot\\\/initrd.img\" \/tmp\/grub.new;\n}\n\n[[ \"$Type\" == 'NoBoot' ]] &amp;&amp; {\n  sed -i \"\/$LinuxKernel.*\\\/\/c\\\\\\t$LinuxKernel\\\\t\\\/vmlinuz $BOOT_OPTION\" \/tmp\/grub.new;\n  sed -i \"\/$LinuxIMG.*\\\/\/c\\\\\\t$LinuxIMG\\\\t\\\/initrd.img\" \/tmp\/grub.new;\n}\n\nsed -i '$a\\\\n' \/tmp\/grub.new;\n\n[[ \"$inVNC\" == 'n' ]] &amp;&amp; {\nGRUBPATCH='0';\n\n[ -f '\/etc\/network\/interfaces' -o -d '\/etc\/sysconfig\/network-scripts' ] || {\n  echo \"Error, Not found interfaces config.\";\n  exit 1;\n}\n\nsed -i ''${INSERTGRUB}'i\\\\n' $GRUBDIR\/$GRUBFILE;\nsed -i ''${INSERTGRUB}'r \/tmp\/grub.new' $GRUBDIR\/$GRUBFILE;\n[[ -f  $GRUBDIR\/grubenv ]] &amp;&amp; sed -i 's\/saved_entry\/#saved_entry\/g' $GRUBDIR\/grubenv;\n\n[[ -d \/tmp\/boot ]] &amp;&amp; rm -rf \/tmp\/boot;\nmkdir -p \/tmp\/boot;\ncd \/tmp\/boot;\nif [[ \"$linuxdists\" == 'debian' ]] || [[ \"$linuxdists\" == 'ubuntu' ]]; then\n  COMPTYPE=\"gzip\";\nelif [[ \"$linuxdists\" == 'centos' ]]; then\n  COMPTYPE=\"$(file \/boot\/initrd.img |grep -o ':.*compressed data' |cut -d' ' -f2 |sed -r 's\/(.*)\/\\L\\1\/' |head -n1)\"\n  [[ -z \"$COMPTYPE\" ]] &amp;&amp; echo \"Detect compressed type fail.\" &amp;&amp; exit 1;\nfi\nCompDected='0'\nfor ListCOMP in `echo -en 'gzip\\nlzma\\nxz'`\n  do\n    if [[ \"$COMPTYPE\" == \"$ListCOMP\" ]]; then\n      CompDected='1'\n      if [[ \"$COMPTYPE\" == 'gzip' ]]; then\n        NewIMG=\"initrd.img.gz\"\n      else\n        NewIMG=\"initrd.img.$COMPTYPE\"\n      fi\n      mv -f \"\/boot\/initrd.img\" \"\/tmp\/$NewIMG\"\n      break;\n    fi\n  done\n[[ \"$CompDected\" != '1' ]] &amp;&amp; echo \"Detect compressed type not support.\" &amp;&amp; exit 1;\n[[ \"$COMPTYPE\" == 'lzma' ]] &amp;&amp; UNCOMP='xz --format=lzma --decompress';\n[[ \"$COMPTYPE\" == 'xz' ]] &amp;&amp; UNCOMP='xz --decompress';\n[[ \"$COMPTYPE\" == 'gzip' ]] &amp;&amp; UNCOMP='gzip -d';\n\n$UNCOMP &lt; \/tmp\/$NewIMG | cpio --extract --verbose --make-directories --no-absolute-filenames &gt;&gt;\/dev\/null 2&gt;&amp;1\n\nif [[ \"$linuxdists\" == 'debian' ]] || [[ \"$linuxdists\" == 'ubuntu' ]]; then\ncat &gt;\/tmp\/boot\/preseed.cfg&lt;&lt;EOF\nd-i debian-installer\/locale string en_US\nd-i console-setup\/layoutcode string us\n\nd-i keyboard-configuration\/xkb-keymap string us\n\nd-i netcfg\/choose_interface select $IFETH\n\nd-i netcfg\/disable_autoconfig boolean true\nd-i netcfg\/dhcp_failed note\nd-i netcfg\/dhcp_options select Configure network manually\nd-i netcfg\/get_ipaddress string $IPv4\nd-i netcfg\/get_netmask string $MASK\nd-i netcfg\/get_gateway string $GATE\nd-i netcfg\/get_nameservers string 8.8.8.8\nd-i netcfg\/no_default_route boolean true\nd-i netcfg\/confirm_static boolean true\n\nd-i hw-detect\/load_firmware boolean true\n\nd-i mirror\/country string manual\nd-i mirror\/http\/hostname string $MirrorHost\nd-i mirror\/http\/directory string $MirrorFolder\nd-i mirror\/http\/proxy string\n\nd-i passwd\/root-login boolean ture\nd-i passwd\/make-user boolean false\nd-i passwd\/root-password-crypted password $myPASSWORD\nd-i user-setup\/allow-password-weak boolean true\nd-i user-setup\/encrypt-home boolean false\n\nd-i clock-setup\/utc boolean true\nd-i time\/zone string US\/Eastern\nd-i clock-setup\/ntp boolean true\n\nd-i preseed\/early_command string anna-install libfuse2-udeb fuse-udeb ntfs-3g-udeb fuse-modules-${vKernel_udeb}-amd64-di\nd-i partman\/early_command string \\\ndebconf-set partman-auto\/disk \"\\$(list-devices disk |head -n1)\"; \\\nwget -qO- '$DDURL' |gunzip -dc |\/bin\/dd of=\\$(list-devices disk |head -n1); \\\nmount.ntfs-3g \\$(list-devices partition |head -n1) \/mnt; \\\ncd '\/mnt\/ProgramData\/Microsoft\/Windows\/Start Menu\/Programs'; \\\ncd Start* || cd start*; \\\ncp -f '\/net.bat' '.\/net.bat'; \\\n\/sbin\/reboot; \\\ndebconf-set grub-installer\/bootdev string \"\\$(list-devices disk |head -n1)\"; \\\numount \/media || true; \\\n\nd-i partman\/mount_style select uuid\nd-i partman-auto\/init_automatically_partition select Guided - use entire disk\nd-i partman-auto\/method string regular\nd-i partman-lvm\/device_remove_lvm boolean true\nd-i partman-md\/device_remove_md boolean true\nd-i partman-auto\/choose_recipe select atomic\nd-i partman-partitioning\/confirm_write_new_label boolean true\nd-i partman\/choose_partition select finish\nd-i partman-lvm\/confirm boolean true\nd-i partman-lvm\/confirm_nooverwrite boolean true\nd-i partman\/confirm boolean true\nd-i partman\/confirm_nooverwrite boolean true\n\nd-i debian-installer\/allow_unauthenticated boolean true\n\ntasksel tasksel\/first multiselect minimal\nd-i pkgsel\/update-policy select none\nd-i pkgsel\/include string openssh-server\nd-i pkgsel\/upgrade select none\n\npopularity-contest popularity-contest\/participate boolean false\n\nd-i grub-installer\/only_debian boolean true\nd-i grub-installer\/bootdev string default\nd-i finish-install\/reboot_in_progress note\nd-i debian-installer\/exit\/reboot boolean true\nd-i preseed\/late_command string\t\\\nsed -ri 's\/^#?PermitRootLogin.*\/PermitRootLogin yes\/g' \/target\/etc\/ssh\/sshd_config; \\\nsed -ri 's\/^#?PasswordAuthentication.*\/PasswordAuthentication yes\/g' \/target\/etc\/ssh\/sshd_config;\nEOF\n\n[[ \"$setNet\" == '0' ]] &amp;&amp; [[ \"$AutoNet\" == '1' ]] &amp;&amp; {\n  sed -i '\/netcfg\\\/disable_autoconfig\/d' \/tmp\/boot\/preseed.cfg\n  sed -i '\/netcfg\\\/dhcp_options\/d' \/tmp\/boot\/preseed.cfg\n  sed -i '\/netcfg\\\/get_.*\/d' \/tmp\/boot\/preseed.cfg\n  sed -i '\/netcfg\\\/confirm_static\/d' \/tmp\/boot\/preseed.cfg\n}\n\n[[ \"$DIST\" == 'trusty' ]] &amp;&amp; GRUBPATCH='1'\n[[ \"$DIST\" == 'wily' ]] &amp;&amp; GRUBPATCH='1'\n\n[[ \"$GRUBPATCH\" == '1' ]] &amp;&amp; {\n  sed -i 's\/^d-i\\ grub-installer\\\/bootdev\\ string\\ default\/\/g' \/tmp\/boot\/preseed.cfg\n}\n[[ \"$GRUBPATCH\" == '0' ]] &amp;&amp; {\n  sed -i 's\/debconf-set\\ grub-installer\\\/bootdev.*\\\"\\;\/\/g' \/tmp\/boot\/preseed.cfg\n}\n[[ \"$DIST\" == 'xenial' ]] &amp;&amp; {\n  sed -i 's\/^d-i\\ clock-setup\\\/ntp\\ boolean\\ true\/d-i\\ clock-setup\\\/ntp\\ boolean\\ false\/g' \/tmp\/boot\/preseed.cfg\n}\n\n[[ \"$linuxdists\" == 'debian' ]] &amp;&amp; {\n  sed -i '\/user-setup\\\/allow-password-weak\/d' \/tmp\/boot\/preseed.cfg\n  sed -i '\/user-setup\\\/encrypt-home\/d' \/tmp\/boot\/preseed.cfg\n  sed -i '\/pkgsel\\\/update-policy\/d' \/tmp\/boot\/preseed.cfg\n  sed -i 's\/umount\\ \\\/media.*true\\;\\ \/\/g' \/tmp\/boot\/preseed.cfg\n}\n[[ \"$INCFW\" == '1' ]] &amp;&amp; [[ \"$linuxdists\" == 'debian' ]] &amp;&amp; [[ -f '\/boot\/firmware.cpio.gz' ]] &amp;&amp; {\n  gzip -d &lt; \/boot\/firmware.cpio.gz | cpio --extract --verbose --make-directories --no-absolute-filenames &gt;&gt;\/dev\/null 2&gt;&amp;1\n}\n\n[[ \"$ddMode\" == '1' ]] &amp;&amp; {\nWinNoDHCP(){\n  echo -ne \"for\\0040\\0057f\\0040\\0042tokens\\00753\\0052\\0042\\0040\\0045\\0045i\\0040in\\0040\\0050\\0047netsh\\0040interface\\0040show\\0040interface\\0040\\0136\\0174more\\0040\\00533\\0040\\0136\\0174findstr\\0040\\0057I\\0040\\0057R\\0040\\0042\u672c\u5730\\0056\\0052\\0040\u4ee5\u592a\\0056\\0052\\0040Local\\0056\\0052\\0040Ethernet\\0042\\0047\\0051\\0040do\\0040\\0050set\\0040EthName\\0075\\0045\\0045j\\0051\\r\\nnetsh\\0040\\0055c\\0040interface\\0040ip\\0040set\\0040address\\0040name\\0075\\0042\\0045EthName\\0045\\0042\\0040source\\0075static\\0040address\\0075$IPv4\\0040mask\\0075$MASK\\0040gateway\\0075$GATE\\r\\nnetsh\\0040\\0055c\\0040interface\\0040ip\\0040add\\0040dnsservers\\0040name\\0075\\0042\\0045EthName\\0045\\0042\\0040address\\00758\\00568\\00568\\00568\\0040index\\00751\\0040validate\\0075no\\r\\n\\r\\n\" &gt;&gt;'\/tmp\/boot\/net.tmp';\n}\nWinRDP(){\n  echo -ne \"netsh\\0040firewall\\0040set\\0040portopening\\0040protocol\\0075ALL\\0040port\\0075$WinRemote\\0040name\\0075RDP\\0040mode\\0075ENABLE\\0040scope\\0075ALL\\0040profile\\0075ALL\\r\\nnetsh\\0040firewall\\0040set\\0040portopening\\0040protocol\\0075ALL\\0040port\\0075$WinRemote\\0040name\\0075RDP\\0040mode\\0075ENABLE\\0040scope\\0075ALL\\0040profile\\0075CURRENT\\r\\nreg\\0040add\\0040\\0042HKLM\\0134SYSTEM\\0134CurrentControlSet\\0134Control\\0134Network\\0134NewNetworkWindowOff\\0042\\0040\\0057f\\r\\nreg\\0040add\\0040\\0042HKLM\\0134SYSTEM\\0134CurrentControlSet\\0134Control\\0134Terminal\\0040Server\\0042\\0040\\0057v\\0040fDenyTSConnections\\0040\\0057t\\0040reg\\0137dword\\0040\\0057d\\00400\\0040\\0057f\\r\\nreg\\0040add\\0040\\0042HKLM\\0134SYSTEM\\0134CurrentControlSet\\0134Control\\0134Terminal\\0040Server\\0134Wds\\0134rdpwd\\0134Tds\\0134tcp\\0042\\0040\\0057v\\0040PortNumber\\0040\\0057t\\0040reg\\0137dword\\0040\\0057d\\0040$WinRemote\\0040\\0057f\\r\\nreg\\0040add\\0040\\0042HKLM\\0134SYSTEM\\0134CurrentControlSet\\0134Control\\0134Terminal\\0040Server\\0134WinStations\\0134RDP\\0055Tcp\\0042\\0040\\0057v\\0040PortNumber\\0040\\0057t\\0040reg\\0137dword\\0040\\0057d\\0040$WinRemote\\0040\\0057f\\r\\nreg\\0040add\\0040\\0042HKLM\\0134SYSTEM\\0134CurrentControlSet\\0134Control\\0134Terminal\\0040Server\\0134WinStations\\0134RDP\\0055Tcp\\0042\\0040\\0057v\\0040UserAuthentication\\0040\\0057t\\0040reg\\0137dword\\0040\\0057d\\00400\\0040\\0057f\\r\\nFOR\\0040\\0057F\\0040\\0042tokens\\00752\\0040delims\\0075\\0072\\0042\\0040\\0045\\0045i\\0040in\\0040\\0050\\0047SC\\0040QUERYEX\\0040TermService\\0040\\0136\\0174FINDSTR\\0040\\0057I\\0040\\0042PID\\0042\\0047\\0051\\0040do\\0040TASKKILL\\0040\\0057F\\0040\\0057PID\\0040\\0045\\0045i\\r\\nFOR\\0040\\0057F\\0040\\0042tokens\\00752\\0040delims\\0075\\0072\\0042\\0040\\0045\\0045i\\0040in\\0040\\0050\\0047SC\\0040QUERYEX\\0040UmRdpService\\0040\\0136\\0174FINDSTR\\0040\\0057I\\0040\\0042PID\\0042\\0047\\0051\\0040do\\0040TASKKILL\\0040\\0057F\\0040\\0057PID\\0040\\0045\\0045i\\r\\nSC\\0040START\\0040TermService\\r\\n\\r\\n\" &gt;&gt;'\/tmp\/boot\/net.tmp';\n}\n  echo -ne \"\\0100ECHO\\0040OFF\\r\\n\\r\\ncd\\0056\\0076\\0045WINDIR\\0045\\0134GetAdmin\\r\\nif\\0040exist\\0040\\0045WINDIR\\0045\\0134GetAdmin\\0040\\0050del\\0040\\0057f\\0040\\0057q\\0040\\0042\\0045WINDIR\\0045\\0134GetAdmin\\0042\\0051\\0040else\\0040\\0050\\r\\necho\\0040CreateObject\\0136\\0050\\0042Shell\\0056Application\\0042\\0136\\0051\\0056ShellExecute\\0040\\0042\\0045\\0176s0\\0042\\0054\\0040\\0042\\0045\\0052\\0042\\0054\\0040\\0042\\0042\\0054\\0040\\0042runas\\0042\\0054\\00401\\0040\\0076\\0076\\0040\\0042\\0045temp\\0045\\0134Admin\\0056vbs\\0042\\r\\n\\0042\\0045temp\\0045\\0134Admin\\0056vbs\\0042\\r\\ndel\\0040\\0057f\\0040\\0057q\\0040\\0042\\0045temp\\0045\\0134Admin\\0056vbs\\0042\\r\\nexit\\0040\\0057b\\00402\\0051\\r\\n\\r\\n\" &gt;'\/tmp\/boot\/net.tmp';\n  [[ \"$setNet\" == '1' ]] &amp;&amp; WinNoDHCP;\n  [[ \"$setNet\" == '0' ]] &amp;&amp; [[ \"$AutoNet\" == '0' ]] &amp;&amp; WinNoDHCP;\n  [[ \"$setRDP\" == '1' ]] &amp;&amp; [[ -n \"$WinRemote\" ]] &amp;&amp; WinRDP\n  echo -ne \"ECHO\\0040SELECT\\0040VOLUME\\0075\\0045\\0045SystemDrive\\0045\\0045\\0040\\0076\\0040\\0042\\0045SystemDrive\\0045\\0134diskpart\\0056extend\\0042\\r\\nECHO\\0040EXTEND\\0040\\0076\\0076\\0040\\0042\\0045SystemDrive\\0045\\0134diskpart\\0056extend\\0042\\r\\nSTART\\0040\/WAIT\\0040DISKPART\\0040\\0057S\\0040\\0042\\0045SystemDrive\\0045\\0134diskpart\\0056extend\\0042\\r\\nDEL\\0040\\0057f\\0040\\0057q\\0040\\0042\\0045SystemDrive\\0045\\0134diskpart\\0056extend\\0042\\r\\n\\r\\n\" &gt;&gt;'\/tmp\/boot\/net.tmp';\n  echo -ne \"cd\\0040\\0057d\\0040\\0042\\0045ProgramData\\0045\\0057Microsoft\\0057Windows\\0057Start\\0040Menu\\0057Programs\\0057Startup\\0042\\r\\ndel\\0040\\0057f\\0040\\0057q\\0040net\\0056bat\\r\\n\\r\\n\\r\\n\" &gt;&gt;'\/tmp\/boot\/net.tmp';\n  iconv -f 'UTF-8' -t 'GBK' '\/tmp\/boot\/net.tmp' -o '\/tmp\/boot\/net.bat'\n  rm -rf '\/tmp\/boot\/net.tmp'\n  echo \"$DDURL\" |grep -q '^https:\/\/'\n  [[ $? -eq '0' ]] &amp;&amp; {\n    echo -ne '\\nAdd ssl support...\\n'\n    [[ -n $SSL_SUPPORT ]] &amp;&amp; {\n      wget --no-check-certificate -qO- \"$SSL_SUPPORT\" |tar -x\n      [[ ! -f  \/tmp\/boot\/usr\/bin\/wget ]] &amp;&amp; echo 'Error! SSL_SUPPORT.' &amp;&amp; exit 1;\n      sed -i 's\/wget\\ -qO-\/\\\/usr\\\/bin\\\/wget\\ --no-check-certificate\\ --retry-connrefused\\ --tries=7\\ --continue\\ -qO-\/g' \/tmp\/boot\/preseed.cfg\n      [[ $? -eq '0' ]] &amp;&amp; echo -ne 'Success! \\n\\n'\n    } || {\n    echo -ne 'Not ssl support package! \\n\\n';\n    exit 1;\n    }\n  }\n}\n\n[[ \"$ddMode\" == '0' ]] &amp;&amp; {\n  sed -i '\/anna-install\/d' \/tmp\/boot\/preseed.cfg\n  sed -i 's\/wget.*\\\/sbin\\\/reboot\\;\\ \/\/g' \/tmp\/boot\/preseed.cfg\n}\n\nelif [[ \"$linuxdists\" == 'centos' ]]; then\ncat &gt;\/tmp\/boot\/ks.cfg&lt;&lt;EOF\n#platform=x86, AMD64, or Intel EM64T\nfirewall --enabled --ssh\ninstall\nurl --url=\"http:\/\/$DISTMirror\/$DIST\/os\/$VER\/\"\nrootpw --iscrypted $myPASSWORD\nauth --useshadow --passalgo=sha512\nfirstboot --disable\nlang en_US\nkeyboard us\nselinux --disabled\nlogging --level=info\nreboot\ntext\nunsupported_hardware\nvnc\nskipx\ntimezone --isUtc Asia\/Hong_Kong\n#ONDHCP network --bootproto=dhcp --onboot=on\n#NODHCP network --bootproto=static --ip=$IPv4 --netmask=$MASK --gateway=$GATE --nameserver=8.8.8.8 --onboot=on\nbootloader --location=mbr --append=\"rhgb quiet crashkernel=auto\"\nzerombr\nclearpart --all --initlabel \nautopart\n\n%packages\n@base\n%end\n\n%post --interpreter=\/bin\/bash\nrm -rf \/root\/anaconda-ks.cfg\nrm -rf \/root\/install.*log\n%end\n\nEOF\n\n[[ \"$setNet\" == '0' ]] &amp;&amp; [[ \"$AutoNet\" == '1' ]] &amp;&amp; {\n  sed -i 's\/#ONDHCP\\ \/\/g' \/tmp\/boot\/ks.cfg\n} || {\n  sed -i 's\/#NODHCP\\ \/\/g' \/tmp\/boot\/ks.cfg\n}\n[[ \"$UNKNOWHW\" == '1' ]] &amp;&amp; sed -i 's\/^unsupported_hardware\/#unsupported_hardware\/g' \/tmp\/boot\/ks.cfg\n[[ \"$(echo \"$DIST\" |grep -o '^[0-9]\\{1\\}')\" == '5' ]] &amp;&amp; sed -i '0,\/^%end\/s\/\/#%end\/' \/tmp\/boot\/ks.cfg\nfi\n\nfind . | cpio -H newc --create --verbose | gzip -9 &gt; \/boot\/initrd.img;\nrm -rf \/tmp\/boot;\n}\n\n[[ \"$inVNC\" == 'y' ]] &amp;&amp; {\n  sed -i '$i\\\\n' $GRUBDIR\/$GRUBFILE\n  sed -i '$r \/tmp\/grub.new' $GRUBDIR\/$GRUBFILE\n  echo -e \"\\n\\033[33m\\033[04mIt will reboot! \\nPlease look at VNC! \\nSelect\\033[0m\\033[32m Install OS [$DIST $VER] \\033[33m\\033[4mto install system.\\033[04m\\n\\n\\033[31m\\033[04mThere is some information for you.\\nDO NOT CLOSE THE WINDOW! \\033[0m\\n\"\n  echo -e \"\\033[35mIPv4\\t\\tNETMASK\\t\\tGATEWAY\\033[0m\"\n  echo -e \"\\033[36m\\033[04m$IPv4\\033[0m\\t\\033[36m\\033[04m$MASK\\033[0m\\t\\033[36m\\033[04m$GATE\\033[0m\\n\\n\"\n\n  read -n 1 -p \"Press Enter to reboot...\" INP\n  [[ \"$INP\" != '' ]] &amp;&amp; echo -ne '\\b \\n\\n';\n}\n\nchown root:root $GRUBDIR\/$GRUBFILE\nchmod 444 $GRUBDIR\/$GRUBFILE\n\nsleep 3 &amp;&amp; reboot &gt;\/dev\/null 2&gt;&amp;1<\/pre>\n<p>&nbsp;\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\t\t\t\t\t\t&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"http:\/\/www.zhangyijun.com\/?p=93\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-93","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=\/wp\/v2\/posts\/93","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=93"}],"version-history":[{"count":0,"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=\/wp\/v2\/posts\/93\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zhangyijun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}