Merge "Refactor cloud-init element"

This commit is contained in:
Zuul 2023-09-20 23:09:32 +00:00 committed by Gerrit Code Review
commit 4c4bb801ae
1 changed files with 2 additions and 2 deletions

View File

@ -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