NoPaste

chroot.sh

von ren22
Beschreibung:
debootstrap chroot script
Snippet erstellt:
16.02.2019 14:17:27
Snippet wird automatisch gelöscht:
Niemals

Dein Code:
  1. #!/bin/bash
  2.  
  3. DEVICE="/dev/sdc"
  4.  
  5. # set TERMl variable
  6. export TERM=xterm-color
  7.  
  8. # get up-to-date
  9. apt update
  10.  
  11. # create device files
  12. apt install -y makedev
  13. cd /dev
  14. echo "creating device files..."
  15. MAKEDEV generic
  16.  
  17. # install additional packages
  18. apt upgrade -y
  19. DEBIAN_FRONTEND=noninteractive apt install -y systemd systemd-sysv linux-base xen-system-amd64 xen-utils-4.8 \
  20. xen-tools linux-headers-amd64 grub-pc console-data console-common tzdata locales keyboard-configuration cryptsetup \
  21. lvm2 initramfs-tools openssh-server busybox dropbear net-tools
  22.  
  23. # set root password
  24. echo "Enter root password"
  25. passwd
  26.  
  27. # reconfigure locales
  28. echo 'LC_ALL=de_DE.UTF-8' >> /etc/default/locale
  29. sed -i '/de_DE.UTF-8/s/^#//' /etc/locale.gen
  30. locale-gen de_DE.UTF-8
  31. update-locale LANG=de_DE.UTF-8
  32.  
  33. #dpkg-reconfigure locales
  34.  
  35. # configure timezone
  36. #dpkg-reconfigure tzdata
  37. #dpkg-reconfigure tzdata console-data console-common keyboard-configuration
  38.  
  39. # ssh copy pub key
  40. # TODO
  41.  
  42. # your device name may be different
  43. cat > /etc/network/interfaces << EOF
  44. # This file describes the network interfaces available on your system
  45. # and how to activate them. For more information, see interfaces(5).
  46.  
  47. source /etc/network/interfaces.d/*
  48.  
  49. # The loopback network interface
  50. auto lo
  51. iface lo inet loopback
  52.  
  53. # The primary network interface
  54. allow-hotplug enp2s0
  55. iface enp2s0 inet static
  56.         address 192.168.123.123/24
  57.         gateway 192.168.123.254
  58.         # dns-* options are implemented by the resolvconf package, if installed
  59.         dns-nameservers 192.168.123.254
  60. EOF
  61.  
  62. #dpkg-reconfigure grub-pc
  63.  
  64. # install grub boot manager
  65. #grub-install "$DEVICE"
  66. #grub-install --no-floppy --root-directory=/mnt/debinst $DEVICE
  67.  
  68. # build grub device.map
  69. #grub-mkdevicemap --no-floppy
  70.  
  71. # generate grub.cfg
  72. #grub-mkconfig -o /boot/grub/grub.cfg
  73.  
  74. # built init ramfs
  75. update-initramfs -u -k all
  76.  
  77. update-grub
  78. # clean up apt
  79. apt-get clean
  80.  
  81. # exit the chroot
  82. exit

Quellcode

Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. Alternativ kannst du den gesamten Eintrag auch als Datei herunterladen.