layout-initrd 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/bin/bash
  2. function cache_services() {
  3. local SERVICE_YMLFILE=$1
  4. local SERVICE_URL=${OS_SERVICES_REPO}/${REPO_VERSION}
  5. local SERVICE_INDEX_URL="${SERVICE_URL}/index.yml"
  6. local SERVICE_YMLFILE_URL="${SERVICE_URL}/${SERVICE_YMLFILE}"
  7. local SERVICE_INDEX_URL_MD5=$(echo -n ${SERVICE_INDEX_URL}|md5sum|cut -d ' ' -f1)
  8. local SERVICE_YMLFILE_URL_MD5=$(echo -n ${SERVICE_YMLFILE_URL}|md5sum|cut -d ' ' -f1)
  9. mkdir -p ${INITRD_DIR}/usr/share/ros/services-cache/
  10. wget -O ${INITRD_DIR}/usr/share/ros/services-cache/${SERVICE_INDEX_URL_MD5} ${SERVICE_INDEX_URL}
  11. wget -O ${INITRD_DIR}/usr/share/ros/services-cache/${SERVICE_YMLFILE_URL_MD5} ${SERVICE_YMLFILE_URL}
  12. }
  13. echo Create initrd layout in $INITRD_DIR
  14. rm -rf ${INITRD_DIR}
  15. mkdir -p ${INITRD_DIR}/usr/{etc,lib,bin,share/ros}
  16. ./scripts/template
  17. cp -rf assets/selinux ${INITRD_DIR}/usr/etc
  18. cp build/images*.tar ${INITRD_DIR}/usr/share/ros/
  19. cp bin/ros ${INITRD_DIR}/usr/bin/
  20. ln -s usr/bin/ros ${INITRD_DIR}/init
  21. ln -s bin ${INITRD_DIR}/usr/sbin
  22. ln -s usr/sbin ${INITRD_DIR}/sbin
  23. curl -SL ${!SYSTEM_DOCKER_URL} | tar --strip-components=1 -xzvf - -C ${INITRD_DIR}/usr/bin/
  24. # we have diabled the user-proxy so we get rid of system-docker-proxy
  25. rm -f ${INITRD_DIR}/usr/bin/system-docker-proxy
  26. cat <<HERE > ${INITRD_DIR}/usr/share/ros/os-release
  27. NAME="RancherOS"
  28. VERSION=${VERSION}
  29. ID=rancheros
  30. ID_LIKE=
  31. VERSION_ID=${VERSION}
  32. PRETTY_NAME="RancherOS ${VERSION}"
  33. HOME_URL="http://rancher.com/rancher-os/"
  34. SUPPORT_URL="https://forums.rancher.com/c/rancher-os"
  35. BUG_REPORT_URL="https://github.com/rancher/os/issues"
  36. BUILD_ID=
  37. HERE
  38. # cache os-services yml file
  39. for file in $(ls .make-*); do
  40. case $file in
  41. ".make-vmware")
  42. cache_services "o/open-vm-tools.yml"
  43. ;;
  44. ".make-4glte")
  45. cache_services "m/modem-manager.yml"
  46. ;;
  47. ".make-pingan")
  48. cache_services "p/pingan-amc.yml"
  49. ;;
  50. ".make-hyperv")
  51. cache_services "h/hyperv-vm-tools.yml"
  52. ;;
  53. ".make-azure")
  54. cache_services "h/hyperv-vm-tools.yml"
  55. cache_services "w/waagent.yml"
  56. ;;
  57. ".make-proxmoxve")
  58. cache_services "q/qemu-guest-agent.yml"
  59. ;;
  60. esac
  61. done
  62. case ${OS_CONSOLE} in
  63. "alpine")
  64. cache_services "a/alpine.yml"
  65. ;;
  66. "centos")
  67. cache_services "c/centos.yml"
  68. ;;
  69. "debian")
  70. cache_services "d/debian.yml"
  71. ;;
  72. "fedora")
  73. cache_services "f/fedora.yml"
  74. ;;
  75. "ubuntu")
  76. cache_services "u/ubuntu.yml"
  77. ;;
  78. esac
  79. pushd ${INITRD_DIR}/usr/etc
  80. ln -s ../share/ros/os-release .
  81. popd
  82. # Support upgrades from old persistent consoles that bind mount these
  83. touch ${INITRD_DIR}/usr/bin/docker-containerd
  84. touch ${INITRD_DIR}/usr/bin/docker-containerd-shim
  85. touch ${INITRD_DIR}/usr/bin/docker
  86. if [ -e ${DOWNLOADS}/policy.29 ]; then
  87. mkdir -p ${INITRD_DIR}/usr/etc/selinux/ros/policy/
  88. cp ${DOWNLOADS}/policy.29 ${INITRD_DIR}/usr/etc/selinux/ros/policy/
  89. fi
  90. # make rancher/os-initrd image
  91. cat <<HERE > ${INITRD_DIR}/../Dockerfile.initrd
  92. FROM scratch
  93. COPY initrd/* /
  94. HERE
  95. name="os-initrd"
  96. tag="${OS_REPO}/${name}:${VERSION}${SUFFIX}"
  97. pushd .
  98. cd ${INITRD_DIR}/..
  99. docker build -t ${OS_REPO}/${name} -f Dockerfile.initrd .
  100. docker tag rancher/${name} ${tag}
  101. popd