host.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. #
  3. # This script will make a shell script that can be used as a cloud-init style user data script
  4. # or run as root from a debian/ubuntu DigitalOcean VM to replace that distribution with
  5. # RancherOS
  6. #
  7. # Its intended to be used for development, but can easily be modified to be more generally
  8. # useful - make a Pull Request :)
  9. #
  10. # Note: this script will run caddy in your os/dist/artifacts/ directory, so don't leave it
  11. # running unsupervised.
  12. DIST="../../../dist/artifacts"
  13. command -v caddy >/dev/null 2>&1 || { echo >&2 "I require caddy but it's not installed, see https://github.com/mholt/caddy#quick-start . Aborting."; exit 1; }
  14. if [[ -e "dist/artifacts" ]]; then
  15. cd scripts/hosting/digitalocean
  16. fi
  17. if [[ ! -e "$DIST" ]]; then
  18. echo "Need to 'make release' so that there are files to serve. Aborting."
  19. exit 1
  20. fi
  21. source ${DIST}/../../scripts/version
  22. VMLINUX=$(ls -1 ${DIST}/ | grep "^vmlinuz-" | head -n1)
  23. INITRD="initrd-${VERSION}"
  24. IP=$(curl ipinfo.io/ip)
  25. PORT=2115
  26. #SOURCECONFIG="cloud-config.yml"
  27. SOURCECONFIG="fedora-symbiote.yml"
  28. CLOUDCONFIG="digitalocean.sh"
  29. cat ${SOURCECONFIG} \
  30. | sed "s|^URL_BASE.*$|URL_BASE=http://${IP}:${PORT}|g" \
  31. | sed "s|^VMLINUX.*$|VMLINUX=${VMLINUX}|g" \
  32. | sed "s|^INITRD.*$|INITRD=${INITRD}|g" \
  33. > ${DIST}/${CLOUDCONFIG}
  34. echo "Hosting a cloud-config script at http://${IP}:${PORT}/${CLOUDCONFIG}"
  35. echo "Usage:"
  36. echo
  37. echo "#include"
  38. echo "http://${IP}:${PORT}/${CLOUDCONFIG}"
  39. echo
  40. echo
  41. cd ${DIST}
  42. caddy -log stdout -port ${PORT}