osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-dev/+/27035 )
Change subject: net: run.sh: write wrapper command to shell script ......................................................................
net: run.sh: write wrapper command to shell script
Instead of passing a whole script to the terminal via command-line argument, write it to a file. This is in preparation to use the same script with tmux, see next patch.
Change-Id: I15760d706b20628421c10a16514120f442d5477f --- M net/templates/run.sh 1 file changed, 27 insertions(+), 13 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/35/27035/1
diff --git a/net/templates/run.sh b/net/templates/run.sh index 7b36101..19e7e9b 100755 --- a/net/templates/run.sh +++ b/net/templates/run.sh @@ -40,7 +40,9 @@
logdir="current_log" piddir="pids" -mkdir -p "$logdir" "$piddir" +wrapperdir="wrappers" +rm -rf "$wrapperdir" +mkdir -p "$logdir" "$piddir" "$wrapperdir"
find_term() { # Find a terminal program and write to the global "terminal" variable @@ -97,20 +99,32 @@ local pidfile_term="$piddir/$title.term.pid" pidfiles_must_not_exist "$pidfile" "$pidfile_term"
+ local wrapper="$wrapperdir/$title.sh" + + cat << EOF > "$wrapper" +#!/bin/sh + +export LD_LIBRARY_PATH='/usr/local/lib' + +$1 & +echo $! > $pidfile +wait + +echo + +while true; do + echo 'q Enter to close' + read q_to_close + if [ "x$q_to_close" = xq ]; then + break + fi +done +EOF + chmod +x "$wrapper" + $terminal \ -title "CN:$title" \ - -e sh -c "export LD_LIBRARY_PATH='/usr/local/lib' - $1 & - echo $! > $pidfile - wait - echo - while true; do - echo 'q Enter to close' - read q_to_close - if [ "x$q_to_close" = xq ]; then - break - fi - done" \ + -e sh -c "$wrapper" \ &
echo "$!" > "$pidfile_term"