mirror of
https://codeberg.org/angestoepselt/imagestack.git
synced 2025-05-24 14:46:16 +00:00
Added Postinstall Scripts
This commit is contained in:
parent
49bb74859f
commit
fd27618915
5 changed files with 169 additions and 5 deletions
9
build.sh
9
build.sh
|
|
@ -1,7 +1,12 @@
|
||||||
cd source-files
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
cp preseed/preseed.cfg source/preseed.cfg
|
||||||
|
cp preseed/gtk.cfg source/isolinux/gtk.cfg
|
||||||
|
|
||||||
|
cd source
|
||||||
|
|
||||||
xorriso -as mkisofs \
|
xorriso -as mkisofs \
|
||||||
-o ../debian-angestoepselt.iso \
|
-o ../images/debian-angestoepselt.iso \
|
||||||
-c isolinux/boot.cat \
|
-c isolinux/boot.cat \
|
||||||
-b isolinux/isolinux.bin \
|
-b isolinux/isolinux.bin \
|
||||||
-no-emul-boot \
|
-no-emul-boot \
|
||||||
|
|
|
||||||
10
preseed/gtk.cfg
Normal file
10
preseed/gtk.cfg
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
default installgui
|
||||||
|
label installgui
|
||||||
|
menu label ^Graphical install
|
||||||
|
menu default
|
||||||
|
kernel /install.amd/vmlinuz
|
||||||
|
append vga=788 initrd=/install.amd/gtk/initrd.gz --- quiet
|
||||||
|
label auto-wipe
|
||||||
|
menu label ^Isopropanol (angestoepselt)
|
||||||
|
kernel /install.amd/vmlinuz
|
||||||
|
append auto=true priority=critical vga=788 file=/cdrom/preseed.cfg initrd=/install.amd/initrd.gz --- quiet
|
||||||
116
preseed/preseed.cfg
Executable file
116
preseed/preseed.cfg
Executable file
|
|
@ -0,0 +1,116 @@
|
||||||
|
|
||||||
|
|
||||||
|
### Allgemeines
|
||||||
|
# Verhindert weniger wichtige Nachfragen
|
||||||
|
# https://www.debian.org/releases/sarge/s390/ch05s02.html.en
|
||||||
|
# https://preseed.debian.net/debian-preseed/bullseye/amd64-main-full.txt
|
||||||
|
d-i debconf/priority string critical
|
||||||
|
# Deaktiviert die Meldung am Ende, dass die Installation abgeschlossen wurde und man neu starten kann
|
||||||
|
d-i finish-install/reboot_in_progress note
|
||||||
|
|
||||||
|
# Gibt an, ob Infos zum Nutzungsverhalten (installierte/verwendete Software) an Debian gesendet werden
|
||||||
|
popularity-contest popularity-contest/participate boolean false
|
||||||
|
# Proprietaere Firmware laden (falls es zu Hardwareproblemen kommt)
|
||||||
|
#d-i hw-detect/load_firmware boolean true
|
||||||
|
|
||||||
|
### Lokalisierung
|
||||||
|
d-i debian-installer/locale string de_DE
|
||||||
|
# Keymap setzen reicht nicht, layout/variantcode hilft ebenfalls nicht: https://groups.google.com/g/linux.debian.bugs.dist/c/XYcrRjLwpQM
|
||||||
|
d-i keyboard-configuration/variant select Deutschland
|
||||||
|
d-i keyboard-configuration/xkb-keymap select de
|
||||||
|
|
||||||
|
d-i clock-setup/utc boolean true
|
||||||
|
d-i tzdata/Areas select Europe
|
||||||
|
tzdata/Zones/Europe select Berlin
|
||||||
|
d-i time/zone string Europe/Berlin
|
||||||
|
|
||||||
|
### Partitionierung
|
||||||
|
# Grub wird automatisch auf den MBR installiert, wenn kein anderes OS vorhanden ist (sicher)
|
||||||
|
d-i grub-installer/only_debian boolean true
|
||||||
|
# MBR installation ebenfalls wenn andere OS vorhanden sind (koennte dazu fuehren, dass diese nicht mehr booten)
|
||||||
|
#d-i grub-installer/with_other_os boolean true
|
||||||
|
# Verhindert, dass grub alternativ fragt, wo er installiert werden soll
|
||||||
|
d-i grub-installer/bootdev string /dev/sda
|
||||||
|
# Fuer die vollautomatische Partitionierung (falls unten aktiv) - Beispiel Lenovo Tiny mit NVMe-SSD
|
||||||
|
# VirtualBox -> /dev/sda, KVM -> /dev/vda
|
||||||
|
#d-i partman-auto/disk string /dev/nvme0n1
|
||||||
|
|
||||||
|
# Fuer lvm 'lvmcfg/vgdelete_confirm', 'partman-lvm/confirm' und 'partman-lvm/confirm_nooverwrite' setzen
|
||||||
|
# Siehe https://www.debian.org/releases/stable/s390x/apbs04.de.html Abschnitt B.4.7.1.
|
||||||
|
d-i partman-auto/method string regular
|
||||||
|
# Alle Daten auf einer Partition (mit 'home' wird das Home-Verzeichnis auf eine eigene Partition gelegt)
|
||||||
|
d-i partman-auto/choose_recipe select atomic
|
||||||
|
|
||||||
|
# Komplett automatisiert ohne Bestaetigung fuer alle Partitionierungsmethoden (Mit Vorsicht verwenden!)
|
||||||
|
d-i partman/choose_partition select finish
|
||||||
|
d-i partman/confirm boolean true
|
||||||
|
d-i partman/confirm_nooverwrite boolean true
|
||||||
|
d-i partman-partitioning/confirm_write_new_label boolean true
|
||||||
|
d-i partman-md/confirm boolean true
|
||||||
|
d-i partman-md/deleteverify boolean true
|
||||||
|
d-i lvmcfg/vgdelete_confirm boolean true
|
||||||
|
d-i partman-lvm/vgdelete_confirm boolean true
|
||||||
|
d-i partman-lvm/device_remove_lvm boolean true
|
||||||
|
d-i partman-lvm/confirm boolean true
|
||||||
|
d-i partman-lvm/confirm_nooverwrite boolean true
|
||||||
|
|
||||||
|
### Software
|
||||||
|
d-i mirror/country string manual
|
||||||
|
d-i mirror/http/hostname string ftp2.de.debian.org
|
||||||
|
d-i mirror/http/directory string /debian
|
||||||
|
d-i mirror/http/proxy string
|
||||||
|
|
||||||
|
# Aktiviert Spiegelserver abseits der Sicherheitsupdates per Netzwerk statt Image
|
||||||
|
d-i apt-setup/use_mirror boolean true
|
||||||
|
d-i apt-setup/disable-cdrom-entries boolean true
|
||||||
|
# Aktiviert offizielle, aber unfreie Repositorys: https://wiki.debian.org/SourcesList
|
||||||
|
#d-i apt-setup/non-free boolean true
|
||||||
|
#d-i apt-setup/contrib boolean true
|
||||||
|
|
||||||
|
# Vorinstallierte Software
|
||||||
|
# Programmgruppe kann festlegen, ob z.B. Headless oder eine bestimmte Desktopumgebung (xfce-desktop, kde-desktop usw) vorinstalliert werden soll (siehe B.4.10)
|
||||||
|
tasksel tasksel/first multiselect standard, gnome-desktop
|
||||||
|
|
||||||
|
d-i pkgsel/install-language-support boolean true
|
||||||
|
d-i pkgsel/update-policy select Install security updates automatically
|
||||||
|
# Alle Pakete automatisch aktualisieren
|
||||||
|
d-i pkgsel/upgrade select full-upgrade
|
||||||
|
d-i pkgsel/include string git vim htop curl jq
|
||||||
|
|
||||||
|
# Stdout Weiterleitungen funktionieren in in-target nicht ohne --pass-stdout
|
||||||
|
# Siehe https://askubuntu.com/a/1248987/650986 und https://serverfault.com/questions/390122/how-do-i-pipe-commands-together-in-a-debian-preseed-file
|
||||||
|
|
||||||
|
### Benutzerkonten
|
||||||
|
d-i passwd/username string computerspende
|
||||||
|
d-i passwd/user-fullname string computerspende
|
||||||
|
d-i passwd/user-uid string 1000
|
||||||
|
d-i passwd/user-password password csw
|
||||||
|
d-i passwd/user-password-again password csw
|
||||||
|
# root
|
||||||
|
d-i passwd/root-password password csw
|
||||||
|
d-i passwd/root-password-again password csw
|
||||||
|
|
||||||
|
# Fuer Testsysteme kann die Policy strikter PWs abgeschaltet werden
|
||||||
|
d-i user-setup/allow-password-weak boolean true
|
||||||
|
d-i user-setup/encrypt-home boolean false
|
||||||
|
d-i user-setup/enable sudo boolean true
|
||||||
|
### Netzwerk
|
||||||
|
d-i netcfg/enable boolean true
|
||||||
|
d-i netcfg/choose_interface select auto
|
||||||
|
d-i netcfg/hostname string computerspende
|
||||||
|
|
||||||
|
d-i preseed/late_command string \
|
||||||
|
in-target --pass-stdout bash -c "echo 'computerspende ALL=NOPASSWD:ALL' > /etc/sudoers.d/computerspende"; \
|
||||||
|
in-target bash -c 'echo "#!/bin/bash" > /home/computerspende/echo_message.sh'; \
|
||||||
|
in-target bash -c 'echo "echo \"Hello, this is a message from late_command!\"" >> /home/computerspende/echo_message.sh'; \
|
||||||
|
in-target bash -c 'echo "read p" >> /home/computerspende/echo_message.sh '; \
|
||||||
|
in-target chmod +x /home/computerspende/post_hardware.sh; \
|
||||||
|
in-target bash -c 'mkdir -p /home/computerspende/.config/autostart'; \
|
||||||
|
in-target bash -c 'echo "[Desktop Entry]" > /home/computerspende/.config/autostart/post_hardware.desktop'; \
|
||||||
|
in-target bash -c 'echo "Type=Application" >> /home/computerspende/.config/autostart/post_hardware.desktop'; \
|
||||||
|
in-target bash -c 'echo "Terminal=true" >> /home/computerspende/.config/autostart/post_hardware.desktop'; \
|
||||||
|
in-target bash -c 'echo "Exec=gnome-terminal -- /home/computerspende/post_hardware.sh" >> /home/username/.config/autostart/post_hardware.desktop'; \
|
||||||
|
in-target bash -c 'echo "Name=Post Hardware Setup" >> /home/computerspende/.config/autostart/post_hardware.desktop'; \
|
||||||
|
in-target bash -c 'chown computerspende:computerspende /home/computerspende/post_hardware.sh'; \
|
||||||
|
in-target bash -c 'chown -R computerspende:computerspende /home/computerspende/.config'
|
||||||
|
|
||||||
34
scripts/generate_intarget.py
Normal file
34
scripts/generate_intarget.py
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
def convert_to_in_target(bash_script_path, target_username):
|
||||||
|
try:
|
||||||
|
with open(bash_script_path, 'r') as file:
|
||||||
|
lines = file.readlines()
|
||||||
|
|
||||||
|
in_target_commands = []
|
||||||
|
|
||||||
|
# Construct the script creation command
|
||||||
|
script_creation_cmd = f"in-target bash -c 'echo \"#!/bin/bash\" > /home/{target_username}/post_hardware.sh'"
|
||||||
|
in_target_commands.append(script_creation_cmd)
|
||||||
|
|
||||||
|
# Convert each script line into an in-target command
|
||||||
|
for line in lines:
|
||||||
|
# Strip the line to remove leading/trailing whitespace
|
||||||
|
stripped_line = line.strip()
|
||||||
|
if stripped_line: # Ignore empty lines
|
||||||
|
escaped_line = stripped_line.replace('"', '\\"').replace('$', '\\$')
|
||||||
|
cmd = f"in-target bash -c 'echo \"{escaped_line}\" >> /home/{target_username}/post_hardware.sh'"
|
||||||
|
in_target_commands.append(cmd)
|
||||||
|
|
||||||
|
# Add command to make the script executable
|
||||||
|
in_target_commands.append(f"in-target chmod +x /home/{target_username}/post_hardware.sh")
|
||||||
|
|
||||||
|
# Output the generated in-target commands
|
||||||
|
for command in in_target_commands:
|
||||||
|
print(command)
|
||||||
|
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("The specified bash script file does not exist.")
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
bash_script_path = 'post_hardware.sh' # Replace with the path to your bash script
|
||||||
|
target_username = 'computerspende' # Replace with the target user's username
|
||||||
|
convert_to_in_target(bash_script_path, target_username)
|
||||||
3
setup.sh
3
setup.sh
|
|
@ -3,7 +3,7 @@
|
||||||
# Change to the script's directory
|
# Change to the script's directory
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
ISO_URL="https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.9.0-amd64-netinst.iso"
|
ISO_URL="https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-12.9.0-amd64-DVD-1.iso"
|
||||||
IMAGE_DIR="images"
|
IMAGE_DIR="images"
|
||||||
ISO_NAME="$IMAGE_DIR/debian-server.iso"
|
ISO_NAME="$IMAGE_DIR/debian-server.iso"
|
||||||
SOURCE_DIR="source"
|
SOURCE_DIR="source"
|
||||||
|
|
@ -18,4 +18,3 @@ wget -O "$ISO_NAME" "$ISO_URL"
|
||||||
xorriso -osirrox on -indev "$ISO_NAME" -extract / "$SOURCE_DIR/"
|
xorriso -osirrox on -indev "$ISO_NAME" -extract / "$SOURCE_DIR/"
|
||||||
|
|
||||||
echo "Debian server ISO file downloaded to $IMAGE_DIR and extracted to $SOURCE_DIR"
|
echo "Debian server ISO file downloaded to $IMAGE_DIR and extracted to $SOURCE_DIR"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue