startup.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. # Load configuration
  3. [ -f ./config.sh ] && source 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. Start docker and libvird
  16. # Those services should have been disabled
  17. # systemctl disable docker libvirtd libvirt-guests
  18. systemctl start docker &
  19. sleep 2 && systemctl status --no-pager docker
  20. systemctl start libvirtd &
  21. sleep 2 && systemctl status --no-pager libvirtd
  22. systemctl start libvirt-guests &
  23. sleep 2 && systemctl status --no-pager libvirt-guests
  24. # 4. Fix forward chain which was set to default deny by docker
  25. # so our KVM containers on br0 have access to the network
  26. iptables -v -A FORWARD -i br0 -o br0 -j ACCEPT