layout-initrd 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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-hyperv")
  48. cache_services "h/hyperv-vm-tools.yml"
  49. ;;
  50. ".make-azure")
  51. cache_services "h/hyperv-vm-tools.yml"
  52. cache_services "w/waagent.yml"
  53. ;;
  54. ".make-proxmoxve")
  55. cache_services "q/qemu-guest-agent.yml"
  56. ;;
  57. esac
  58. done
  59. case ${OS_CONSOLE} in
  60. "alpine")
  61. cache_services "a/alpine.yml"
  62. ;;
  63. "centos")
  64. cache_services "c/centos.yml"
  65. ;;
  66. "debian")
  67. cache_services "d/debian.yml"
  68. ;;
  69. "fedora")
  70. cache_services "f/fedora.yml"
  71. ;;
  72. "ubuntu")
  73. cache_services "u/ubuntu.yml"
  74. ;;
  75. esac
  76. # TODO: usr/lib dir is overwritten by the kernel modules and firmware
  77. ln -s ${INITRD_DIR}/usr/share/ros/os-release ${INITRD_DIR}/usr/lib/
  78. ln -s ${INITRD_DIR}/usr/share/ros/os-release ${INITRD_DIR}/usr/etc/
  79. # Support upgrades from old persistent consoles that bind mount these
  80. touch ${INITRD_DIR}/usr/bin/docker-containerd
  81. touch ${INITRD_DIR}/usr/bin/docker-containerd-shim
  82. touch ${INITRD_DIR}/usr/bin/docker
  83. if [ -e ${DOWNLOADS}/policy.29 ]; then
  84. mkdir -p ${INITRD_DIR}/usr/etc/selinux/ros/policy/
  85. cp ${DOWNLOADS}/policy.29 ${INITRD_DIR}/usr/etc/selinux/ros/policy/
  86. fi
  87. # make rancher/os-initrd image
  88. cat <<HERE > ${INITRD_DIR}/../Dockerfile.initrd
  89. FROM scratch
  90. COPY initrd/* /
  91. HERE
  92. name="os-initrd"
  93. tag="${OS_REPO}/${name}:${VERSION}${SUFFIX}"
  94. pushd .
  95. cd ${INITRD_DIR}/..
  96. docker build -t ${OS_REPO}/${name} -f Dockerfile.initrd .
  97. docker tag rancher/${name} ${tag}
  98. popd