Perform safety checks in create-stack-user.sh
This adds some safety checks to the stack user creation script. This includes: - Using set -o errexit to exit early on errors - Make sure STACK_USER is set before doing anything with it Change-Id: If027daddd03e32c5ba3c2ebb05ad5b27d2868b0a
This commit is contained in:
parent
535e0089e0
commit
010959de40
@ -15,6 +15,7 @@
|
||||
# and it was time for this nonsense to stop. Run this script as root to create
|
||||
# the user and configure sudo.
|
||||
|
||||
set -o errexit
|
||||
|
||||
# Keep track of the devstack directory
|
||||
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
|
||||
@ -27,12 +28,14 @@ source $TOP_DIR/functions
|
||||
# and ``DISTRO``
|
||||
GetDistro
|
||||
|
||||
# Needed to get ``ENABLED_SERVICES``
|
||||
# Needed to get ``ENABLED_SERVICES`` and ``STACK_USER``
|
||||
source $TOP_DIR/stackrc
|
||||
|
||||
# Give the non-root user the ability to run as **root** via ``sudo``
|
||||
is_package_installed sudo || install_package sudo
|
||||
|
||||
[[ -z "$STACK_USER" ]] && die "STACK_USER is not set. Exiting."
|
||||
|
||||
if ! getent group $STACK_USER >/dev/null; then
|
||||
echo "Creating a group called $STACK_USER"
|
||||
groupadd $STACK_USER
|
||||
|
Loading…
Reference in New Issue
Block a user