mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-30 09:13:29 +00:00
Merge pull request #344 from marcov/dracut-improvements
dracut: improve host distro support
This commit is contained in:
commit
987fe3067e
@ -401,8 +401,6 @@ prepare_overlay()
|
||||
# provided as argument
|
||||
setup_rootfs()
|
||||
{
|
||||
[ -z "$distro" ] && prepare_overlay
|
||||
|
||||
info "Create symlink to /tmp in /var to create private temporal directories with systemd"
|
||||
pushd "${ROOTFS_DIR}" >> /dev/null
|
||||
if [ "$PWD" != "/" ] ; then
|
||||
@ -448,14 +446,21 @@ EOT
|
||||
|
||||
[ -n "${KERNEL_MODULES_DIR}" ] && copy_kernel_modules ${KERNEL_MODULES_DIR} ${ROOTFS_DIR}
|
||||
|
||||
chrony_conf_file="${ROOTFS_DIR}/etc/chrony.conf"
|
||||
if [ "${distro}" == "ubuntu" ] || [ "${distro}" == "debian" ] ; then
|
||||
chrony_conf_file="${ROOTFS_DIR}/etc/chrony/chrony.conf"
|
||||
fi
|
||||
|
||||
info "Create ${ROOTFS_DIR}/etc"
|
||||
mkdir -p "${ROOTFS_DIR}/etc"
|
||||
|
||||
case "${distro}" in
|
||||
"ubuntu" | "debian")
|
||||
echo "I am ubuntu or debian"
|
||||
chrony_conf_file="${ROOTFS_DIR}/etc/chrony/chrony.conf"
|
||||
chrony_systemd_service="${ROOTFS_DIR}/lib/systemd/system/chrony.service"
|
||||
;;
|
||||
*)
|
||||
chrony_conf_file="${ROOTFS_DIR}/etc/chrony.conf"
|
||||
chrony_systemd_service="${ROOTFS_DIR}/usr/lib/systemd/system/chronyd.service"
|
||||
;;
|
||||
esac
|
||||
|
||||
info "Configure chrony file ${chrony_conf_file}"
|
||||
cat >> "${chrony_conf_file}" <<EOT
|
||||
refclock PHC /dev/ptp0 poll 3 dpoll -2 offset 0
|
||||
@ -468,11 +473,6 @@ EOT
|
||||
# Reference: https://chrony.tuxfamily.org/doc/3.4/chrony.conf.html
|
||||
sed -i 's/^\(server \|pool \|peer \)/# &/g' ${chrony_conf_file}
|
||||
|
||||
chrony_systemd_service="${ROOTFS_DIR}/usr/lib/systemd/system/chronyd.service"
|
||||
if [ ${distro} == ubuntu ] || [ ${distro} == debian ] ; then
|
||||
chrony_systemd_service="${ROOTFS_DIR}/lib/systemd/system/chrony.service"
|
||||
fi
|
||||
|
||||
if [ -f "$chrony_systemd_service" ]; then
|
||||
sed -i '/^\[Unit\]/a ConditionPathExists=\/dev\/ptp0' ${chrony_systemd_service}
|
||||
fi
|
||||
@ -533,6 +533,23 @@ parse_arguments()
|
||||
distro="$1"
|
||||
}
|
||||
|
||||
detect_host_distro()
|
||||
{
|
||||
source /etc/os-release
|
||||
|
||||
case "$ID" in
|
||||
"*suse*")
|
||||
distro="suse"
|
||||
;;
|
||||
"clear-linux-os")
|
||||
distro="clearlinux"
|
||||
;;
|
||||
*)
|
||||
distro="$ID"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
parse_arguments $*
|
||||
@ -544,6 +561,10 @@ main()
|
||||
else
|
||||
#Make sure ROOTFS_DIR is set correctly
|
||||
[ -d "${ROOTFS_DIR}" ] || die "Invalid rootfs directory: '$ROOTFS_DIR'"
|
||||
|
||||
# Set the distro for dracut build method
|
||||
detect_host_distro
|
||||
prepare_overlay
|
||||
fi
|
||||
|
||||
setup_rootfs
|
||||
|
Loading…
Reference in New Issue
Block a user