Addressng chsh fail due to /etc/passwd permissions

Since maas containers are running as non-privileged,
the maas root user might not be able to get lock on
the host's /etc/paasword to change shell for the maas
user. Added retry/sleep to eventually get the lock and
make the shell update for the user.
Also, using usermod instead of chsh.

Change-Id: Iaba6276bd6d54b22980aef8c6f7c5c113d0f2fff
This commit is contained in:
Ahmad Mahmoudi 2019-05-21 10:08:09 -05:00
parent 290bbf1adc
commit d11fa44221
1 changed files with 17 additions and 2 deletions

View File

@ -36,6 +36,21 @@ then
chmod 600 ~maas/.ssh/*
fi
chsh -s /bin/bash maas
set +e
sh_set=false
for (( c=0; c<=10; c++ )); do
if chsh -s /bin/bash maas; then
sh_set=true
break
elif usermod -s /bin/bash maas; then
sh_set=true
break
else
sleep 2
fi
done
if [[ $sh_set = false ]]; then
exit 1
fi
set -e
exec /sbin/init --log-target=console 3>&1