startup.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash -e
  2. # Load configuration
  3. [ -f /installer/config.sh ] && source /installer/config.sh
  4. disk2=$disk"p3"
  5. # 1. Open LUKS devices and sets up a mapping under /dev/mapper/
  6. cryptsetup luksOpen $disk2 data
  7. echo "Device mappings:" `find /dev/mapper/ -type l`
  8. # 2. Mount LUKS volumes
  9. mount --verbose /dev/mapper/data /srv/data
  10. # 3. Create a bind-mounts so we are not on the unecryped root volume
  11. mount --verbose --bind /srv/data/guests/lib/docker /var/lib/docker
  12. mount --verbose --bind /srv/data/guests/docker /opt/docker
  13. mount --verbose --bind /srv/data/guests/lib/libvirt /var/lib/libvirt
  14. mount --verbose --bind /srv/data/guests/etc/libvirt /etc/libvirt
  15. # 4. Fix forward chain which was set to default deny by docker
  16. # so our KVM containers on br0 have access to the network
  17. iptables -v -A FORWARD -i br0 -o br0 -j ACCEPT
  18. sleep 5 # wait a bit to make sure the data volume is ready
  19. # 4. Start libvirt and docker
  20. # Those services should have been disabled
  21. # systemctl disable docker libvirtd libvirt-guests
  22. echo start libvirt
  23. systemctl start libvirtd && sleep 2 && systemctl status --no-pager libvirtd
  24. echo start libvirt-guests
  25. systemctl start libvirt-guests && sleep 2 && systemctl status --no-pager libvirt-guests
  26. echo start docker
  27. systemctl start docker && sleep 2 && systemctl status --no-pager docker