Comment 3 for bug 2004543

Revision history for this message
Jeff Lane  (bladernr) wrote (last edit ):

whoami won't work since the script has to be run via sudo:

bladernr@galactica:~/development/maas-cert-server$ whoami
bladernr
bladernr@galactica:~/development/maas-cert-server$ sudo whoami
root

And in fact, we actually use whoami earlier in the script to ensure we're running as root:
1166 if [ `whoami` != "root" ] ; then
1167 echo "This script must be run via sudo. Exiting!"
1168 exit 1
1169 fi

I think though, that before this can be really resolved, we need to know why it happened in the first place:

1: why does uid 1000 not exist, when that is the default uid for pretty much any Ubuntu installatiuon I've seen (via either MAAS or ISO)
2: If uid 1000 isnt' the default, then what is?

The DEFAULT_USER is used to set up the maas admin account, and set up SSH keys for the default user (which means that user should have a shell...)

Another idea would be "if 'ubuntu' exists as a user, use THAT UID whatever it is, and if not, then create the ubuntu user from scratch and use the newly created user UID."

Or just create a maasadmin account on the server by default, and a corresponding maasadmin user in MAAS...

But the simplest may be to switch just to using logname instead which DOES get the man username when sudo is used:

bladernr@galactica:~/development/maas-cert-server$ logname
bladernr
bladernr@galactica:~/development/maas-cert-server$ sudo logname
bladernr
bladernr@galactica:~/development/maas-cert-server$ sudo whoami
root