VPS一键 dd 安装 Windows脚本

发布时间: 2017-11-23

通常在Linux VPS下安装windows用的比较多的方法是DD,Vicer大佬已经制作出通用的一键脚本,在cloudcone一台VPS上测试正常安装,耗时不到20分钟。根据大佬的教程,可以自己制作镜像包,添加相应的驱动。目前支持KVM、Hyper-V构架,OPENVZ不支持。

  • 特点:

突破没有VNC,没有救援模式,内存比dd包小的限制.
使用Debian Live CD中的busybox做中间媒介,经过复杂的处理,
使本机的网络参数传进Windows操作系统中,
即使没有DHCP能够让Windows获取网络参数,
也能让Windows操作系统在开机的第一时间能够连通网络.

  • 准备:
    • 需要定制dd包.
      1. 默认Administrator账户登录.
      2. 默认开启远程桌面(默认3389端口).
      3. 适当的调整防火墙.(可选)
    • 需要相关的虚拟化驱动.
    • dd包解压后的体积不能超过机器第一块硬盘的最大容积.
    • 无DHCP时额外需求: iconv,Debian/Ubuntu自带,Centos系yum install glibc-common
  • 使用方法:
  1. wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && bash DebianNET.sh -dd '[Windows dd包直连地址]'
  • 萌咖提供的dd包:
  1. wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && bash DebianNET.sh -dd 'https://moeclub.org/get-win7embx86-auto'
  • 注意事项:
    1. 远程登陆账号为: Administrator
    2. 远程登陆密码为: Vicer
    3. 仅修改了主机名,可放心使用.(建议自己制作.)
    4. 使用的公用网盘,如需长期/大量使用此包请自行备份.
    5. 如果因此违反了TOS,作者不负任何责任.
  • 可能用到的命令:
  1. ::以管理员身份运行CMD::
  2. ::更改用户的密码
  3. net user [用户名] [密码]
  4. ::激活 Administrator 账户
  5. net user Administrator /active:yes
  6. ::设置 Administrator 账户密码
  7. net user Administrator [新密码]
  8. ::添加用户
  9. net user [用户名] [密码] /add
  10. ::将用户添加至 Administrator
  11. net localgroup Administrators [用户名] /add
  12. ::删除用户
  13. net user [用户名] /del

 

 

代码备份
  1. #!/bin/bash
  2. while [[ $# -ge 1 ]]; do
  3. case $1 in
  4. -v|--ver)
  5. shift
  6. VERtmp="$1"
  7. shift
  8. ;;
  9. -d|--debian|--ubuntu)
  10. shift
  11. vDEBtmp="$1"
  12. shift
  13. ;;
  14. -dd|--ddwin)
  15. shift
  16. ddMode='1'
  17. URLtmp="$1"
  18. shift
  19. ;;
  20. -p|--password)
  21. shift
  22. WDtmp="$1"
  23. shift
  24. ;;
  25. -a|--auto)
  26. shift
  27. INStmp='auto'
  28. ;;
  29. -m|--manual)
  30. shift
  31. INStmp='manual'
  32. ;;
  33. -apt|--mirror)
  34. shift
  35. isMirror='1'
  36. tmpMirror="$1"
  37. shift
  38. ;;
  39. -ssl)
  40. shift
  41. tmpSSL="$1"
  42. shift
  43. ;;
  44. *)
  45. echo -ne " Usage:\n\tbash $0\t-d/--debian [7/\033[33m\033[04mwheezy\033[0m|8/jessie|9/stretch]\n\t\t\t\t-v/--ver [32/\033[33m\033[04mi386\033[0m|64/amd64]\n\t\t\t\t-apt/--mirror\n\t\t\t\t-dd/--ddwin\n\t\t\t\t-a/--auto\n\t\t\t\t-m/--manual\n"
  46. exit 1;
  47. ;;
  48. esac
  49. done
  50. [[ $EUID -ne 0 ]] && echo "Error:This script must be run as root!" && exit 1
  51. [[ -f /boot/grub/grub.cfg ]] && GRUBOLD='0' && GRUBDIR='/boot/grub' && GRUBFILE='grub.cfg'
  52. [[ -z $GRUBDIR ]] && [[ -f /boot/grub2/grub.cfg ]] && GRUBOLD='0' && GRUBDIR='/boot/grub2' && GRUBFILE='grub.cfg'
  53. [[ -z $GRUBDIR ]] && [[ -f /boot/grub/grub.conf ]] && GRUBOLD='1' && GRUBDIR='/boot/grub' && GRUBFILE='grub.conf'
  54. [ -z $GRUBDIR -o -z $GRUBFILE ] && echo "Error! Not Found grub path." && exit 1
  55. [[ -n $vDEBtmp ]] && {
  56. [ "$vDEBtmp" == '7' -o "$vDEBtmp" == 'wheezy' ] && linuxdists='debian' && vDEB='wheezy';
  57. [ "$vDEBtmp" == '8' -o "$vDEBtmp" == 'jessie' ] && linuxdists='debian' && vDEB='jessie';
  58. [ "$vDEBtmp" == '9' -o "$vDEBtmp" == 'stretch' ] && linuxdists='debian' && vDEB='stretch';
  59. [[ "$vDEBtmp" == 'precise' ]] && linuxdists='ubuntu' && vDEB='precise';
  60. [[ "$vDEBtmp" == 'trusty' ]] && linuxdists='ubuntu' && vDEB='trusty';
  61. [[ "$vDEBtmp" == 'wily' ]] && linuxdists='ubuntu' && vDEB='wily';
  62. [[ "$vDEBtmp" == 'xenial' ]] && linuxdists='ubuntu' && vDEB='xenial';
  63. [[ "$vDEBtmp" == 'yakkety' ]] && linuxdists='ubuntu' && vDEB='yakkety';
  64. [[ "$vDEBtmp" == 'zesty' ]] && linuxdists='ubuntu' && vDEB='zesty';
  65. }
  66. [[ -n $vDEBtmp ]] && {
  67. [ "$VERtmp" == '32' -o "$VERtmp" == 'i386' ] && VER='i386';
  68. [ "$VERtmp" == '64' -o "$VERtmp" == 'amd64' ] && VER='amd64';
  69. }
  70. [[ -n $ddMode ]] && [[ "$ddMode" == '1' ]] && {
  71. [[ -n $URLtmp ]] && {
  72. linuxdists='debian';
  73. vDEB='jessie';
  74. VER='amd64';
  75. INStmp='auto'
  76. DDURL="$URLtmp"
  77. [[ -n $tmpSSL ]] && CURL_SUPPORT="$tmpSSL"
  78. [[ -z $CURL_SUPPORT ]] && CURL_SUPPORT='https://moeclub.org/get-curl_udeb_amd64'
  79. } || {
  80. echo 'Please input vaild URL! '
  81. exit 1
  82. }
  83. } || {
  84. ddMode='0';
  85. }
  86. [[ -z $linuxdists ]] && linuxdists='debian'
  87. [[ -n $isMirror ]] && [[ "$isMirror" == '1' ]] && [[ -n $tmpMirror ]] && {
  88. tmpDebianMirror="$(echo -n "$tmpMirror" |grep -Eo '.*\.(\w+)')"
  89. echo -n "$tmpDebianMirror" |grep -q '://'
  90. [[ $? -eq '0' ]] && {
  91. DebianMirror="$(echo -n "$tmpDebianMirror" |awk -F'://' '{print $2}')"
  92. } || {
  93. DebianMirror="$(echo -n "$tmpDebianMirror")"
  94. }
  95. } || {
  96. [[ $linuxdists == 'debian' ]] && DebianMirror='httpredir.debian.org'
  97. [[ $linuxdists == 'ubuntu' ]] && DebianMirror='archive.ubuntu.com'
  98. }
  99. [[ -z $DebianMirrorDirectory ]] && [[ -n $DebianMirror ]] && [[ -n $tmpMirror ]] && {
  100. DebianMirrorDirectory="$(echo -n "$tmpMirror" |awk -F''${DebianMirror}'' '{print $2}' |sed 's/\/$//g')"
  101. }
  102. [[ "$DebianMirrorDirectory" == '/' ]] && [[ -n $DebianMirror ]] && {
  103. [[ $linuxdists == 'debian' ]] && DebianMirrorDirectory='/debian'
  104. [[ $linuxdists == 'ubuntu' ]] && DebianMirrorDirectory='/ubuntu'
  105. }
  106. [[ -z $DebianMirrorDirectory ]] && [[ -n $DebianMirror ]] && {
  107. [[ $linuxdists == 'debian' ]] && DebianMirrorDirectory='/debian'
  108. [[ $linuxdists == 'ubuntu' ]] && DebianMirrorDirectory='/ubuntu'
  109. }
  110. [[ -n $INStmp ]] && {
  111. [[ "$INStmp" == 'auto' ]] && inVNC='n'
  112. [[ "$INStmp" == 'manual' ]] && inVNC='y'
  113. }
  114. [[ -n $WDtmp ]] && myPASSWORD="$WDtmp"
  115. [[ -z $vDEB ]] && vDEB='wheezy';
  116. [[ -z $VER ]] && VER='i386';
  117. [[ -z $myPASSWORD ]] && myPASSWORD='Vicer'
  118. clear && echo -e "\n\033[36m# Install\033[0m\n"
  119. [[ -z $inVNC ]] && ASKVNC(){
  120. inVNC='y';
  121. [[ "$ddMode" == '0' ]] && {
  122. echo -ne "\033[34mCan you login VNC?\033[0m\e[33m[\e[32my\e[33m/n]\e[0m "
  123. read inVNCtmp
  124. [[ -n "$inVNCtmp" ]] && inVNC=$inVNCtmp
  125. }
  126. [ "$inVNC" == 'y' -o "$inVNC" == 'Y' ] && inVNC='y'
  127. [ "$inVNC" == 'n' -o "$inVNC" == 'N' ] && inVNC='n'
  128. }
  129. [ "$inVNC" == 'y' -o "$inVNC" == 'n' ] || ASKVNC;
  130. [[ $linuxdists == 'debian' ]] && LinuxName='Debian'
  131. [[ $linuxdists == 'ubuntu' ]] && LinuxName='Ubuntu'
  132. [[ "$ddMode" == '0' ]] && {
  133. [[ "$inVNC" == 'y' ]] && echo -e "\033[34mManual Mode\033[0m insatll \033[33m$LinuxName\033[0m [\033[33m$vDEB\033[0m] [\033[33m$VER\033[0m] in VNC. "
  134. [[ "$inVNC" == 'n' ]] && echo -e "\033[34mAuto Mode\033[0m insatll \033[33m$LinuxName\033[0m [\033[33m$vDEB\033[0m] [\033[33m$VER\033[0m]. "
  135. }
  136. [[ "$ddMode" == '1' ]] && {
  137. echo -ne "\033[34mAuto Mode\033[0m insatll \033[33mWindows\033[0m\n[\033[33m$DDURL\033[0m]\n"
  138. }
  139. echo -e "\n[\033[33m$vDEB\033[0m] [\033[33m$VER\033[0m] Downloading..."
  140. [[ -z $DebianMirror ]] && echo -ne "\033[31mError! \033[0mGet debian mirror fail! \n" && exit 1
  141. [[ -z $DebianMirrorDirectory ]] && echo -ne "\033[31mError! \033[0mGet debian mirror directory fail! \n" && exit 1
  142. wget --no-check-certificate -qO '/boot/initrd.gz' "http://$DebianMirror$DebianMirrorDirectory/dists/$vDEB/main/installer-$VER/current/images/netboot/$linuxdists-installer/$VER/initrd.gz"
  143. [[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'initrd.gz' failed! \n" && exit 1
  144. wget --no-check-certificate -qO '/boot/linux' "http://$DebianMirror$DebianMirrorDirectory/dists/$vDEB/main/installer-$VER/current/images/netboot/$linuxdists-installer/$VER/linux"
  145. [[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'linux' failed! \n" && exit 1
  146. 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}')"
  147. [[ -n "$DEFAULTNET" ]] && 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\}')"
  148. IPv4="$(echo -n "$IPSUB" |cut -d'/' -f1)"
  149. NETSUB="$(echo -n "$IPSUB" |grep -o '/[0-9]\{1,2\}')"
  150. 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\}')"
  151. [[ -n "$NETSUB" ]] && 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)"
  152. [[ -n "$GATE" ]] && [[ -n "$MASK" ]] && [[ -n "$IPv4" ]] || {
  153. echo "Not found `ip command`, It will use `route command`."
  154. ipNum() {
  155. local IFS='.'
  156. read ip1 ip2 ip3 ip4 <<<"$1"
  157. echo $((ip1*(1<<24)+ip2*(1<<16)+ip3*(1<<8)+ip4)) } SelectMax(){ ii=0 for 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\}'` do NumTMP="$(ipNum $IPITEM)" eval "arrayNum[$ii]='$NumTMP,$IPITEM'" ii=$[$ii+1] done echo ${arrayNum[@]} |sed 's/\s/\n/g' |sort -n -k 1 -t ',' |tail -n1 |cut -d',' -f2 } [[ -z $IPv4 ]] && 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)" [[ -z $GATE ]] && GATE="$(SelectMax 2)" [[ -z $MASK ]] && MASK="$(SelectMax 3)" [[ -n "$GATE" ]] && [[ -n "$MASK" ]] && [[ -n "$IPv4" ]] || { echo "Error! Not configure network. " exit 1 } } [[ -f /etc/network/interfaces ]] && { [[ -z "$(sed -n '/iface.*inet static/p' /etc/network/interfaces)" ]] && AutoNet='1' || AutoNet='0' [[ -d /etc/network/interfaces.d ]] && { ICFGN="$(find /etc/network/interfaces.d -name '*.cfg' |wc -l)" || ICFGN='0' [[ "$ICFGN" -ne '0' ]] && { for NetCFG in `ls -1 /etc/network/interfaces.d/*.cfg` do [[ -z "$(cat $NetCFG | sed -n '/iface.*inet static/p')" ]] && AutoNet='1' || AutoNet='0' [[ "$AutoNet" -eq '0' ]] && break done } } } [[ -d /etc/sysconfig/network-scripts ]] && { ICFGN="$(find /etc/sysconfig/network-scripts -name 'ifcfg-*' |grep -v 'lo'|wc -l)" || ICFGN='0' [[ "$ICFGN" -ne '0' ]] && { for NetCFG in `ls -1 /etc/sysconfig/network-scripts/ifcfg-* |grep -v 'lo$' |grep -v ':[0-9]\{1,\}'` do [[ -n "$(cat $NetCFG | sed -n '/BOOTPROTO.*[dD][hH][cC][pP]/p')" ]] && AutoNet='1' || { AutoNet='0' && . $NetCFG [[ -n $NETMASK ]] && MASK="$NETMASK" [[ -n $GATEWAY ]] && GATE="$GATEWAY" } [[ "$AutoNet" -eq '0' ]] && break done } } [[ ! -f $GRUBDIR/$GRUBFILE ]] && echo "Error! Not Found $GRUBFILE. " && exit 1 [[ ! -f $GRUBDIR/$GRUBFILE.old ]] && [[ -f $GRUBDIR/$GRUBFILE.bak ]] && mv -f $GRUBDIR/$GRUBFILE.bak $GRUBDIR/$GRUBFILE.old mv -f $GRUBDIR/$GRUBFILE $GRUBDIR/$GRUBFILE.bak [[ -f $GRUBDIR/$GRUBFILE.old ]] && cat $GRUBDIR/$GRUBFILE.old >$GRUBDIR/$GRUBFILE || cat $GRUBDIR/$GRUBFILE.bak >$GRUBDIR/$GRUBFILE
  158. [[ "$GRUBOLD" == '0' ]] && {
  159. CFG0="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
  160. CFG2="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 2 |tail -n 1)"
  161. CFG1=""
  162. for CFGtmp in `awk '/}/{print NR}' $GRUBDIR/$GRUBFILE`
  163. do
  164. [ $CFGtmp -gt "$CFG0" -a $CFGtmp -lt "$CFG2" ] && CFG1="$CFGtmp";
  165. done
  166. [[ -z "$CFG1" ]] && {
  167. echo "Error! read $GRUBFILE. "
  168. exit 1
  169. }
  170. sed -n "$CFG0,$CFG1"p $GRUBDIR/$GRUBFILE >/tmp/grub.new
  171. [[ -f /tmp/grub.new ]] && [[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || {
  172. echo -ne "\033[31mError! \033[0mNot configure $GRUBFILE. \n"
  173. exit 1
  174. }
  175. sed -i "/menuentry.*/c\menuentry\ \'Install OS \[$vDEB\ $VER\]\'\ --class debian\ --class\ gnu-linux\ --class\ gnu\ --class\ os\ \{" /tmp/grub.new
  176. [[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || {
  177. echo "Error! configure append $GRUBFILE. "
  178. exit 1
  179. }
  180. sed -i "/echo.*Loading/d" /tmp/grub.new
  181. }
  182. [[ "$GRUBOLD" == '1' ]] && {
  183. CFG0="$(awk '/title /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
  184. CFG1="$(awk '/title /{print NR}' $GRUBDIR/$GRUBFILE|head -n 2 |tail -n 1)"
  185. [[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 == $CFG0 ] && sed -n "$CFG0,$"p $GRUBDIR/$GRUBFILE >/tmp/grub.new
  186. [[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 != $CFG0 ] && sed -n "$CFG0,$CFG1"p $GRUBDIR/$GRUBFILE >/tmp/grub.new
  187. [[ ! -f /tmp/grub.new ]] && echo "Error! configure append $GRUBFILE. " && exit 1
  188. sed -i "/title.*/c\title\ \'Install OS \[$vDEB\ $VER\]\'" /tmp/grub.new
  189. sed -i '/^#/d' /tmp/grub.new
  190. }
  191. [[ -n "$(grep 'initrd.*/' /tmp/grub.new |awk '{print $2}' |tail -n 1 |grep '^/boot/')" ]] && Type='InBoot' || Type='NoBoot'
  192. LinuxKernel="$(grep 'linux.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)"
  193. [[ -z $LinuxKernel ]] && LinuxKernel="$(grep 'kernel.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)"
  194. LinuxIMG="$(grep 'initrd.*/' /tmp/grub.new |awk '{print $1}' |tail -n 1)"
  195. [[ "$Type" == 'InBoot' ]] && {
  196. sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/boot\/linux auto=true hostname=$linuxdists domain= -- quiet" /tmp/grub.new
  197. sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/boot\/initrd.gz" /tmp/grub.new
  198. }
  199. [[ "$Type" == 'NoBoot' ]] && {
  200. sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/linux auto=true hostname=$linuxdists domain= -- quiet" /tmp/grub.new
  201. sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/initrd.gz" /tmp/grub.new
  202. }
  203. sed -i '$a\\n' /tmp/grub.new
  204. [[ "$inVNC" == 'n' ]] && {
  205. GRUBPATCH='0'
  206. [ -f /etc/network/interfaces -o -d /etc/sysconfig/network-scripts ] && {
  207. sed -i ''${CFG0}'i\\n' $GRUBDIR/$GRUBFILE
  208. sed -i ''${CFG0}'r /tmp/grub.new' $GRUBDIR/$GRUBFILE
  209. [[ -z $AutoNet ]] && echo "Error, Not found interfaces config." && exit 1
  210. [[ -f $GRUBDIR/grubenv ]] && sed -i 's/saved_entry/#saved_entry/g' $GRUBDIR/grubenv
  211. [[ -d /boot/tmp ]] && rm -rf /boot/tmp
  212. mkdir -p /boot/tmp/
  213. cd /boot/tmp/
  214. gzip -d < ../initrd.gz | cpio --extract --verbose --make-directories --no-absolute-filenames >>/dev/null 2>&1
  215. cat >/boot/tmp/preseed.cfg<'/boot/tmp/net.tmp';
  216. [[ "$AutoNet" -eq '0' ]] && echo -ne "@ECHO OFF\r\ncd\056\076\045windir\045\GetAdmin\r\nif\040exist\040\045windir\045\GetAdmin\040\050del\040\057f\040\057q\040\042\045windir\045\GetAdmin\042\051\040else\040\050\r\necho\040CreateObject^\050\042Shell\056Application\042^\051\056ShellExecute\040\042\045~s0\042\054\040\042\045\052\042\054\040\042\042\054\040\042runas\042\054\040\061\040\076\076\040\042\045temp\045\Admin\056vbs\042\r\n\042\045temp\045\Admin\056vbs\042\r\ndel\040\057f\040\057q\040\042\045temp\045\Admin\056vbs\042\r\nexit\040\057b\040\062\051\r\nfor\040\057f\040\042tokens=\063\052\042\040\045\045i\040in\040\050\047netsh\040interface\040show\040interface\040^|more\040+3\040^|findstr\040\057R\040\042本地\056\052\040以太\056\052\040Local\056\052\040Ethernet\042\047\051\040do\040\050set\040EthName=\045\045j\051\r\nnetsh\040-c\040interface\040ip\040set\040address\040name=\042\045EthName\045\042\040source=static\040address=$IPv4\040mask=$MASK\040gateway=$GATE\r\nnetsh\040-c\040interface\040ip\040add\040dnsservers\040name=\042\045EthName\045\042 address=\070\056\070\056\070\056\070\040index=1\040validate=no\r\nnetsh\040-c\040interface\040ip\040add\040dnsservers\040name=\042\045EthName\045\042\040address=\070\056\070\056\064\056\064\040index=2\040validate=no\r\ncd\040\057d\040\042\045ProgramData\045\057Microsoft\057Windows\057Start\040Menu\057Programs\057Startup\042\r\ndel\040\057f\040\057q\040net\056bat\r\n\r\n" >'/boot/tmp/net.tmp';
  217. iconv -f 'UTF-8' -t 'GBK' '/boot/tmp/net.tmp' -o '/boot/tmp/net.bat'
  218. rm -rf '/boot/tmp/net.tmp'
  219. echo "$DDURL" |grep -q '^https://'
  220. [[ $? -eq '0' ]] && {
  221. echo -ne '\nAdd curl support...\n'
  222. [[ -n $CURL_SUPPORT ]] && {
  223. wget --no-check-certificate -qO- "$CURL_SUPPORT" |tar -x
  224. [[ ! -f /boot/tmp/usr/bin/curl ]] && echo 'Error! CURL_SUPPORT.' && exit 1;
  225. sed -i 's/wget\ -qO-/\/usr\/bin\/curl -ksSL/g' /boot/tmp/preseed.cfg
  226. [[ $? -eq '0' ]] && echo 'Success! \n\n'
  227. } || {
  228. echo -ne 'Not curl support package! \n\n'
  229. exit 1
  230. }
  231. }
  232. }
  233. [[ "$ddMode" == '0' ]] && {
  234. sed -i '/anna-install/d' /boot/tmp/preseed.cfg
  235. sed -i 's/wget.*\/sbin\/reboot\;\ //g' /boot/tmp/preseed.cfg
  236. }
  237. rm -rf ../initrd.gz
  238. find . | cpio -H newc --create --verbose | gzip -9 > ../initrd.gz
  239. rm -rf /boot/tmp
  240. }
  241. }
  242. [[ "$inVNC" == 'y' ]] && {
  243. sed -i '$i\\n' $GRUBDIR/$GRUBFILE
  244. sed -i '$r /tmp/grub.new' $GRUBDIR/$GRUBFILE
  245. echo -e "\n\033[33m\033[04mIt will reboot! \nPlease look at VNC! \nSelect\033[0m\033[32m Install OS [$vDEB $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"
  246. echo -e "\033[35mIPv4\t\tNETMASK\t\tGATEWAY\033[0m"
  247. 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"
  248. read -n 1 -p "Press Enter to reboot..." INP
  249. if [[ "$INP" != '' ]] ; then
  250. echo -ne '\b \n'
  251. echo "";
  252. fi
  253. }
  254. chown root:root $GRUBDIR/$GRUBFILE
  255. chmod 444 $GRUBDIR/$GRUBFILE
  256. sleep 3 && reboot >/dev/null 2>&1

 


相关:https://moeclub.org/2017/11/19/483/

  1. soclearn
    2023-08-30 05:28:02

    有显示进度的一键dd脚本可以用了《利用可显进度的一键DD脚本1keydd安装win10(同时支持bios,uefi,支持vps,独服,计算实例)》https://www.bilibili.com/video/BV17B4y1b79Y 命令:wget -qO- inst.sh|bash

请在下方留下您的评论.加入TG吹水群