Skip to content

Commit 33cb430

Browse files
author
Dean Troyer
committedDec 12, 2012
Write selected env variables to .stackenv
There are some environment variables that are derived in stack.sh and cubersome to re-create later, so save them at the end of stack.sh for use by other supporting scripts, such as openrc. Change-Id: I1bbf717b970f8ceac0ff7da74aeaf19474997e07
1 parent 60ffc61 commit 33cb430

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

‎openrc

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ source $RC_DIR/functions
2626
# Load local configuration
2727
source $RC_DIR/stackrc
2828

29+
# Load the last env variables if available
30+
if [[ -r $TOP_DIR/.stackenv ]]; then
31+
source $TOP_DIR/.stackenv
32+
fi
33+
2934
# Get some necessary configuration
3035
source $RC_DIR/lib/tls
3136

‎stack.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ DEST=${DEST:-/opt/stack}
9090
# Sanity Check
9191
# ============
9292

93+
# Clean up last environment var cache
94+
if [[ -r $TOP_DIR/.stackenv ]]; then
95+
rm $TOP_DIR/.stackenv
96+
fi
97+
9398
# Import database configuration
9499
source $TOP_DIR/lib/database
95100

@@ -537,9 +542,9 @@ function echo_nolog() {
537542
# Set ``LOGFILE`` to turn on logging
538543
# Append '.xxxxxxxx' to the given name to maintain history
539544
# where 'xxxxxxxx' is a representation of the date the file was created
545+
TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT:-"%F-%H%M%S"}
540546
if [[ -n "$LOGFILE" || -n "$SCREEN_LOGDIR" ]]; then
541547
LOGDAYS=${LOGDAYS:-7}
542-
TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT:-"%F-%H%M%S"}
543548
CURRENT_LOG_TIME=$(date "+$TIMESTAMP_FORMAT")
544549
fi
545550

@@ -1705,6 +1710,14 @@ if is_service_enabled tempest; then
17051710
echo '**************************************************'
17061711
fi
17071712

1713+
# Save some values we generated for later use
1714+
CURRENT_RUN_TIME=$(date "+$TIMESTAMP_FORMAT")
1715+
echo "# $CURRENT_RUN_TIME" >$TOP_DIR/.stackenv
1716+
for i in BASE_SQL_CONN ENABLED_SERVICES HOST_IP LOGFILE \
1717+
SERVICE_HOST SERVICE_PROTOCOL TLS_IP; do
1718+
echo $i=${!i} >>$TOP_DIR/.stackenv
1719+
done
1720+
17081721

17091722
# Run local script
17101723
# ================

0 commit comments

Comments
 (0)
Please sign in to comment.