mirror of https://gerrit.osmocom.org/osmo-dev
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
This commit is contained in:
parent
eba7d9ed8a
commit
c64fc3fb05
|
@ -40,7 +40,9 @@ fi
|
||||||
|
|
||||||
logdir="current_log"
|
logdir="current_log"
|
||||||
piddir="pids"
|
piddir="pids"
|
||||||
mkdir -p "$logdir" "$piddir"
|
wrapperdir="wrappers"
|
||||||
|
rm -rf "$wrapperdir"
|
||||||
|
mkdir -p "$logdir" "$piddir" "$wrapperdir"
|
||||||
|
|
||||||
find_term() {
|
find_term() {
|
||||||
# Find a terminal program and write to the global "terminal" variable
|
# Find a terminal program and write to the global "terminal" variable
|
||||||
|
@ -97,20 +99,32 @@ term() {
|
||||||
local pidfile_term="$piddir/$title.term.pid"
|
local pidfile_term="$piddir/$title.term.pid"
|
||||||
pidfiles_must_not_exist "$pidfile" "$pidfile_term"
|
pidfiles_must_not_exist "$pidfile" "$pidfile_term"
|
||||||
|
|
||||||
$terminal \
|
local wrapper="$wrapperdir/$title.sh"
|
||||||
-title "CN:$title" \
|
|
||||||
-e sh -c "export LD_LIBRARY_PATH='/usr/local/lib'
|
cat << EOF > "$wrapper"
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH='/usr/local/lib'
|
||||||
|
|
||||||
$1 &
|
$1 &
|
||||||
echo \$! > $pidfile
|
echo \$! > $pidfile
|
||||||
wait
|
wait
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
echo 'q Enter to close'
|
echo 'q Enter to close'
|
||||||
read q_to_close
|
read q_to_close
|
||||||
if [ \"x\$q_to_close\" = xq ]; then
|
if [ "x\$q_to_close" = xq ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done" \
|
done
|
||||||
|
EOF
|
||||||
|
chmod +x "$wrapper"
|
||||||
|
|
||||||
|
$terminal \
|
||||||
|
-title "CN:$title" \
|
||||||
|
-e sh -c "$wrapper" \
|
||||||
&
|
&
|
||||||
|
|
||||||
echo "$!" > "$pidfile_term"
|
echo "$!" > "$pidfile_term"
|
||||||
|
|
Loading…
Reference in New Issue