download.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash -e
  2. UARCH=$(uname -m)
  3. echo "Architecture is ${UARCH}"
  4. case "${UARCH}" in
  5. "x86_64")
  6. HOST_ARCH="amd64"
  7. ;;
  8. "arm64" | "aarch64")
  9. HOST_ARCH="arm64"
  10. ;;
  11. "armv7l" | "armv6l" | "armhf")
  12. HOST_ARCH="arm"
  13. ;;
  14. "i386")
  15. HOST_ARCH="386"
  16. ;;
  17. *)
  18. echo "Architecture not supported. Exiting."
  19. exit 1
  20. ;;
  21. esac
  22. echo "Going to use ${HOST_ARCH} cfssl binaries"
  23. # download curl and ca-certificate from apt-get if needed
  24. to_install=()
  25. apk info | grep -q curl || to_install+=("curl")
  26. apk info | grep -q ca-certificates || to_install+=("ca-certificates")
  27. if [ ${#to_install[@]} -ne 0 ]; then
  28. apk add $to_install
  29. fi
  30. apk add openssl jq
  31. echo "Download cfssl ..."
  32. echo "curl -o /usr/sbin/cfssl -SL https://github.com/osixia/cfssl/releases/download/1.5.0/cfssl_linux-${HOST_ARCH}"
  33. curl -o /usr/sbin/cfssl -SL "https://github.com/osixia/cfssl/releases/download/1.5.0/cfssl_linux-${HOST_ARCH}"
  34. chmod 700 /usr/sbin/cfssl
  35. echo "Download cfssljson ..."
  36. echo "curl -o /usr/sbin/cfssljson -SL https://github.com/osixia/cfssl/releases/download/1.5.0/cfssljson_linux-${HOST_ARCH}"
  37. curl -o /usr/sbin/cfssljson -SL "https://github.com/osixia/cfssl/releases/download/1.5.0/cfssljson_linux-${HOST_ARCH}"
  38. chmod 700 /usr/sbin/cfssljson
  39. echo "Project sources: https://github.com/cloudflare/cfssl"
  40. # remove tools installed to download cfssl
  41. if [ ${#to_install[@]} -ne 0 ]; then
  42. apk del --purge $to_install
  43. fi