aboutsummaryrefslogtreecommitdiffstats
path: root/bin/srt
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2019-01-21 14:14:11 -0800
committerDavid Reyna <David.Reyna@windriver.com>2019-01-21 14:14:11 -0800
commit75c76171ebf8c4a6e8f5e467857644f3fae27af9 (patch)
tree851bc39e090a1947e819919a1036dda5b3bede87 /bin/srt
parent1d1c2f17a4ee33139121bceed160a999ee7144c2 (diff)
downloadsrtool-75c76171ebf8c4a6e8f5e467857644f3fae27af9.zip
srtool-75c76171ebf8c4a6e8f5e467857644f3fae27af9.tar.gz
srtool-75c76171ebf8c4a6e8f5e467857644f3fae27af9.tar.bz2
srtool_start: generate SRTool stop/restart scripts
When the SRTool successfully starts, auto-generate helper scripts to allow the user to stop and restart the SRTool based on the previous options. This is also useful for scripts that need to stop then restart the SRTool server in order to safely perform actions (like backup or restore). Generated scripts: bin/srt_start.sh (also first stops the server if currently running) bin/srt_stop.sh Signed-off-by: David Reyna <David.Reyna@windriver.com>
Diffstat (limited to 'bin/srt')
-rwxr-xr-xbin/srt32
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/srt b/bin/srt
index 41753b7..721f122 100755
--- a/bin/srt
+++ b/bin/srt
@@ -170,6 +170,37 @@ verify_prereq() {
return 0
}
+create_restart() {
+ cat > $SRT_BASE_DIR/bin/srt_start.sh << endmsg
+#!/bin/bash
+# Restart the SRTool using the last start options
+if [ -f $SRT_BASE_DIR/.srtmain.pid ] ; then
+ $SRT_BASE_DIR/bin/srt_stop.sh
+fi
+$SRT_BASE_DIR/bin/srt $*
+endmsg
+ chmod +x $SRT_BASE_DIR/bin/srt_start.sh
+ cat > $SRT_BASE_DIR/bin/srt_stop.sh << endmsg
+#!/bin/bash
+# Stop the SRTool based on the the last start options
+if [ 1 -eq $no_auto_update ] ; then
+ $SRT_BASE_DIR/bin/srt stop noautoupdate
+else
+ $SRT_BASE_DIR/bin/srt stop
+fi
+endmsg
+ chmod +x $SRT_BASE_DIR/bin/srt_stop.sh
+}
+
+# read command line parameters
+if [ -n "$BASH_SOURCE" ] ; then
+ SRT=${BASH_SOURCE}
+elif [ -n "$ZSH_NAME" ] ; then
+ SRT=${(%):-%x}
+else
+ SRT=$0
+fi
+
# read command line parameters
if [ -n "$BASH_SOURCE" ] ; then
SRT=${BASH_SOURCE}
@@ -282,6 +313,7 @@ case $CMD in
# set fail safe stop system on terminal exit
trap stop_system SIGHUP
echo "Successful ${CMD}."
+ create_restart $*
exit 0
;;
stop )