download.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. if [ "$(dpkg-query -W -f='${Status}' curl 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
  26. to_install+=("curl")
  27. fi
  28. if [ "$(dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then
  29. to_install+=("ca-certificates")
  30. fi
  31. if [ ${#to_install[@]} -ne 0 ]; then
  32. LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "${to_install[@]}"
  33. fi
  34. LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends openssl jq
  35. # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923479
  36. if [[ "${HOST_ARCH}" == 'arm' ]]; then
  37. LC_ALL=C DEBIAN_FRONTEND=noninteractive c_rehash
  38. fi
  39. echo "Download cfssl ..."
  40. echo "curl -o /usr/sbin/cfssl -SL https://github.com/osixia/cfssl/releases/download/1.5.0/cfssl_linux-${HOST_ARCH}"
  41. curl -o /usr/sbin/cfssl -SL "https://github.com/osixia/cfssl/releases/download/1.5.0/cfssl_linux-${HOST_ARCH}"
  42. chmod 700 /usr/sbin/cfssl
  43. echo "Download cfssljson ..."
  44. echo "curl -o /usr/sbin/cfssljson -SL https://github.com/osixia/cfssl/releases/download/1.5.0/cfssljson_linux-${HOST_ARCH}"
  45. curl -o /usr/sbin/cfssljson -SL "https://github.com/osixia/cfssl/releases/download/1.5.0/cfssljson_linux-${HOST_ARCH}"
  46. chmod 700 /usr/sbin/cfssljson
  47. echo "Project sources: https://github.com/cloudflare/cfssl"
  48. # remove tools installed to download cfssl
  49. if [ ${#to_install[@]} -ne 0 ]; then
  50. apt-get remove -y --purge --auto-remove "${to_install[@]}"
  51. fi