as documented in ubuntu bug bug 878600, starting the rabbitmq
daemon was keeping its output filehandle open, which caused the 'tee'
to never die, and an ssh connection to never close.
Change the over all flow so that the default settings are
filled in in the outside shell (not inside the '()' and 'tee').
This way, those variables pass through to the subshell, but they're
also available in the parent shell at the end for outputting status.
Also, exit failure rather than success if 'exec' to run as stack
user failed.
make the successful run output end with more clear messages.
By moving them outside of the "do it all" path, the xtrace output
will not mix with echo statements.
Previously, the only path that would only ensure that 'apt-get update'
was run was when the stack user was created.
Archives can be out of date, apt-get should be run.
* Increase the timeout from 3 to 10, so user has a bigger chance
to kill the script if being run interactively before a 'stack'
user is created.
* explicitly ask 'getent' for the stack user rather than getting
all users and grepping (which would match an "openstack" user,
or a user named "bob.stack")
* use $PWD rather than `pwd`
* create file in sudoers.d rather than modifying /etc/sudoers.
Bash contains a variable 'SECONDS' that indicates how long
the current shell has been alive. It seems sane to just use that
to indicate to the user how long the script took.
If stack.sh is run as root, it execs stack.sh as stack, but also
runs bash after doing so to provide a prompt as the stack user.
In unattended installations this isn't desired as it will prevent
the original job from completing.
This change adds a paremeter "SHELL_AFTER_RUN" which can be set
to "no" to prevent the final invocation of bash.