diff --git a/README.md b/README.md index 37301ff..169e467 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,11 @@ This script is written to reinstall a VPS/virtual machine to Debian 10 Buster. ## Available Options - * `--ip ` Static public/private IP, e.g. `10.0.0.2` - * `--netmask ` e.g. `255.255.255.0` / `ffff:ffff:ffff:ffff::`. Ignored if `--ip` is not specified - * `--gateway ` e.g. `10.0.0.1`. Ignored if `--ip` is not specified - * `--dns '8.8.8.8 8.8.4.4'` Quoted string where IP addresses are seperated by spaces. Ignored if `--ip` is not specified - * `--hostname debian` + * `--ip ` Disable the auto network config (DHCP) and set a static public/private IP address, e.g. `10.0.0.2` + * `--netmask ` Subnet mask of the static public/private IP address, e.g. (IPv4) `255.255.255.0` (IPv6) `ffff:ffff:ffff:ffff::` + * `--gateway ` e.g. `10.0.0.1` + * `--dns '8.8.8.8 8.8.4.4'` + * `--hostname ` FQDN hostname (includes the domain name), e.g. `server1.example.com` * `--network-console` Enable the network console of the installer. `ssh installer@ip` to connect * `--suite buster` * `--mirror-protocol http` or `https` or `ftp` @@ -60,7 +60,7 @@ This script is written to reinstall a VPS/virtual machine to Debian 10 Buster. * `--kernel ` Choose an package for the kernel image * `--cloud-kernel` Choose `linux-image-cloud-amd64` as the kernel image * `--no-install-recommends` - * `--install 'ca-certificates libpam-systemd'` Additional packages to install. Quoted string where package names are seperated by spaces. Package names specified here will override the default list, rather than append to it + * `--install 'ca-certificates libpam-systemd'` * `--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` diff --git a/debi.sh b/debi.sh index 8aa4b98..1d06dc2 100755 --- a/debi.sh +++ b/debi.sh @@ -250,6 +250,10 @@ done installer="debian-$suite" installer_directory="/boot/$installer" +while [ -z "$password" ]; do + prompt_password +done + save_preseed='cat' if [ "$dry_run" != true ]; then [ "$(id -u)" -ne 0 ] && err 'root privilege is required' @@ -276,25 +280,32 @@ if [ -n "$ip" ]; then echo 'd-i netcfg/disable_autoconfig boolean true' | $save_preseed echo "d-i netcfg/get_ipaddress string $ip" | $save_preseed [ -n "$netmask" ] && echo "d-i netcfg/get_netmask string $netmask" | $save_preseed - [ -n "$gateway" ] && echo "d-i netcfg/get_gateway string $gateway" | $save_preseed - [ -n "$dns" ] && echo "d-i netcfg/get_nameservers string $dns" | $save_preseed echo 'd-i netcfg/confirm_static boolean true' | $save_preseed fi -$save_preseed << 'EOF' -d-i netcfg/get_hostname string debian -d-i netcfg/get_domain string -EOF +[ -n "$gateway" ] && echo "d-i netcfg/get_gateway string $gateway" | $save_preseed +[ -n "$dns" ] && echo "d-i netcfg/get_nameservers string $dns" | $save_preseed if [ -n "$hostname" ]; then echo "d-i netcfg/hostname string $hostname" | $save_preseed + hostname=debian + domain= +else + hostname=$(cat /proc/sys/kernel/hostname) + domain=$(cat /proc/sys/kernel/domainname) + if [ "$domain" = '(none)' ]; then + domain= + else + domain=" $domain" + fi fi -echo 'd-i hw-detect/load_firmware boolean true' | $save_preseed +$save_preseed << EOF +d-i netcfg/get_hostname string $hostname +d-i netcfg/get_domain string$domain +EOF -while [ -z "$password" ]; do - prompt_password -done +echo 'd-i hw-detect/load_firmware boolean true' | $save_preseed if [ "$network_console" = true ]; then $save_preseed << EOF