| 1 | #!/bin/sh |
| 2 | # The official way to install cloud-init on FreeBSD is via the net/cloud-init |
| 3 | # port or the (appropriately py-flavoured) package. |
| 4 | # This script provides a communication medium between the cloud-init maintainers |
| 5 | # and the cloud-init port maintainers as to what dependencies have changed. |
| 6 | # It also provides a quick and dirty way of building and installing, and will |
| 7 | # optionally make a first run at the end. |
| 8 | |
| 9 | set -eux |
| 10 | |
| 11 | fail() { |
| 12 | echo "FAILED:" "$@" 1>&2 |
| 13 | exit 1 |
| 14 | } |
| 15 | |
| 16 | PYTHON="${PYTHON:-python3}" |
| 17 | if [ ! $(which ${PYTHON}) ]; then |
| 18 | echo "Please install python first." |
| 19 | exit 1 |
| 20 | fi |
| 21 | |
| 22 | # Check dependencies: |
| 23 | depschecked=/tmp/c-i.dependencieschecked |
| 24 | [ -f "$depschecked" ] || ./tools/read-dependencies --distro freebsd -t || fail "install packages" |
| 25 | touch $depschecked |
| 26 | |
| 27 | # Build the code and install in /usr/local/: |
| 28 | meson setup builddir -Dinit_system=sysvinit_freebsd |
| 29 | meson install -C builddir |
| 30 | |
| 31 | echo "Installation completed." |
| 32 | |
| 33 | if [ "$#" -gt 1 ] && [ "$1" = "run" ]; then |
| 34 | echo "Ok, now let's see if it works." |
| 35 | |
| 36 | # Backup SSH keys |
| 37 | mv /etc/ssh/ssh_host_* /tmp/ |
| 38 | |
| 39 | # Remove old metadata |
| 40 | rm -rf /var/lib/cloud |
| 41 | |
| 42 | # Just log everything, quick&dirty |
| 43 | rm /usr/local/etc/cloud/cloud.cfg.d/05_logging.cfg |
| 44 | |
| 45 | # Start: |
| 46 | /usr/local/etc/rc.d/cloudinit start |
| 47 | |
| 48 | # Restore SSH keys |
| 49 | mv /tmp/ssh_host_* /etc/ssh/ |
| 50 | fi |