# 初始设置
d-i     netcfg/choose_interface select em1  # 多网卡初始选择
d-i     debian-installer/locale string en_US.UTF-8 # 选择语言
#d-i     debian-installer/splash boolean false
d-i     console-setup/ask_detect        boolean false
d-i     console-setup/layoutcode        string us # 键盘设置
d-i     console-setup/variantcode       string

# 1. 网络配置
#d-i     netcfg/get_nameservers  string dns服务器
#d-i     netcfg/get_ipaddress    string IP地址
#d-i     netcfg/get_netmask      string 子网掩码
#d-i     netcfg/get_gateway      string 网关
#d-i          netcfg/hostname string somehost 主机名
#d-i     netcfg/confirm_static   boolean true

# 2. 镜像设置
# 根据使用的安装方式,镜像可用于下载安装程序的额外组件、安装基本系统以及为所安装的系统建立 /etc/apt/sources.list
d-i mirror/country string china
d-i mirror/http/hostname string http.mirrors.aliyun.com
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string

# 3. 账号设置
d-i     passwd/root-login       boolean false # 不允许使用root,true为使用root用户
#d-i passwd/root-password password r00tme # root用户的明文密码
#d-i passwd/root-password-again password r00tme # 再次输入
#d-i passwd/root-password-crypted password $6$a.nzemIHmRqyiU$8Ee3.qGy9gPPShhTa/NYyX7c7Ga0kb4UOG.kr1p6tQB7cJRoxdTaXjGcCKHmSWRJ/DI693lJ9Mfy62gJI9L101 # 加密密码可使用mkpasswd -m sha-512来生成加密字符串

d-i     passwd/make-user        boolean true # 使用普通用户
d-i     passwd/user-fullname    string ubuntu # 普通用户的完整名称
d-i     passwd/username string ubuntu # 登录的用户名
d-i     passwd/user-password password ubuntu # 普通用户的密码
d-i     passwd/user-password-again password ubuntu # 再次确认密码
d-i     passwd/user-password-crypted password $6$m4WYoBEE$OFg6PjWwN7r27ri9yfBZXmyhtwbV11Rj0IUYvXFBhdvoIvkIHCNdD3Vltr8H1RHjC.K4Xj5MtXEIRPscTfyxD/ # 加密密码可使用mkpasswd -m sha-512来生成加密字符串

d-i     passwd/user-uid string 501 # 普通用户的uid
d-i     user-setup/allow-password-weak  boolean false
d-i     user-setup/encrypt-home boolean false # 是否对当前用户的家目录进行加密
d-i     passwd/user-default-groups      string adm cdrom dialout lpadmin plugdev sambashare

# 4. 时区设置
d-i     clock-setup/utc boolean true # 设置硬件时钟为UTC
d-i         time/zone string Asia/ShangHai # 设置地区
d-i     clock-setup/ntp boolean true #在NTP安装期间设置时钟
#d-i         clock-setup/ntp-server string ntp.example.com # 设置NTP服务器


# 5. 分区设置

d-i     partman-auto/method string regular # 使用整块硬盘
# 可使用选项如下:
# - regular: 使用整块硬盘
# - lvm:     使用LVM
# - crypto:  使用LVM并且加密分区

d-i     partman-lvm/device_remove_lvm boolean true
d-i     partman-lvm/confirm boolean true
d-i     partman/confirm_write_new_label boolean true
d-i         partman-auto/choose_recipe select atomic # 设置分区
# - atomic: 所有文件在一个分区
# - home:   独立home分区
# - multi:  独立 /home, /usr, /var, and /tmp 分区

d-i     partman/choose_partition        select Finish partitioning and write changes to disk
d-i     partman/confirm boolean true
d-i     partman/confirm_nooverwrite boolean true
d-i     partman/default_filesystem string ext4 # 设置文件系统类型

# 5.1 分区挂载控制
d-i partman/mount_style select uuid #使用UUID方式挂载分区

# 6. 基本系统安装
d-i     base-installer/kernel/p_w_picpath     string linux-server

# 7. 设置apt
d-i     apt-setup/services-select       multiselect security
d-i     apt-setup/security_host string mirrors.163.com # 选择更新的服务器
d-i     apt-setup/security_path string /ubuntu
d-i     debian-installer/allow_unauthenticated  string false
d-i     pkgsel/upgrade  select safe-upgrade
d-i     pkgsel/language-packs   multiselect
d-i     pkgsel/update-policy    select none
d-i     pkgsel/updatedb boolean trueb

# 8. 设置grub以及bootloader
d-i     grub-installer/skip     boolean false
d-i     lilo-installer/skip     boolean false
d-i     grub-installer/only_debian      boolean true
d-i     grub-installer/with_other_os    boolean true

# 9. 安装软件
d-i     pkgsel/include string openssh-server zabbix-agent vim


# 10. 安装过程中运行命令及脚本
#d-i preseed/early_command string anna-install some-udeb
#d-i partman/early_command \
#       string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh

d-i preseed/run string 1.sh

# 完成安装
d-i     finish-install/keep-consoles    boolean false
d-i     finish-install/reboot_in_progress       note
d-i     cdrom-detect/eject      boolean true
d-i     debian-installer/exit/halt      boolean false
d-i     debian-installer/exit/poweroff  boolean false