User Tools

Site Tools


computing:preseed

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
computing:preseed [2024/02/17 17:50] oemb1905computing:preseed [2024/02/17 17:52] oemb1905
Line 31: Line 31:
 After getting the virt-install recipe and config to perform the desired Debian install, my next task was to automate all of this with a simple script that would create a virtual hard disk of any desired size and a libvirt entry with my desired naming convention in my production VM directory. Here's what I came up with: After getting the virt-install recipe and config to perform the desired Debian install, my next task was to automate all of this with a simple script that would create a virtual hard disk of any desired size and a libvirt entry with my desired naming convention in my production VM directory. Here's what I came up with:
  
-  echo -n "Please enter the fully qualified hostname:"+  #!/bin/bash 
 +  echo -n "Please enter the fully qualified hostname: "
   read hostname   read hostname
-  echo -n "How large (in GB) would you like the virtual hard disk to be?"+  echo -n "How large (in GB) would you like the virtual hard disk to be? "
   read size   read size
   qemu-img create -f qcow2 /mnt/vms/production/${hostname}.qcow2 ${size}G   qemu-img create -f qcow2 /mnt/vms/production/${hostname}.qcow2 ${size}G
   sleep 2s   sleep 2s
-  echo "Okay, I am now creating the preseed.cfg file for your host +  echo -n "What do you want the last octet of the IP address for this host to be? " 
-  mkdir /mnt/vms/cfgs/${hostname} +  read ip 
-  cp -ar /mnt/vms/cfgs/preseed.cfg /mnt/vms/cfgs/${hostname}/preseed.cfg +  sleep 2s 
-  rpl -w "unassigned-hostname" "$hostname" /mnt/vms/cfgs/${hostname}/preseed.cfg +  echo "Okay, I am now creating the preseed.cfg file for your host ...
-  rpl -w "unassigned-domain" "$hostname" /mnt/vms/cfgs/${hostname}/preseed.cfg+  mkdir /mnt/vms/cfgs/external/${hostname} 
 +  cp -ar /mnt/vms/cfgs/external/preseed.cfg /mnt/vms/cfgs/external/${hostname}/preseed.cfg 
 +  rpl -w "unassigned-hostname" "$hostname" /mnt/vms/cfgs/external/${hostname}/preseed.cfg 
 +  rpl -w "unassigned-domain" "$hostname" /mnt/vms/cfgs/external/${hostname}/preseed.cfg 
 +  rpl -w "XXX" "$ip" /mnt/vms/cfgs/external/${hostname}/preseed.cfg 
 +  sleep 2s 
 +  echo "Alright, I am opening up virt-installer and building your host ..."
   sleep 2s   sleep 2s
-  echo "Alright, I am opening up virt-installer and building your host …" 
   virt-install --name=${hostname}.qcow2 \   virt-install --name=${hostname}.qcow2 \
    --os-variant=debian11 \    --os-variant=debian11 \
    --vcpu=2 \    --vcpu=2 \
    --ram=4096 \    --ram=4096 \
-   --disk path=/mnt/pathtovms/${hostname}.qcow2 \+   --disk path=/mnt/vms/production/${hostname}.qcow2 \
    --check path_in_use=off \    --check path_in_use=off \
    --graphics spice \    --graphics spice \
    --location=/mnt/vms/isos/debian-12.4.0-amd64-netinst.iso \    --location=/mnt/vms/isos/debian-12.4.0-amd64-netinst.iso \
    --network bridge:br0 \    --network bridge:br0 \
-   --initrd-inject /mnt/pathtovms/${hostname}/preseed.cfg+   --network bridge:virbr1 \ 
 +   --initrd-inject /mnt/vms/cfgs/external/${hostname}/preseed.cfg
  
 For now, I just need really simple Debian VMs as quickly as possible. However, as I wrote this, I began to realize that I could easily expand this script to meet the needs of a variety of different use cases, could add conditionals to it, validation and more. Down the road, I plan to do that, and you can stay up to date with how I expand this script's functionality on the Hacking Club repository: For now, I just need really simple Debian VMs as quickly as possible. However, as I wrote this, I began to realize that I could easily expand this script to meet the needs of a variety of different use cases, could add conditionals to it, validation and more. Down the road, I plan to do that, and you can stay up to date with how I expand this script's functionality on the Hacking Club repository:
computing/preseed.txt · Last modified: 2024/02/17 18:01 by oemb1905