Remove DEFAULT_STACK_USER, just use STACK_USER

STACK_USER needs to be set for more than just stack.sh, there
was no real distinction for using DEFAULT_STACK_USER instead
of just setting STACK_USER directly in stackrc and allowing it
to be overridden in localrc.

Change-Id: I9e8d70db29bb421f1ce3dbf40a5ad299cc7ea785
This commit is contained in:
Dean Troyer 2013-01-24 14:19:55 -06:00
parent 3b3a6d78a6
commit 74759aa17a
6 changed files with 23 additions and 21 deletions

View File

@ -160,7 +160,6 @@ VERBOSE=$(trueorfalse True $VERBOSE)
# sudo privileges and runs as that user.
if [[ $EUID -eq 0 ]]; then
STACK_USER=$DEFAULT_STACK_USER
ROOTSLEEP=${ROOTSLEEP:-10}
echo "You are running this script as root."
echo "In $ROOTSLEEP seconds, we will create a user '$STACK_USER' and run as that user"
@ -196,7 +195,6 @@ if [[ $EUID -eq 0 ]]; then
fi
exit 1
else
STACK_USER=`whoami`
# We're not **root**, make sure ``sudo`` is available
is_package_installed sudo || die "Sudo is required. Re-run stack.sh as root ONE TIME ONLY to set up sudo."
@ -1291,7 +1289,7 @@ fi
CURRENT_RUN_TIME=$(date "+$TIMESTAMP_FORMAT")
echo "# $CURRENT_RUN_TIME" >$TOP_DIR/.stackenv
for i in BASE_SQL_CONN ENABLED_SERVICES HOST_IP LOGFILE \
SERVICE_HOST SERVICE_PROTOCOL TLS_IP; do
SERVICE_HOST SERVICE_PROTOCOL STACK_USER TLS_IP; do
echo $i=${!i} >>$TOP_DIR/.stackenv
done

View File

@ -12,8 +12,12 @@ DATA_DIR=${DEST}/data
# Select the default database
DATABASE_TYPE=mysql
# Default stack user
DEFAULT_STACK_USER=stack
# Determine stack user
if [[ $EUID -eq 0 ]]; then
STACK_USER=stack
else
STACK_USER=$(whoami)
fi
# Specify which services to launch. These generally correspond to
# screen tabs. To change the default list, use the ``enable_service`` and

View File

@ -125,17 +125,17 @@ if [ ! -r $DEV_FILE ]; then
# Create a stack user that is a member of the libvirtd group so that stack
# is able to interact with libvirt.
chroot $MNTDIR groupadd libvirtd
chroot $MNTDIR useradd $DEFAULT_STACK_USER -s /bin/bash -d $DEST -G libvirtd
chroot $MNTDIR useradd $STACK_USER -s /bin/bash -d $DEST -G libvirtd
mkdir -p $MNTDIR/$DEST
chroot $MNTDIR chown $DEFAULT_STACK_USER $DEST
chroot $MNTDIR chown $STACK_USER $DEST
# A simple password - pass
echo $DEFAULT_STACK_USER:pass | chroot $MNTDIR chpasswd
echo $STACK_USER:pass | chroot $MNTDIR chpasswd
echo root:$ROOT_PASSWORD | chroot $MNTDIR chpasswd
# And has sudo ability (in the future this should be limited to only what
# stack requires)
echo "$DEFAULT_STACK_USER ALL=(ALL) NOPASSWD: ALL" >> $MNTDIR/etc/sudoers
echo "$STACK_USER ALL=(ALL) NOPASSWD: ALL" >> $MNTDIR/etc/sudoers
umount $MNTDIR
rmdir $MNTDIR
@ -187,7 +187,7 @@ git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
# Use this version of devstack
rm -rf $MNTDIR/$DEST/devstack
cp -pr $CWD $MNTDIR/$DEST/devstack
chroot $MNTDIR chown -R $DEFAULT_STACK_USER $DEST/devstack
chroot $MNTDIR chown -R $STACK_USER $DEST/devstack
# Configure host network for DHCP
mkdir -p $MNTDIR/etc/network
@ -225,7 +225,7 @@ EOF
# Make the run.sh executable
chmod 755 $RUN_SH
chroot $MNTDIR chown $DEFAULT_STACK_USER $DEST/run.sh
chroot $MNTDIR chown $STACK_USER $DEST/run.sh
umount $MNTDIR
rmdir $MNTDIR

View File

@ -207,11 +207,11 @@ ROOTSLEEP=0
`cat $TOP_DIR/localrc`
LOCAL_EOF
fi
useradd -U -G sudo -s /bin/bash -d /opt/stack -m $DEFAULT_STACK_USER
echo $DEFAULT_STACK_USER:pass | chpasswd
useradd -U -G sudo -s /bin/bash -d /opt/stack -m $STACK_USER
echo $STACK_USER:pass | chpasswd
mkdir -p /opt/stack/.ssh
echo "$PUB_KEY" > /opt/stack/.ssh/authorized_keys
chown -R $DEFAULT_STACK_USER /opt/stack
chown -R $STACK_USER /opt/stack
chmod 700 /opt/stack/.ssh
chmod 600 /opt/stack/.ssh/authorized_keys
@ -224,7 +224,7 @@ fi
# Run stack.sh
cat >> $vm_dir/uec/user-data<<EOF
sudo -u $DEFAULT_STACK_USER bash -l -c "cd /opt/stack/devstack && ./stack.sh"
sudo -u $STACK_USER bash -l -c "cd /opt/stack/devstack && ./stack.sh"
EOF
# (re)start a metadata service

View File

@ -46,13 +46,13 @@ mkdir -p $STAGING_DIR/$DEST
# Create a stack user that is a member of the libvirtd group so that stack
# is able to interact with libvirt.
chroot $STAGING_DIR groupadd libvirtd || true
chroot $STAGING_DIR useradd $DEFAULT_STACK_USER -s /bin/bash -d $DEST -G libvirtd || true
chroot $STAGING_DIR useradd $STACK_USER -s /bin/bash -d $DEST -G libvirtd || true
# Add a simple password - pass
echo $DEFAULT_STACK_USER:pass | chroot $STAGING_DIR chpasswd
echo $STACK_USER:pass | chroot $STAGING_DIR chpasswd
# Configure sudo
( umask 226 && echo "$DEFAULT_STACK_USER ALL=(ALL) NOPASSWD:ALL" \
( umask 226 && echo "$STACK_USER ALL=(ALL) NOPASSWD:ALL" \
> $STAGING_DIR/etc/sudoers.d/50_stack_sh )
# Copy over your ssh keys and env if desired
@ -67,7 +67,7 @@ rm -rf $STAGING_DIR/$DEST/devstack
cp_it . $STAGING_DIR/$DEST/devstack
# Give stack ownership over $DEST so it may do the work needed
chroot $STAGING_DIR chown -R $DEFAULT_STACK_USER $DEST
chroot $STAGING_DIR chown -R $STACK_USER $DEST
# Unmount
umount $STAGING_DIR

View File

@ -65,8 +65,8 @@ cd $TOP_DIR
cat <<EOF >$STAGING_DIR/etc/rc.local
# network restart required for getting the right gateway
/etc/init.d/networking restart
chown -R $DEFAULT_STACK_USER /opt/stack
su -c "/opt/stack/run.sh > /opt/stack/run.sh.log" $DEFAULT_STACK_USER
chown -R $STACK_USER /opt/stack
su -c "/opt/stack/run.sh > /opt/stack/run.sh.log" $STACK_USER
exit 0
EOF