Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions tools/create-stack-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,40 @@
# and it was time for this nonsense to stop. Run this script as root to create
# the user and configure sudo.

set -e

# Keep track of the devstack directory
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)

# Import common functions
source $TOP_DIR/functions
if [[ -e $TOP_DIR/functions ]]; then
source $TOP_DIR/functions
else
echo "Could not source $TOP_DIR/functions. Exiting."
exit 1
fi

# Determine what system we are running on. This provides ``os_VENDOR``,
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
# and ``DISTRO``
GetDistro

# Needed to get ``ENABLED_SERVICES``
source $TOP_DIR/stackrc
# Needed to get ``ENABLED_SERVICES`` and ``STACK_USER``
if [[ -e $TOP_DIR/stackrc ]]; then
source $TOP_DIR/stackrc
else
echo "Could not source $TOP_DIR/stackrc. Exiting."
exit 1
fi

# Give the non-root user the ability to run as **root** via ``sudo``
is_package_installed sudo || install_package sudo

if [[ -z "$STACK_USER" ]]; then
echo "STACK_USER is not set. Exiting."
exit 1
fi

if ! getent group $STACK_USER >/dev/null; then
echo "Creating a group called $STACK_USER"
groupadd $STACK_USER
Expand Down