From 82fa85594c87dc804b14fae263fbf725c4937393 Mon Sep 17 00:00:00 2001 From: Bohan Yang Date: Fri, 26 Nov 2021 21:41:18 +0800 Subject: [PATCH] Add --interface, --ssh-port; Always allow low-mem --- README.md | 6 ++++-- debi.sh | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9b26372..f48d82c 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,8 @@ Otherwise, you can run this command to revert all changes made by the script: ## Available Options + * `--interface ` Manually select a network interface, e.g. eth1 + * `--ethx` Disable *Consistent Network Device Naming* to get interface names like *ethX* back * `--ip ` Disable the auto network config (DHCP) and configure a static IP address, e.g. `10.0.0.2`, `1.2.3.4/24`, `2001:2345:6789:abcd::ef/48` * `--netmask ` e.g. `255.255.255.0`, `ffff:ffff:ffff:ffff::` * `--gateway ` e.g. `10.0.0.1`, `none` if no gateway @@ -135,9 +137,9 @@ Otherwise, you can run this command to revert all changes made by the script: * `--install 'ca-certificates libpam-systemd'` Install additional APT packages. Space-separated and quoted. * `--safe-upgrade` **(Default)** `apt upgrade --with-new-pkgs`. [See](https://salsa.debian.org/installer-team/pkgsel/-/blob/master/debian/postinst) * `--full-upgrade` `apt dist-upgrade` - * `--no-upgrade` - * `--ethx` Disable *Consistent Network Device Naming* to get interface names like *ethX* back + * `--no-upgrade` * `--bbr` Enable TCP BBR congestion control + * `--ssh-port ` SSH port * `--hold` Don't reboot or power off after installation * `--power-off` Power off after installation rather than reboot * `--architecture ` e.g. `amd64`, `i386`, `arm64`, `armhf`, etc. diff --git a/debi.sh b/debi.sh index 14becc2..6a0ea93 100755 --- a/debi.sh +++ b/debi.sh @@ -195,6 +195,7 @@ has_backports() { return 1 } +interface=auto ip= netmask= gateway= @@ -227,6 +228,7 @@ install='ca-certificates libpam-systemd' upgrade= kernel_params= bbr=false +ssh_port= hold=false power_off=false architecture= @@ -250,6 +252,10 @@ while [ $# -gt 0 ]; do ntp=ntp.aliyun.com security_repository=mirror ;; + --interface) + interface=$2 + shift + ;; --ip) ip=$2 shift @@ -391,6 +397,10 @@ while [ $# -gt 0 ]; do --bbr) bbr=true ;; + --ssh-port) + ssh_port=$2 + shift + ;; --hold) hold=true ;; @@ -470,7 +480,7 @@ elif [ "$network_console" = true ] && [ -z "$authorized_keys_url" ]; then prompt_password "Choose a password for the installer user of the SSH network console: " fi -$save_preseed << 'EOF' +$save_preseed << EOF # Localization d-i debian-installer/language string en @@ -480,7 +490,7 @@ d-i keyboard-configuration/xkb-keymap select us # Network configuration -d-i netcfg/choose_interface select auto +d-i netcfg/choose_interface select $interface EOF [ -n "$ip" ] && { @@ -609,6 +619,8 @@ EOF fi } +[ -n "$ssh_port" ] && configure_sshd Port "$ssh_port" + $save_preseed << EOF # Clock and time zone setup @@ -804,9 +816,7 @@ EOF installer_directory="$boot_directory$installer" -# shellcheck disable=SC2034 -mem=$(grep ^MemTotal: /proc/meminfo | { read -r x y z; echo "$y"; }) -[ $((mem / 1024)) -le 512 ] && kernel_params="$kernel_params lowmem/low=1" +kernel_params="$kernel_params lowmem/low=1" initrd="$installer_directory/initrd.gz" [ "$firmware" = true ] && initrd="$initrd $installer_directory/firmware.cpio.gz"