aboutsummaryrefslogtreecommitdiffstats
path: root/bin/srt
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2018-12-29 23:21:14 -0800
committerDavid Reyna <David.Reyna@windriver.com>2018-12-29 23:27:03 -0800
commitde23b97de101aec4c311f0f38800a85bfbd0c52c (patch)
tree9f79e3f3e1da91decc7e3d2b34993e85c3bcd6db /bin/srt
parent602a75909c666d75d1e86d438b2c3694207ca6ad (diff)
downloadsrtool-de23b97de101aec4c311f0f38800a85bfbd0c52c.tar.gz
srtool-de23b97de101aec4c311f0f38800a85bfbd0c52c.tar.bz2
srtool-de23b97de101aec4c311f0f38800a85bfbd0c52c.zip
srtool: generalize the master app (yp, acme, ...) management
The SRTool allows users to substitute an alternate master application instead of the default "yp" in order to customize their instance to their organization. This is done by: (a) Creating a datasource directory under bin (b) Defining a "datasource.json" file (c) Defining 'export SRT_MAIN_APP="<app>"' in "srtool_env.sh" This environment files are scanned by 'bin/srt', and if such an alternate master app is found it pre-empts the default 'yp'. This value is set via the environment because "lib/srtmain/settings.py" is the file that sets the app (and this the URL) ordering, and it is processed before any database is attached. To disable the alternate main app, simply rename its "datasource.json" file and it will be ignored for the next start. The sample alternate app "acme" is provided to demonstrate this facility. Additionally, a development tool 'bin/dev_tools/master_app.sh' has been added to help switch between master apps, to aid testing. $ ./stop.sh $ ./master_app.sh acme $ ./start.sh ... test ... $ ./stop.sh $ ./master_app.sh yp $ ./start.sh Other included fixes: * Fix the ACME JSON files formating * Remove ACME "_sample" from all but "datasource.json_sample" * Fix tabs to spaces in "srt" * Add global contect values to views::managedcontextprocessor so that other app templates can share them Signed-off-by: David Reyna <David.Reyna@windriver.com>
Diffstat (limited to 'bin/srt')
-rwxr-xr-xbin/srt41
1 files changed, 30 insertions, 11 deletions
diff --git a/bin/srt b/bin/srt
index 06940ee8..7af2491f 100755
--- a/bin/srt
+++ b/bin/srt
@@ -45,17 +45,34 @@ databaseCheck()
return $retval
}
+get_srt_env_settings() {
+ mainapp="yp"
+ # Apply all shell settings except default app 'yp'
+ # Only look in directories with proper 'datasource.json' files
+ for envscript in $(find ./bin -name "datasource.json") ; do
+ envscript=${envscript/datasource.json/srtool_env.sh}
+ if [ -f "$envscript" -a "$envscript" = "${envscript/bin\/yp/}" ] ; then
+ . $envscript
+ fi
+ done
+ # if no main app, default to 'yp'
+ if [ -z "$SRT_MAIN_APP" ] ; then
+ . ./bin/yp/srtool_env.sh
+ fi
+ echo "SRT_MAIN_APP=$SRT_MAIN_APP"
+}
+
webserverKillAll()
{
local pidfile
for pidfile in ${SRT_BASE_DIR}/.srtmain.pid ; do
if [ -f ${pidfile} ] ; then
pid=`cat ${pidfile}`
- while kill -0 $pid 2>/dev/null; do
- echo "KILL:$pid"
- kill -SIGTERM -9 $pid 2>/dev/null
- sleep 1
- done
+ while kill -0 $pid 2>/dev/null; do
+ echo "KILL:$pid"
+ kill -SIGTERM -9 $pid 2>/dev/null
+ sleep 1
+ done
rm ${pidfile}
fi
done
@@ -157,6 +174,9 @@ SRT_BASE_DIR=$(readlink -f $SRT_BASE_DIR)
SRT_BASE_DIR=$(dirname $SRT_BASE_DIR)
MANAGE="python3 $SRT_BASE_DIR/lib/manage.py"
+# Fetch the datasource environent settings
+get_srt_env_settings
+
# insure basic directories are present
mkdir -p $SRT_BASE_DIR/data
mkdir -p $SRT_BASE_DIR/data/cache
@@ -193,7 +213,7 @@ for param in $*; do
;;
*)
if [ "manage" == "$CMD" ] ; then
- cd $SRT_BASE_DIR/lib
+ cd $SRT_BASE_DIR/lib
manage_cmd="$manage_cmd $param"
else
echo "$HELP"
@@ -206,7 +226,6 @@ done
verify_prereq || exit 1
-
# this defines the dir SRTool will use for
# 1) the sqlite db if that is being used.
# 2) pid's we need to clean up on exit/shutdown
@@ -214,9 +233,9 @@ verify_prereq || exit 1
# Determine the action. If specified by arguments, fine, if not, toggle it
if [ "$CMD" = "start" ] ; then
if [ -n "$BBSERVER" ]; then
- echo " SRT is already running. Exiting..."
- exit 1
-fi
+ echo " SRT is already running. Exiting..."
+ exit 1
+ fi
elif [ "$CMD" = "" ]; then
echo "No command specified"
echo "$HELP"
@@ -230,7 +249,7 @@ case $CMD in
start )
# check if addr:port is not in use
if [ "$CMD" == 'start' ] ; then
- $MANAGE checksocket "$ADDR_PORT" || exit 1
+ $MANAGE checksocket "$ADDR_PORT" || exit 1
fi
if ! webserverStartAll; then