build-aci 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/bash
  2. # A non-installed actool can be used, for example:
  3. # ACTOOL=../../appc/spec/bin/actool
  4. ACTOOL=${ACTOOL:-actool}
  5. IMAGEDIR=${IMAGEDIR:-bin/image-aci}
  6. VERSION=$1
  7. if [ ! -x "$ACTOOL" ] ; then
  8. echo "actool ($ACTOOL) is not executable"
  9. exit 1
  10. fi
  11. if [ ! -x bin/etcd ] ; then
  12. echo "bin/etcd not found. Is it compiled?"
  13. exit 1
  14. fi
  15. if [ -z "$VERSION" ] ; then
  16. echo "Usage: scripts/build-aci VERSION"
  17. exit 1
  18. fi
  19. mkdir -p $IMAGEDIR/rootfs
  20. if [ ! -d $IMAGEDIR/rootfs -o ! -x $IMAGEDIR/rootfs ]; then
  21. echo "$IMAGEDIR/rootfs is not a writeable directory"
  22. exit 1
  23. fi
  24. if [ -n "$(ls -A $IMAGEDIR/rootfs)" ]; then
  25. echo "$IMAGEDIR/rootfs is not empty"
  26. exit 1
  27. fi
  28. cp bin/etcd bin/etcdctl $IMAGEDIR/rootfs/
  29. cp README.md $IMAGEDIR/rootfs/
  30. cp etcdctl/README.md $IMAGEDIR/rootfs/README-etcdctl.md
  31. cp -r Documentation $IMAGEDIR/rootfs/
  32. cat <<DF > $IMAGEDIR/manifest
  33. {
  34. "acVersion": "0.5.1",
  35. "acKind": "ImageManifest",
  36. "name": "coreos.com/etcd",
  37. "labels": [
  38. {"name": "os", "value": "linux"},
  39. {"name": "arch", "value": "amd64"},
  40. {"name": "version", "value": "${VERSION}"}
  41. ],
  42. "app": {
  43. "environment": [
  44. {
  45. "name": "ETCD_DATA_DIR",
  46. "value": "/data-dir"
  47. }
  48. ],
  49. "exec": [
  50. "/etcd"
  51. ],
  52. "user": "0",
  53. "group": "0",
  54. "mountPoints": [
  55. {
  56. "name": "data-dir",
  57. "path": "/data-dir"
  58. }
  59. ],
  60. "ports": [
  61. {
  62. "name": "legacy-client",
  63. "port": 4001,
  64. "protocol": "tcp"
  65. },
  66. {
  67. "name": "client",
  68. "port": 2379,
  69. "protocol": "tcp"
  70. },
  71. {
  72. "name": "legacy-peer",
  73. "port": 7001,
  74. "protocol": "tcp"
  75. },
  76. {
  77. "name": "peer",
  78. "port": 2380,
  79. "protocol": "tcp"
  80. }
  81. ]
  82. }
  83. }
  84. DF
  85. mkdir -p $IMAGEDIR/rootfs/etc/
  86. cat <<DF > $IMAGEDIR/rootfs/etc/hosts
  87. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  88. DF
  89. $ACTOOL build -overwrite=true $IMAGEDIR bin/etcd-${1}-linux-amd64.aci