请叫我峰子:
感受VPS建站的乐趣。

脚本: 无限制一键全自动 DD 安装 Debian/Ubuntu/Windows

全文转载自萌咖,博主在波兰 VPS 上使用无问题,小伙伴们在 Vultr、DO 等常见机器也无问题。
也可参考狗仔小分队的文章

用途

  • 突破没有 VNC, 没有救援模式, 内存比 dd 包小的限制.
    使用 Debian Live CD 中的 busybox 做中间媒介, 经过复杂的处理,
    使本机的网络参数传进 Windows 操作系统中,
    即使没有 DHCP 能够让 Windows 获取网络参数,
    也能让 Windows 操作系统在开机的第一时间能够连通网络.
  • 与萌咖博客中的 Debian(Ubuntu) 网络安装 / 重装一键脚本需求一样.
  • 因为是同一个脚本. 没错, 现在可以 Debian/Ubuntu/Windows 三合一.

注意

当然肯定是有一些限制, 满足以下条件后封装即可使用脚本自动 dd, 自动配置网络.

  • 需要定制 dd 包.
    1. 默认 Administrator 账户登录.
    2. 默认开启远程桌面 (默认 3389 端口).
    3. 适当的调整防火墙.(可选)
  • 需要自行添加相关的虚拟化驱动.
    例如 VirtIO 驱动和 XEN 驱动.
    dd 包解压后的体积不能超过机器第一块硬盘的最大容积.
  • 萌咖提供的镜像只是一个 demo. 仅修改了主机名, 可放心使用.(强烈建议自己制作.)

使用

仅在 KVM,Hyper-v 虚拟化构架中通过测试 (因为只添加了 VirtIO 驱动)。无需 VNC, 无需 DHCP.

wget --no-check-certificate -qO DebianNET.sh 'https://moeclub.org/attachment/LinuxShell/DebianNET.sh' && bash DebianNET.sh -dd 'https://moeclub.org/get-win7embx86-auto'
  • 默认账号密码:Administrator/Vicer

免责声明

  • 如果因此违反了 TOS, 或造成损失萌咖不负任何责任.

源码

#!/bin/bash

while [[ $# -ge 1 ]]; do
  case $1 in
    -v|--ver)
      shift
      VERtmp="$1"
      shift
      ;;
    -d|--debian|--ubuntu)
      shift
      vDEBtmp="$1"
      shift
      ;;
    -dd|--ddwin)
      shift
      ddMode='1'
      URLtmp="$1"
      shift
      ;;
    -p|--password)
      shift
      WDtmp="$1"
      shift
      ;;
    -a|--auto)
      shift
      INStmp='auto'
      ;;
    -m|--manual)
      shift
      INStmp='manual'
      ;;
    -apt|--mirror)
      shift
      isMirror='1'
      tmpMirror="$1"
      shift
      ;;
    -ssl)
      shift
      tmpSSL="$1"
      shift
      ;;
    *)
      echo -ne " Usage:ntbash $0t-d/--debian [7/33[33m33[04mwheezy33[0m|8/jessie|9/stretch]ntttt-v/--ver [32/33[33m33[04mi38633[0m|64/amd64]ntttt-apt/--mirrorntttt-dd/--ddwinntttt-a/--autontttt-m/--manualn"
      exit 1;
      ;;
    esac
  done

[[ $EUID -ne 0 ]] && echo "Error:This script must be run as root!" && exit 1
[[ -f /boot/grub/grub.cfg ]] && GRUBOLD='0' && GRUBDIR='/boot/grub' && GRUBFILE='grub.cfg'
[[ -z $GRUBDIR ]] && [[ -f /boot/grub2/grub.cfg ]] && GRUBOLD='0' && GRUBDIR='/boot/grub2' && GRUBFILE='grub.cfg'
[[ -z $GRUBDIR ]] && [[ -f /boot/grub/grub.conf ]] && GRUBOLD='1' && GRUBDIR='/boot/grub' && GRUBFILE='grub.conf'
[ -z $GRUBDIR -o -z $GRUBFILE ] && echo "Error! Not Found grub path." && exit 1

[[ -n $vDEBtmp ]] && {
[ "$vDEBtmp" == '7' -o "$vDEBtmp" == 'wheezy' ] && linuxdists='debian' && vDEB='wheezy';
[ "$vDEBtmp" == '8' -o "$vDEBtmp" == 'jessie' ] && linuxdists='debian' && vDEB='jessie';
[ "$vDEBtmp" == '9' -o "$vDEBtmp" == 'stretch' ] && linuxdists='debian' && vDEB='stretch';
[[ "$vDEBtmp" == 'precise' ]] && linuxdists='ubuntu' && vDEB='precise';
[[ "$vDEBtmp" == 'trusty' ]] && linuxdists='ubuntu' && vDEB='trusty';
[[ "$vDEBtmp" == 'wily' ]] && linuxdists='ubuntu' && vDEB='wily';
[[ "$vDEBtmp" == 'xenial' ]] && linuxdists='ubuntu' && vDEB='xenial';
[[ "$vDEBtmp" == 'yakkety' ]] && linuxdists='ubuntu' && vDEB='yakkety';
[[ "$vDEBtmp" == 'zesty' ]] && linuxdists='ubuntu' && vDEB='zesty';
}
[[ -n $vDEBtmp ]] && {
[ "$VERtmp" == '32' -o "$VERtmp" == 'i386' ] && VER='i386';
[ "$VERtmp" == '64' -o "$VERtmp" == 'amd64' ] && VER='amd64';
}
[[ -n $ddMode ]] && [[ "$ddMode" == '1' ]] && {
[[ -n $URLtmp ]] && {
linuxdists='debian';
vDEB='jessie';
VER='amd64';
INStmp='auto'
DDURL="$URLtmp"
[[ -n $tmpSSL ]] && CURL_SUPPORT="$tmpSSL"
[[ -z $CURL_SUPPORT ]] && CURL_SUPPORT='https://moeclub.org/get-curl_udeb_amd64'
} || {
echo 'Please input vaild URL! '
exit 1
}
} || {
ddMode='0';
}

[[ -z $linuxdists ]] && linuxdists='debian'
[[ -n $isMirror ]] && [[ "$isMirror" == '1' ]] && [[ -n $tmpMirror ]] && {
tmpDebianMirror="$(echo -n "$tmpMirror" |grep -Eo '.*.(w+)')"
echo -n "$tmpDebianMirror" |grep -q '://'
[[ $? -eq '0' ]] && {
DebianMirror="$(echo -n "$tmpDebianMirror" |awk -F'://' '{print $2}')"
} || {
DebianMirror="$(echo -n "$tmpDebianMirror")"
}
} || {
[[ $linuxdists == 'debian' ]] && DebianMirror='httpredir.debian.org'
[[ $linuxdists == 'ubuntu' ]] && DebianMirror='archive.ubuntu.com'
}
[[ -z $DebianMirrorDirectory ]] && [[ -n $DebianMirror ]] && [[ -n $tmpMirror ]] && {
DebianMirrorDirectory="$(echo -n "$tmpMirror" |awk -F''${DebianMirror}'' '{print $2}' |sed 's//$//g')"
}
[[ "$DebianMirrorDirectory" == '/' ]] && [[ -n $DebianMirror ]] && {
[[ $linuxdists == 'debian' ]] && DebianMirrorDirectory='/debian'
[[ $linuxdists == 'ubuntu' ]] && DebianMirrorDirectory='/ubuntu'
}
[[ -z $DebianMirrorDirectory ]] && [[ -n $DebianMirror ]] && {
[[ $linuxdists == 'debian' ]] && DebianMirrorDirectory='/debian'
[[ $linuxdists == 'ubuntu' ]] && DebianMirrorDirectory='/ubuntu'
}

[[ -n $INStmp ]] && {
[[ "$INStmp" == 'auto' ]] && inVNC='n'
[[ "$INStmp" == 'manual' ]] && inVNC='y'
}
[[ -n $WDtmp ]] && myPASSWORD="$WDtmp"

[[ -z $vDEB ]] && vDEB='wheezy';
[[ -z $VER ]] && VER='i386';
[[ -z $myPASSWORD ]] && myPASSWORD='Vicer'

clear && echo -e "n33[36m# Install33[0mn"

[[ -z $inVNC ]] && ASKVNC(){
inVNC='y';
[[ "$ddMode" == '0' ]] && {
echo -ne "33[34mCan you login VNC?33[0me[33m[e[32mye[33m/n]e[0m "
read inVNCtmp
[[ -n "$inVNCtmp" ]] && inVNC=$inVNCtmp
}
[ "$inVNC" == 'y' -o "$inVNC" == 'Y' ] && inVNC='y'
[ "$inVNC" == 'n' -o "$inVNC" == 'N' ] && inVNC='n'
}

[ "$inVNC" == 'y' -o "$inVNC" == 'n' ] || ASKVNC;

[[ $linuxdists == 'debian' ]] && LinuxName='Debian'
[[ $linuxdists == 'ubuntu' ]] && LinuxName='Ubuntu'
[[ "$ddMode" == '0' ]] && { 
[[ "$inVNC" == 'y' ]] && echo -e "33[34mManual Mode33[0m insatll 33[33m$LinuxName33[0m [33[33m$vDEB33[0m] [33[33m$VER33[0m] in VNC. "
[[ "$inVNC" == 'n' ]] && echo -e "33[34mAuto Mode33[0m insatll 33[33m$LinuxName33[0m [33[33m$vDEB33[0m] [33[33m$VER33[0m]. "
}
[[ "$ddMode" == '1' ]] && {
echo -ne "33[34mAuto Mode33[0m insatll 33[33mWindows33[0mn[33[33m$DDURL33[0m]n"
}

echo -e "n[33[33m$vDEB33[0m] [33[33m$VER33[0m] Downloading..."
[[ -z $DebianMirror ]] && echo -ne "33[31mError! 33[0mGet debian mirror fail! n" && exit 1
[[ -z $DebianMirrorDirectory ]] && echo -ne "33[31mError! 33[0mGet debian mirror directory fail! n" && exit 1
wget --no-check-certificate -qO '/boot/initrd.gz' "http://$DebianMirror$DebianMirrorDirectory/dists/$vDEB/main/installer-$VER/current/images/netboot/$linuxdists-installer/$VER/initrd.gz"
[[ $? -ne '0' ]] && echo -ne "33[31mError! 33[0mDownload 'initrd.gz' failed! n" && exit 1
wget --no-check-certificate -qO '/boot/linux' "http://$DebianMirror$DebianMirrorDirectory/dists/$vDEB/main/installer-$VER/current/images/netboot/$linuxdists-installer/$VER/linux"
[[ $? -ne '0' ]] && echo -ne "33[31mError! 33[0mDownload 'linux' failed! n" && exit 1

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 "$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}')"
IPv4="$(echo -n "$IPSUB" |cut -d'/' -f1)"
NETSUB="$(echo -n "$IPSUB" |grep -o '/[0-9]{1,2}')"
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 "$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)"

[[ -n "$GATE" ]] && [[ -n "$MASK" ]] && [[ -n "$IPv4" ]] || {
echo "Not found `ip command`, It will use `route command`."
ipNum() {
  local IFS='.'
  read ip1 ip2 ip3 ip4 <<<"$1"
  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

[[ "$GRUBOLD" == '0' ]] && {
CFG0="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
CFG2="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 2 |tail -n 1)"
CFG1=""
for CFGtmp in `awk '/}/{print NR}' $GRUBDIR/$GRUBFILE`
 do
  [ $CFGtmp -gt "$CFG0" -a $CFGtmp -lt "$CFG2" ] && CFG1="$CFGtmp";
 done
[[ -z "$CFG1" ]] && {
echo "Error! read $GRUBFILE. "
exit 1
}
sed -n "$CFG0,$CFG1"p $GRUBDIR/$GRUBFILE >/tmp/grub.new
[[ -f /tmp/grub.new ]] && [[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || {
echo -ne "33[31mError! 33[0mNot configure $GRUBFILE. n"
exit 1
}

sed -i "/menuentry.*/cmenuentry 'Install OS [$vDEB $VER]' --class debian --class gnu-linux --class gnu --class os {" /tmp/grub.new
[[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || {
echo "Error! configure append $GRUBFILE. "
exit 1
}
sed -i "/echo.*Loading/d" /tmp/grub.new
}

[[ "$GRUBOLD" == '1' ]] && {
CFG0="$(awk '/title /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
CFG1="$(awk '/title /{print NR}' $GRUBDIR/$GRUBFILE|head -n 2 |tail -n 1)"
[[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 == $CFG0 ] && sed -n "$CFG0,$"p $GRUBDIR/$GRUBFILE >/tmp/grub.new
[[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 != $CFG0 ] && sed -n "$CFG0,$CFG1"p $GRUBDIR/$GRUBFILE >/tmp/grub.new
[[ ! -f /tmp/grub.new ]] && echo "Error! configure append $GRUBFILE. " && exit 1
sed -i "/title.*/ctitle 'Install OS [$vDEB $VER]'" /tmp/grub.new
sed -i '/^#/d' /tmp/grub.new
}

[[ -n "$(grep 'initrd.*/' /tmp/grub.new |awk '{print $2}' |tail -n 1 |grep '^/boot/')" ]] && Type='InBoot' || Type='NoBoot'

LinuxKernel="$(grep 'linux.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)"
[[ -z $LinuxKernel ]] && LinuxKernel="$(grep 'kernel.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)"
LinuxIMG="$(grep 'initrd.*/' /tmp/grub.new |awk '{print $1}' |tail -n 1)"

[[ "$Type" == 'InBoot' ]] && {
sed -i "/$LinuxKernel.*//c\t$LinuxKernel\t/boot/linux auto=true hostname=$linuxdists domain= -- quiet" /tmp/grub.new
sed -i "/$LinuxIMG.*//c\t$LinuxIMG\t/boot/initrd.gz" /tmp/grub.new
}

[[ "$Type" == 'NoBoot' ]] && {
sed -i "/$LinuxKernel.*//c\t$LinuxKernel\t/linux auto=true hostname=$linuxdists domain= -- quiet" /tmp/grub.new
sed -i "/$LinuxIMG.*//c\t$LinuxIMG\t/initrd.gz" /tmp/grub.new
}

sed -i '$a\n' /tmp/grub.new

[[ "$inVNC" == 'n' ]] && {
GRUBPATCH='0'
[ -f /etc/network/interfaces -o -d /etc/sysconfig/network-scripts ] && {
sed -i ''${CFG0}'i\n' $GRUBDIR/$GRUBFILE
sed -i ''${CFG0}'r /tmp/grub.new' $GRUBDIR/$GRUBFILE
[[ -z $AutoNet ]] && echo "Error, Not found interfaces config." && exit 1
[[ -f  $GRUBDIR/grubenv ]] && sed -i 's/saved_entry/#saved_entry/g' $GRUBDIR/grubenv
[[ -d /boot/tmp ]] && rm -rf /boot/tmp
mkdir -p /boot/tmp/
cd /boot/tmp/
gzip -d < ../initrd.gz | cpio --extract --verbose --make-directories --no-absolute-filenames >>/dev/null 2>&1
cat >/boot/tmp/preseed.cfg<<EOF
d-i debian-installer/locale string en_US
d-i console-setup/layoutcode string us

d-i keyboard-configuration/xkb-keymap string us

d-i netcfg/choose_interface select auto

d-i netcfg/disable_autoconfig boolean true
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually
d-i netcfg/get_ipaddress string $IPv4
d-i netcfg/get_netmask string $MASK
d-i netcfg/get_gateway string $GATE
d-i netcfg/get_nameservers string 8.8.8.8
d-i netcfg/no_default_route boolean true
d-i netcfg/confirm_static boolean true

d-i hw-detect/load_firmware boolean false

d-i mirror/country string manual
d-i mirror/http/hostname string $DebianMirror
d-i mirror/http/directory string $DebianMirrorDirectory
d-i mirror/http/proxy string

d-i passwd/root-login boolean ture
d-i passwd/make-user boolean false
d-i passwd/root-password password $myPASSWORD
d-i passwd/root-password-again password $myPASSWORD
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false

d-i clock-setup/utc boolean true
d-i time/zone string US/Eastern
d-i clock-setup/ntp boolean true

d-i preseed/early_command string anna-install libfuse2-udeb fuse-udeb ntfs-3g-udeb fuse-modules-3.16.0-4-amd64-di
d-i partman/early_command string 
debconf-set partman-auto/disk "$(list-devices disk |head -n1)"; 
wget -qO- '$DDURL' |gunzip -dc |/bin/dd of=$(list-devices disk |head -n1); 
mount.ntfs-3g $(list-devices partition |head -n1) /mnt; 
cp -f 'https://7xlpwglucc.r.worldssl.net/net.bat' '/mnt/ProgramData/Microsoft/Windows/Start Menu/Programs/Startup/net.bat'; 
/sbin/reboot; 
debconf-set grub-installer/bootdev string "$(list-devices disk |head -n1)"; 
umount /media || true; 

d-i partman/mount_style select uuid
d-i partman-auto/init_automatically_partition select Guided - use entire disk
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-auto/choose_recipe select atomic
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

d-i debian-installer/allow_unauthenticated boolean true

tasksel tasksel/first multiselect minimal
d-i pkgsel/update-policy select none
d-i pkgsel/include string openssh-server
d-i pkgsel/upgrade select none

popularity-contest popularity-contest/participate boolean false

d-i grub-installer/only_debian boolean true
d-i grub-installer/bootdev string default
d-i finish-install/reboot_in_progress note
d-i debian-installer/exit/reboot boolean true
d-i preseed/late_command string 
sed -i 's/^.*PermitRootLogin.*/PermitRootLogin yes/g' /target/etc/ssh/sshd_config; 
sed -i 's/^.*PasswordAuthentication.*/PasswordAuthentication yes/g' /target/etc/ssh/sshd_config;
EOF
[[ "$AutoNet" -eq '1' ]] && {
sed -i '/netcfg/disable_autoconfig/d' /boot/tmp/preseed.cfg
sed -i '/netcfg/dhcp_options/d' /boot/tmp/preseed.cfg
sed -i '/netcfg/get_.*/d' /boot/tmp/preseed.cfg
sed -i '/netcfg/confirm_static/d' /boot/tmp/preseed.cfg
}
[[ "$vDEB" == 'trusty' ]] && GRUBPATCH='1'
[[ "$vDEB" == 'wily' ]] && GRUBPATCH='1'
[[ "$GRUBPATCH" == '1' ]] && {
sed -i 's/^d-i grub-installer/bootdev string default//g' /boot/tmp/preseed.cfg
}
[[ "$GRUBPATCH" == '0' ]] && {
sed -i 's/debconf-set grub-installer/bootdev.*";//g' /boot/tmp/preseed.cfg
}
[[ "$vDEB" == 'xenial' ]] && {
sed -i 's/^d-i clock-setup/ntp boolean true/d-i clock-setup/ntp boolean false/g' /boot/tmp/preseed.cfg
}
[[ "$linuxdists" == 'debian' ]] && {
sed -i '/user-setup/allow-password-weak/d' /boot/tmp/preseed.cfg
sed -i '/user-setup/encrypt-home/d' /boot/tmp/preseed.cfg
sed -i '/pkgsel/update-policy/d' /boot/tmp/preseed.cfg
sed -i 's/umount /media.*true; //g' /boot/tmp/preseed.cfg
}
[[ "$ddMode" == '1' ]] && {
[[ "$AutoNet" -eq '1' ]] && echo -ne "@ECHO OFFrncd4057d404245ProgramData4557Microsoft57Windows57Start40Menu57Programs57Startup42rndel4057f4057q40net56batrnrn" >'/boot/tmp/net.tmp';
[[ "$AutoNet" -eq '0' ]] && echo -ne "@ECHO OFFrncd567645windir45GetAdminrnif40exist4045windir45GetAdmin4050del4057f4057q404245windir45GetAdmin425140else4050rnecho40CreateObject^5042Shell56Application42^5156ShellExecute404245~s04254404245524254404242544042runas42544061407676404245temp45Admin56vbs42rn4245temp45Admin56vbs42rndel4057f4057q404245temp45Admin56vbs42rnexit4057b406251rnfor4057f4042tokens=635242404545i40in405047netsh40interface40show40interface40^|more40+340^|findstr4057R4042本地565240以太565240Local565240Ethernet42475140do4050set40EthName=4545j51rnnetsh40-c40interface40ip40set40address40name=4245EthName454240source=static40address=$IPv440mask=$MASK40gateway=$GATErnnetsh40-c40interface40ip40add40dnsservers40name=4245EthName4542 address=7056705670567040index=140validate=nornnetsh40-c40interface40ip40add40dnsservers40name=4245EthName454240address=7056705664566440index=240validate=norncd4057d404245ProgramData4557Microsoft57Windows57Start40Menu57Programs57Startup42rndel4057f4057q40net56batrnrn" >'/boot/tmp/net.tmp';
iconv -f 'UTF-8' -t 'GBK' '/boot/tmp/net.tmp' -o '/boot/tmp/net.bat'
rm -rf '/boot/tmp/net.tmp'
echo "$DDURL" |grep -q '^https://'
[[ $? -eq '0' ]] && {
echo -ne 'nAdd curl support...n'
[[ -n $CURL_SUPPORT ]] && {
wget --no-check-certificate -qO- "$CURL_SUPPORT" |tar -x
[[ ! -f  /boot/tmp/usr/bin/curl ]] && echo 'Error! CURL_SUPPORT.' && exit 1;
sed -i 's/wget -qO-//usr/bin/curl -ksSL/g' /boot/tmp/preseed.cfg
[[ $? -eq '0' ]] && echo 'Success! nn'
} || {
echo -ne 'Not curl support package! nn'
exit 1
}
}
}
[[ "$ddMode" == '0' ]] && {
sed -i '/anna-install/d' /boot/tmp/preseed.cfg
sed -i 's/wget.*/sbin/reboot; //g' /boot/tmp/preseed.cfg
}
rm -rf ../initrd.gz
find . | cpio -H newc --create --verbose | gzip -9 > ../initrd.gz
rm -rf /boot/tmp
}
}

[[ "$inVNC" == 'y' ]] && {
sed -i '$i\n' $GRUBDIR/$GRUBFILE
sed -i '$r /tmp/grub.new' $GRUBDIR/$GRUBFILE
echo -e "n33[33m33[04mIt will reboot! nPlease look at VNC! nSelect33[0m33[32m Install OS [$vDEB $VER] 33[33m33[4mto install system.33[04mnn33[31m33[04mThere is some information for you.nDO NOT CLOSE THE WINDOW! 33[0mn"
echo -e "33[35mIPv4ttNETMASKttGATEWAY33[0m"
echo -e "33[36m33[04m$IPv433[0mt33[36m33[04m$MASK33[0mt33[36m33[04m$GATE33[0mnn"

read -n 1 -p "Press Enter to reboot..." INP
if [[ "$INP" != '' ]] ; then
echo -ne 'b n'
echo "";
fi
}

chown root:root $GRUBDIR/$GRUBFILE
chmod 444 $GRUBDIR/$GRUBFILE

sleep 3 && reboot >/dev/null 2>&1
赞(1) 打赏
转载请注明:峰网博客 » 脚本: 无限制一键全自动 DD 安装 Debian/Ubuntu/Windows

评论 抢沙发

评论前必须登录!

 

中山网站建设

企业专线联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏