mirror of
https://github.com/bohanyang/debi.git
synced 2026-09-27 14:36:20 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88ee869a6e | ||
|
|
e5452a93e4 |
@@ -151,6 +151,7 @@ Otherwise, you can run this command to revert all changes made by the script:
|
||||
* `--grub-timeout 5` How many seconds the GRUB menu shows before entering the installer
|
||||
* `--force-lowmem <integer>` Valid values: 0, 1, 2. Force [low memory level](https://salsa.debian.org/installer-team/lowmem). Useful if your machine has memory less than 500M where level 2 is set (see issue #45). `--force-lowmem 1` may solve it.
|
||||
* `--dry-run` Print generated preseed and GRUB entry without downloading the installer and actually saving them
|
||||
* `--cidata ./cidata-example` Custom data for cloud-init. **VM provider's data source will be IGNORED.** See example.
|
||||
|
||||
### Presets
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
instance-id: 4c75121c-44fb-4166-8717-800b73cab4e4
|
||||
@@ -0,0 +1,21 @@
|
||||
#cloud-config
|
||||
hostname: ci01
|
||||
user: debian
|
||||
disable_root: false
|
||||
ssh_pwauth: true
|
||||
password: 'kuras001'
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCgBp08hAwwPk2w2T+yvlqil7jqXlzM7ulIA9lrgJB9NJLZV3wyYEmcxP/frTSUanjWtiYlrmn5d6EJFwR01Ga+aD6hwQoSZtKyVGY7zKfM6NWKF/lcpFT6HxPg33C4tpueqSqupSlx2yoPqRZhVoCeERrN9k/7fN8Bv8Xvfa/LN8sAI4v8CEJ7BpRXplRwnxceECBdJm0d3ebzMTnj1sfWBTgu/5iwpDh8DRR6LEab7famSTTB8jo6gz3gcwZC+Q3L/UTxS4kcjiQTuX7G74ae9+oSOpuPfP7N0Yo7lJDr8LCZHqkAZC47mQ2baatmD4hc3ZdVD64k6V1b/ms+37/7 youth@DESKTOP-AV4DNMN
|
||||
chpasswd: { expire: false }
|
||||
|
||||
write_files:
|
||||
- content: |
|
||||
[Swap]
|
||||
What=/swapfile
|
||||
|
||||
[Install]
|
||||
WantedBy=swap.target
|
||||
path: /etc/systemd/system/swapfile.swap
|
||||
|
||||
runcmd:
|
||||
- [ sh, -c, "[ ! -e /swapfile ] && { fallocate -l 100M /swapfile && chmod 0600 /swapfile && mkswap /swapfile; }; systemctl daemon-reload && systemctl enable --now swapfile.swap" ]
|
||||
@@ -18,7 +18,7 @@ command_exists() {
|
||||
}
|
||||
|
||||
# Sets variable:
|
||||
late_command=
|
||||
in_target_script=
|
||||
in_target() {
|
||||
local command=
|
||||
|
||||
@@ -27,8 +27,8 @@ in_target() {
|
||||
done
|
||||
|
||||
if [ -n "$command" ]; then
|
||||
[ -z "$late_command" ] && late_command='true'
|
||||
late_command="$late_command;$command"
|
||||
[ -z "$in_target_script" ] && in_target_script='true'
|
||||
in_target_script="$in_target_script;$command"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -200,11 +200,11 @@ dns='8.8.8.8 8.8.4.4'
|
||||
hostname=
|
||||
network_console=false
|
||||
set_debian_version 12
|
||||
mirror_protocol=http
|
||||
mirror_protocol=https
|
||||
mirror_host=deb.debian.org
|
||||
mirror_directory=/debian
|
||||
mirror_proxy=
|
||||
security_repository=http://security.debian.org/debian-security
|
||||
security_repository=mirror
|
||||
account_setup=true
|
||||
username=debian
|
||||
password=
|
||||
@@ -240,12 +240,18 @@ apt_non_free=false
|
||||
apt_contrib=false
|
||||
apt_src=true
|
||||
apt_backports=true
|
||||
cidata=
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--cdn|--aws)
|
||||
--cdn)
|
||||
mirror_protocol=https
|
||||
[ "$1" = '--aws' ] && mirror_host=cdn-aws.deb.debian.org
|
||||
mirror_host=deb.debian.org
|
||||
security_repository=mirror
|
||||
;;
|
||||
--aws)
|
||||
mirror_protocol=https
|
||||
mirror_host=cdn-aws.deb.debian.org
|
||||
security_repository=mirror
|
||||
;;
|
||||
--china)
|
||||
@@ -468,6 +474,12 @@ while [ $# -gt 0 ]; do
|
||||
--dry-run)
|
||||
dry_run=true
|
||||
;;
|
||||
--cidata)
|
||||
cidata=$(realpath "$2")
|
||||
[ ! -f "$cidata/meta-data" ] && err 'No "meta-data" file found in the cloud-init directory'
|
||||
[ ! -f "$cidata/user-data" ] && err 'No "user-data" file found in the cloud-init directory'
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
err "Unknown option: \"$1\""
|
||||
esac
|
||||
@@ -803,7 +815,10 @@ $save_preseed << 'EOF'
|
||||
tasksel tasksel/first multiselect ssh-server
|
||||
EOF
|
||||
|
||||
echo "d-i pkgsel/include string ca-certificates libpam-systemd $install" | $save_preseed
|
||||
install="$install ca-certificates libpam-systemd"
|
||||
[ -n "$cidata" ] && install="$install cloud-init"
|
||||
|
||||
[ -n "$install" ] && echo "d-i pkgsel/include string $install" | $save_preseed
|
||||
[ -n "$upgrade" ] && echo "d-i pkgsel/upgrade select $upgrade" | $save_preseed
|
||||
|
||||
$save_preseed << 'EOF'
|
||||
@@ -832,7 +847,13 @@ EOF
|
||||
|
||||
[ "$bbr" = true ] && in_target '{ echo "net.core.default_qdisc=fq"; echo "net.ipv4.tcp_congestion_control=bbr"; } > /etc/sysctl.d/bbr.conf'
|
||||
|
||||
[ -n "$late_command" ] && echo "d-i preseed/late_command string in-target sh -c '$late_command'" | $save_preseed
|
||||
[ -n "$cidata" ] && in_target 'echo "{ datasource_list: [ NoCloud ], datasource: { NoCloud: { fs_label: ~ } } }" > /etc/cloud/cloud.cfg.d/99_debi.cfg'
|
||||
|
||||
late_command='true'
|
||||
[ -n "$in_target_script" ] && late_command="$late_command; in-target sh -c '$in_target_script'"
|
||||
[ -n "$cidata" ] && late_command="$late_command; mkdir -p /target/var/lib/cloud/seed/nocloud; cp -r /cidata/. /target/var/lib/cloud/seed/nocloud/"
|
||||
|
||||
echo "d-i preseed/late_command string $late_command" | $save_preseed
|
||||
|
||||
[ "$power_off" = true ] && echo 'd-i debian-installer/exit/poweroff boolean true' | $save_preseed
|
||||
|
||||
@@ -850,6 +871,12 @@ save_grub_cfg='cat'
|
||||
gzip -d initrd.gz
|
||||
# cpio reads a list of file names from the standard input
|
||||
echo preseed.cfg | cpio -o -H newc -A -F initrd
|
||||
|
||||
if [ -n "$cidata" ]; then
|
||||
cp -r "$cidata" cidata
|
||||
find cidata | cpio -o -H newc -A -F initrd
|
||||
fi
|
||||
|
||||
gzip -1 initrd
|
||||
|
||||
mkdir -p /etc/default/grub.d
|
||||
|
||||
Reference in New Issue
Block a user