startup.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. # 1. Open LUKS devices and sets up a mapping under /dev/mapper/
  3. cryptsetup luksOpen /dev/sda guests
  4. cryptsetup luksOpen /dev/sdb magnetic
  5. echo "Device mappings:" `find /dev/mapper/ -type l`
  6. # 2. Mount LUKS volumes
  7. mount --verbose /dev/mapper/guests /srv/guests
  8. mount --verbose /dev/mapper/magnetic /srv/magnetic
  9. # 3. Create a bind-mounts so we are not on the unecryped root volume
  10. mount --verbose --bind /srv/guests/lib/docker /var/lib/docker
  11. mount --verbose --bind /srv/guests/docker /opt/docker
  12. mount --verbose --bind /srv/guests/lib/libvirt /var/lib/libvirt
  13. mount --verbose --bind /srv/guests/etc/libvirt /etc/libvirt
  14. # 4. Start docker and libvird
  15. # Those services should have been disabled
  16. # systemctl disable docker libvirtd libvirt-guests
  17. systemctl start docker &
  18. sleep 2 && systemctl status --no-pager docker
  19. systemctl start libvirtd &
  20. sleep 2 && systemctl status --no-pager libvirtd
  21. systemctl start libvirt-guests &
  22. sleep 2 && systemctl status --no-pager libvirt-guests
  23. # 4. Fix forward chain which was set to default deny by docker
  24. # so our KVM containers on br0 have access to the network
  25. iptables -v -A FORWARD -i br0 -o br0 -j ACCEPT
  26. # Start docker containers
  27. # docker-compose --file /opt/docker/proxy/docker-compose.yml up --detach reverse-proxy