From bccea6d5f02370b40380cf0a63ae2a69636d6671 Mon Sep 17 00:00:00 2001 From: Maksim Malchuk Date: Fri, 15 Sep 2023 17:40:36 +0300 Subject: [PATCH] Refactor cloud-init element There is no need in pipe and sudo for changing /etc/cloud/cloud.cfg TrivialFix Change-Id: I905e8d3964f1322ec3ccc2eb09c517a02ef88044 Signed-off-by: Maksim Malchuk --- .../post-install.d/21-cloud-init-allow-password-auth | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diskimage_builder/elements/cloud-init/post-install.d/21-cloud-init-allow-password-auth b/diskimage_builder/elements/cloud-init/post-install.d/21-cloud-init-allow-password-auth index 643653e2..564cdbf4 100755 --- a/diskimage_builder/elements/cloud-init/post-install.d/21-cloud-init-allow-password-auth +++ b/diskimage_builder/elements/cloud-init/post-install.d/21-cloud-init-allow-password-auth @@ -9,9 +9,9 @@ set -o pipefail # Set cloud-init to allow password authentication if [ -n "${DIB_CLOUD_INIT_ALLOW_SSH_PWAUTH:-}" ]; then if [ -f "/etc/cloud/cloud.cfg" ]; then - if [ -z "$(cat /etc/cloud/cloud.cfg | grep ssh_pwauth)" ]; then + if [ -z "$(grep ssh_pwauth /etc/cloud/cloud.cfg)" ]; then echo "ssh_pwauth not exist. append to EOF" - sudo sh -c 'echo "ssh_pwauth: 1" >> /etc/cloud/cloud.cfg' + echo "ssh_pwauth: 1" >> /etc/cloud/cloud.cfg else echo "ssh_pwauth exist. make sure ssh_pwauth enabled" sed -i -e 's/ssh_pwauth: *0/ssh_pwauth: 1/g' /etc/cloud/cloud.cfg