浏览代码

Manual network configuration and full option names

Bohan Yang 7 年之前
父节点
当前提交
7f72ed4eab
共有 2 个文件被更改,包括 51 次插入13 次删除
  1. 4 0
      README.md
  2. 47 13
      netboot.sh

+ 4 - 0
README.md

@@ -34,6 +34,10 @@ sudo sh -c "$(wget -O - https://github.com/brentybh/debian-netboot/raw/master/ne
  - `-g <UPGRADE>` Whether to upgrade packages after debootstrap. Default is `full-upgrade`. `none` and `safe-upgrade` is also available.
  - `-g <UPGRADE>` Whether to upgrade packages after debootstrap. Default is `full-upgrade`. `none` and `safe-upgrade` is also available.
  - `-s <SECURITY>` Custom URL for security repository mirror. Default is `http://security.debian.org/debian-security`.
  - `-s <SECURITY>` Custom URL for security repository mirror. Default is `http://security.debian.org/debian-security`.
  - `-l` Security mirror linking. If the option present, security repository will be setup as same as the archive mirror instead of `security.debian.org`.
  - `-l` Security mirror linking. If the option present, security repository will be setup as same as the archive mirror instead of `security.debian.org`.
+ - `--addr <IPADDR>` Configure network manually with an IP address. Following options only work when IP address specified.
+ - `--mask <NETMASK>` Netmask for manual network configuration
+ - `--gate <GATEWAY>` Gateway for manual network configuration
+ - `--dns <DNS>` Domain Name Server for manual network configuration
 
 
 ### Chinese Special
 ### Chinese Special
 
 

+ 47 - 13
netboot.sh

@@ -20,57 +20,73 @@ set -ex
 
 
 while [ $# -gt 0 ]; do
 while [ $# -gt 0 ]; do
   case $1 in
   case $1 in
-    -c)
+    -c|--country)
       COUNTRY=$2
       COUNTRY=$2
       shift
       shift
       ;;
       ;;
-    -h)
+    -h|--hostname)
       HOST=$2
       HOST=$2
       shift
       shift
       ;;
       ;;
-    -x)
+    -x|--transport|--protocol)
       TRANSPORT=$2
       TRANSPORT=$2
       shift
       shift
       ;;
       ;;
-    -m)
+    -m|--mirror|--host)
       MIRROR=$2
       MIRROR=$2
       shift
       shift
       ;;
       ;;
-    -d)
+    -d|--dir|--path|--directory)
       DIRECTORY=${2%/}
       DIRECTORY=${2%/}
       shift
       shift
       ;;
       ;;
-    -r)
+    -r|--suite|--release)
       SUITE=$2
       SUITE=$2
       shift
       shift
       ;;
       ;;
-    -u)
+    -u|--user|--username)
       USERNAME=$2
       USERNAME=$2
       shift
       shift
       ;;
       ;;
-    -p)
+    -p|--pass|--password)
       PASSWORD=$2
       PASSWORD=$2
       shift
       shift
       ;;
       ;;
-    -z)
+    -z|--time|--zone|--timezone)
       TIMEZONE=$2
       TIMEZONE=$2
       shift
       shift
       ;;
       ;;
-    -t)
+    -t|--ntp|--ntpserver)
       NTPSERVER=$2
       NTPSERVER=$2
       shift
       shift
       ;;
       ;;
-    -s)
+    -s|--security)
       SECURITY=$2
       SECURITY=$2
       shift
       shift
       ;;
       ;;
-    -l)
+    -l|--link|--linked|--linking)
       LINKED=true
       LINKED=true
       ;;
       ;;
-    -g)
+    -g|--upgrade)
       UPGRADE=$2
       UPGRADE=$2
       shift
       shift
       ;;
       ;;
+    --addr|--ipaddr)
+      IPADDR=$2
+      shift
+      ;;
+    --mask|--netmask)
+      NETMASK=$2
+      shift
+      ;;
+    --gate|--gateway)
+      GATEWAY=$2
+      shift
+      ;;
+    --dns|--dnserver|--dnsserver)
+      DNS=$2
+      shift
+      ;;
     *)
     *)
       echo "Illegal option $1"
       echo "Illegal option $1"
       exit 1
       exit 1
@@ -147,6 +163,24 @@ d-i keyboard-configuration/xkb-keymap select us
 # 2. Network configuration: HOST
 # 2. Network configuration: HOST
 
 
 d-i netcfg/choose_interface select auto
 d-i netcfg/choose_interface select auto
+EOF
+
+if [ -n "$IPADDR" ]; then
+  echo "d-i netcfg/disable_autoconfig boolean true" >> preseed.cfg
+  echo "d-i netcfg/get_ipaddress string $IPADDR" >> preseed.cfg
+  if [ -n "$NETMASK" ]; then
+    echo "d-i netcfg/get_netmask string $NETMASK" >> preseed.cfg
+  fi
+  if [ -n "$GATEWAY" ]; then
+    echo "d-i netcfg/get_gateway string $GATEWAY" >> preseed.cfg
+  fi
+  if [ -n "$DNS" ]; then
+    echo "d-i netcfg/get_nameservers string $DNS" >> preseed.cfg
+  fi
+  echo "d-i netcfg/confirm_static boolean true" >> preseed.cfg
+fi
+
+cat >> preseed.cfg << EOF
 d-i netcfg/get_hostname string unassigned-hostname
 d-i netcfg/get_hostname string unassigned-hostname
 d-i netcfg/get_domain string unassigned-domain
 d-i netcfg/get_domain string unassigned-domain
 d-i netcfg/hostname string {{-HOST-}}
 d-i netcfg/hostname string {{-HOST-}}