You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

docker-build.sh 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env bash
  2. # fail on error
  3. set -e
  4. # Retry 5 times with a wait of 10 seconds between each retry
  5. tryfail() {
  6. for i in $(seq 1 5);
  7. do [ $i -gt 1 ] && sleep 10; $* && s=0 && break || s=$?; done;
  8. (exit $s)
  9. }
  10. # Try multiple keyservers in case of failure
  11. addKey() {
  12. for server in $(shuf -e ha.pool.sks-keyservers.net \
  13. hkp://p80.pool.sks-keyservers.net:80 \
  14. keyserver.ubuntu.com \
  15. hkp://keyserver.ubuntu.com:80 \
  16. pgp.mit.edu) ; do \
  17. if apt-key adv --keyserver "$server" --recv "$1"; then
  18. exit 0
  19. fi
  20. done
  21. return 1
  22. }
  23. if [ "x${1}" == "x" ]; then
  24. echo please pass PKGURL as an environment variable
  25. exit 0
  26. fi
  27. apt-get update
  28. apt-get install -qy --no-install-recommends \
  29. apt-transport-https \
  30. curl \
  31. openjdk-8-jre-headless \
  32. procps \
  33. libcap2-bin
  34. tryfail apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
  35. echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list
  36. apt-get update
  37. echo "deb http://www.ubnt.com/downloads/unifi/debian unifi5 ubiquiti" > /etc/apt/sources.list.d/20ubiquiti.list
  38. tryfail apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv C0A52C50
  39. curl -L -o ./unifi.deb "${1}"
  40. apt -qy install mongodb-org ./unifi.deb
  41. rm -f ./unifi.deb
  42. chown -R unifi:unifi /usr/lib/unifi
  43. rm -rf /var/lib/apt/lists/*
  44. rm -rf ${ODATADIR} ${OLOGDIR}
  45. mkdir -p ${DATADIR} ${LOGDIR}
  46. ln -s ${DATADIR} ${BASEDIR}/data
  47. ln -s ${RUNDIR} ${BASEDIR}/run
  48. ln -s ${LOGDIR} ${BASEDIR}/logs
  49. rm -rf {$ODATADIR} ${OLOGDIR}
  50. ln -s ${DATADIR} ${ODATADIR}
  51. ln -s ${LOGDIR} ${OLOGDIR}
  52. mkdir -p /var/cert ${CERTDIR}
  53. ln -s ${CERTDIR} /var/cert/unifi
  54. rm -rf "${0}"