From 83957bb0870944fd14f3cef5fe8aea0773afd871 Mon Sep 17 00:00:00 2001 From: Bohan Yang Date: Mon, 8 Apr 2019 11:17:32 +0800 Subject: [PATCH] Update --- README.md | 5 ++++- netboot.sh | 55 ++++++++++++++++++++++++++++-------------------------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index b5a46d8..37dba68 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ sudo sh -c "$(wget -qO- https://github.com/brentybh/debian-netboot/raw/master/ne ### All Options - - `-c US` Debian Installer Country + - `-c CN` ~~Debian Installer Country~~ Only useful for the *Chinese Special* settings - `-fqdn debian` FQDN including hostname and domain. Priority: `-fqdn` option > rDNS > `debian` as default. - `-proto http` Transport protocol for archive mirror only but not security repository (`http`, `https`, `ftp`) - `-host deb.debian.org` Host for archive mirror only but not security repository @@ -47,6 +47,9 @@ sudo sh -c "$(wget -qO- https://github.com/brentybh/debian-netboot/raw/master/ne - `-add "ca-certificates curl fail2ban openssl whois"` Include individual additional packages to install - `-ssh secret` Enable network console and specify **password for SSH access during install process**. You can login with `installer` user and check system logs. - `-dry-run` Generate `preseed.cfg` and save to current dir but don't actually do anything + - `-manually` Manually configure user account and disk partition, etc. (Network, repository mirror & time related settings will be auto-configured) + - `-arch amd64` Specify architecture (useful under CentOS) + - `-lvm` Use `/` as the boot root path for the `grub.cfg` instead of `/boot`, useful under LVM partition disks ### Chinese Special diff --git a/netboot.sh b/netboot.sh index 055f923..723f13e 100644 --- a/netboot.sh +++ b/netboot.sh @@ -89,9 +89,15 @@ while [ $# -gt 0 ]; do shift ;; -ssh) + DEBNETB_SSH=true DEBNETB_SSH_PASSWD=$2 shift ;; + -ssh-pubkey) + DEBNETB_SSH=true + DEBNETB_SSH_PUBKEY=$2 + shift + ;; -fs) DEBNETB_FILESYS=$2 shift @@ -155,13 +161,12 @@ fi if [ "$DEBNETB_MANUALLY" != true ]; then if [ -z "$DEBNETB_PASSWD" ]; then - DEBNETB_PASSWD=$(mkpasswd -m sha-512) +DEBNETB_PASSWD=$(mkpasswd -m sha-512) else - DEBNETB_PASSWD=$(mkpasswd -m sha-512 "$DEBNETB_PASSWD") +DEBNETB_PASSWD=$(mkpasswd -m sha-512 "$DEBNETB_PASSWD") fi fi - if [ "$DEBNETB_DRYRUN" != true ]; then DEBNETB_BOOTNAME="debian-$DEBNETB_SUITE" if [ "$DEBNETB_ISLVM" = true ]; then @@ -185,7 +190,6 @@ cd "$DEBNETB_BOOT" fi cat >> preseed.cfg << EOF -# COUNTRY: 1 # IP_ADDR: 2 # NETMASK: 2 # GATEWAY: 2 @@ -196,20 +200,18 @@ cat >> preseed.cfg << EOF # HOST: 3 # DIR: 3 # SUITE: 3, 8 -# ADMIN: 4 -# PASSWD: 4 -# TIME_ZONE: 5 -# NTP: 5 +# TIME_ZONE: 4 +# NTP: 4 +# ADMIN: 5 +# PASSWD: 5 # FILESYS: 6 # DISKCRYPTO: 6 # SECURITY: 8 # INCLUDE: 9 # UPGRADE: 9 -# 1. Localization: +# 1. Localization -d-i debian-installer/language string en -d-i debian-installer/country string {{-COUNTRY-}} d-i debian-installer/locale string en_US.UTF-8 d-i keyboard-configuration/xkb-keymap select us @@ -246,11 +248,16 @@ cat >> preseed.cfg << EOF d-i hw-detect/load_firmware boolean true EOF -if [ -n "$DEBNETB_SSH_PASSWD" ]; then +if [ "$DEBNETB_SSH" = true ]; then echo "d-i anna/choose_modules string network-console" >> preseed.cfg echo "d-i preseed/early_command string anna-install network-console" >> preseed.cfg - echo "d-i network-console/password password $DEBNETB_SSH_PASSWD" >> preseed.cfg - echo "d-i network-console/password-again password $DEBNETB_SSH_PASSWD" >> preseed.cfg + if [ -n "$DEBNETB_SSH_PASSWD" ]; then + echo "d-i network-console/password password $DEBNETB_SSH_PASSWD" >> preseed.cfg + echo "d-i network-console/password-again password $DEBNETB_SSH_PASSWD" >> preseed.cfg + fi + if [ -n "$DEBNETB_SSH_PUBKEY" ]; then + echo "d-i network-console/authorized_keys_url string $DEBNETB_SSH_PUBKEY" >> preseed.cfg + fi echo "d-i network-console/start select Continue" >> preseed.cfg fi @@ -265,28 +272,25 @@ d-i mirror/{{-PROTO-}}/directory string {{-DIR-}} d-i mirror/{{-PROTO-}}/proxy string d-i mirror/suite string {{-SUITE-}} d-i mirror/udeb/suite string {{-SUITE-}} + +# 4. Clock and time zone setup: TIME_ZONE, NTP + +d-i clock-setup/utc boolean true +d-i time/zone string {{-TIME_ZONE-}} +d-i clock-setup/ntp boolean true +d-i clock-setup/ntp-server string {{-NTP-}} EOF if [ "$DEBNETB_MANUALLY" != true ]; then cat >> preseed.cfg << EOF -# 4. Account setup: ADMIN, PASSWD +# 5. Account setup: ADMIN, PASSWD d-i passwd/root-login boolean false d-i passwd/user-fullname string d-i passwd/username string {{-ADMIN-}} d-i passwd/user-password-crypted password {{-PASSWD-}} -# 5. Clock and time zone setup: TIME_ZONE, NTP - -d-i clock-setup/utc boolean true -d-i time/zone string {{-TIME_ZONE-}} -d-i clock-setup/ntp boolean true -d-i clock-setup/ntp-server string {{-NTP-}} -EOF - -cat >> preseed.cfg << EOF - # 6. Partitioning: FILESYS d-i partman-basicfilesystems/no_swap boolean false @@ -349,7 +353,6 @@ d-i finish-install/reboot_in_progress note EOF fi -sed -i 's/{{-COUNTRY-}}/'"$DEBNETB_COUNTRY"'/g' preseed.cfg sed -i 's/{{-PROTO-}}/'"$DEBNETB_PROTO"'/g' preseed.cfg sed -i 's/{{-HOST-}}/'"$DEBNETB_HOST"'/g' preseed.cfg sed -i 's/{{-DIR-}}/'$(echo "$DEBNETB_DIR" | sed 's/\//\\\//g')'/g' preseed.cfg