aboutsummaryrefslogtreecommitdiffstats
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
parent1d1c2f17a4ee33139121bceed160a999ee7144c2 (diff)
downloadsrtool-75c76171ebf8c4a6e8f5e467857644f3fae27af9.tar.gz
srtool-75c76171ebf8c4a6e8f5e467857644f3fae27af9.tar.bz2
srtool-75c76171ebf8c4a6e8f5e467857644f3fae27af9.zip
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>
-rwxr-xr-xbin/acme/patcher/inplace/bin/srt23
-rwxr-xr-xbin/srt32
2 files changed, 55 insertions, 0 deletions
diff --git a/bin/acme/patcher/inplace/bin/srt b/bin/acme/patcher/inplace/bin/srt
index af8a1fb2..5eba94d6 100755
--- a/bin/acme/patcher/inplace/bin/srt
+++ b/bin/acme/patcher/inplace/bin/srt
@@ -175,6 +175,28 @@ 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}
@@ -297,6 +319,7 @@ case $CMD in
# set fail safe stop system on terminal exit
trap stop_system SIGHUP
echo "Successful ${CMD}."
+ create_restart $*
exit 0
;;
stop )
diff --git a/bin/srt b/bin/srt
index 41753b74..721f1224 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 )