| 1 | #!/bin/shscip-shell filesystem . . `/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 | failscip-shell shell shell-project 0.0.0 fail().() { |
| 12 | echoscip-shell system . . echo. "FAILED:" "$@" 1>&2 |
| 13 | exit 1 |
| 14 | } |
| 15 | |
| 16 | PYTHON="${PYTHON:-python3}" |
| 17 | if [scip-shell system . . `[`. ! $(whichscip-shell system . . which. ${PYTHON}) ]; then |
| 18 | echoscip-shell system . . echo. "Please install python first." |
| 19 | exit 1 |
| 20 | fi |
| 21 | |
| 22 | # Check dependencies: |
| 23 | depschecked=/tmp/c-i.dependenciescheckedscip-shell filesystem . . `/tmp/c-i.dependencieschecked`. |
| 24 | [scip-shell system . . `[`. -f "$depschecked" ] || ./tools/read-dependencies --distro freebsd -t || failscip-shell shell shell-project 0.0.0 fail(). "install packages" |
| 25 | touchscip-shell system . . touch. $depschecked |
| 26 | |
| 27 | # Build the code and install in /usr/local/: |
| 28 | mesonscip-shell system . . meson. setup builddir -Dinit_system=sysvinit_freebsd |
| 29 | mesonscip-shell system . . meson. install -C builddir |
| 30 | |
| 31 | echoscip-shell system . . echo. "Installation completed." |
| 32 | |
| 33 | if [scip-shell system . . `[`. "$#" -gt 1 ] && [scip-shell system . . `[`. "$1" = "run" ]; then |
| 34 | echoscip-shell system . . echo. "Ok, now let's see if it works." |
| 35 | |
| 36 | # Backup SSH keys |
| 37 | mvscip-shell system . . mv. /etc/ssh/ssh_host_* /tmp/scip-shell filesystem . . `/tmp/`. |
| 38 | |
| 39 | # Remove old metadata |
| 40 | rmscip-shell system . . rm. -rf /var/lib/cloudscip-shell filesystem . . `/var/lib/cloud`. |
| 41 | |
| 42 | # Just log everything, quick&dirty |
| 43 | rmscip-shell system . . rm. /usr/local/etc/cloud/cloud.cfg.d/05_logging.cfgscip-shell filesystem . . `/usr/local/etc/cloud/cloud.cfg.d/05_logging.cfg`. |
| 44 | |
| 45 | # Start: |
| 46 | /usr/local/etc/rc.d/cloudinitscip-shell filesystem . . `/usr/local/etc/rc.d/cloudinit`. start |
| 47 | |
| 48 | # Restore SSH keys |
| 49 | mvscip-shell system . . mv. /tmp/ssh_host_* /etc/ssh/scip-shell filesystem . . `/etc/ssh/`. |
| 50 | fi |