projects
/
anna.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixes & improvements
[anna.git]
/
example
/
diameter
/
launcher
/
resources
/
scripts
/
operation_signal.sh
diff --git
a/example/diameter/launcher/resources/scripts/operation_signal.sh
b/example/diameter/launcher/resources/scripts/operation_signal.sh
index
da0449b
..
04684bd
100755
(executable)
--- a/
example/diameter/launcher/resources/scripts/operation_signal.sh
+++ b/
example/diameter/launcher/resources/scripts/operation_signal.sh
@@
-16,7
+16,7
@@
_exit() {
usage() {
echo
usage() {
echo
- echo "Usage: $0 [-h|--help] [-t|--timeout <value>] [-f|--file] <data>"
+ echo "Usage: $0 [-h|--help] [-t|--timeout <value>] [-f|--file]
[-p|--ping]
<data>"
echo
echo " -h|--help: this usage help."
echo " -t|--timeout: timeout for operation in seconds."
echo
echo " -h|--help: this usage help."
echo " -t|--timeout: timeout for operation in seconds."
@@
-26,6
+26,9
@@
usage() {
echo " with one operation per line. If missing, it will be"
echo " a single operation string."
echo
echo " with one operation per line. If missing, it will be"
echo " a single operation string."
echo
+ echo " -p|--ping: Check the target process id."
+ echo " Returns 1 (dead) or 0 (alive)."
+ echo
echo " data: operation string or file with several operations."
echo
echo " For example:"
echo " data: operation string or file with several operations."
echo
echo " For example:"
@@
-40,6
+43,7
@@
parse_arguments() {
is_file=
timeout=$TIMEOUT__dflt
data=
is_file=
timeout=$TIMEOUT__dflt
data=
+ ping=
while [ $# -gt 0 ]; do
case $1 in
while [ $# -gt 0 ]; do
case $1 in
@@
-61,6
+65,10
@@
parse_arguments() {
shift
;;
shift
;;
+ -p|--ping)
+ ping=yes
+ ;;
+
*)
first=$(echo $1 | cut -c1)
[ "$first" = "-" ] && _exit "Unsupported script option: $1. Type '$SCR_BN -h' (or --help) to print the available options."
*)
first=$(echo $1 | cut -c1)
[ "$first" = "-" ] && _exit "Unsupported script option: $1. Type '$SCR_BN -h' (or --help) to print the available options."
@@
-70,13
+78,13
@@
parse_arguments() {
shift
done
shift
done
- [ -z "$data" ] && _exit "Missing data value"
+ [ -z "$
ping" -a -z "$
data" ] && _exit "Missing data value"
}
# $1: pid to check
check_pid() {
kill -0 $1 2>/dev/null
}
# $1: pid to check
check_pid() {
kill -0 $1 2>/dev/null
- [ $? -ne 0 ] && _exit "Operation error: missing process with pid $1"
+ return $?
}
#############
}
#############
@@
-91,6
+99,12
@@
PID=`cat .pid`
[ "$1" = "" -o "$1" = "--help" -o "$1" = "-h" ] && usage
parse_arguments $@
[ "$1" = "" -o "$1" = "--help" -o "$1" = "-h" ] && usage
parse_arguments $@
+# Check pid:
+check_pid $PID
+res=$?
+[ -n "$ping" ] && exit $res
+[ $res -ne 0 ] && _exit "Operation error: missing process with pid $PID"
+
# Send operation:
if [ -n "$is_file" ]
then
# Send operation:
if [ -n "$is_file" ]
then