summaryrefslogtreecommitdiffstats
path: root/stap-serverd
diff options
context:
space:
mode:
Diffstat (limited to 'stap-serverd')
-rwxr-xr-xstap-serverd46
1 files changed, 26 insertions, 20 deletions
diff --git a/stap-serverd b/stap-serverd
index 431d03e9..d7a57513 100755
--- a/stap-serverd
+++ b/stap-serverd
@@ -29,7 +29,8 @@ function initialization {
ssl_db=
stap_options=
uname_r="`uname -r`"
- arch="`get_arch`"
+ arch="`stap_get_arch`"
+ logfile=/dev/null
# Parse the arguments
parse_options "$@"
@@ -39,7 +40,7 @@ function initialization {
while netstat -atn | awk '{print $4}' | cut -f2 -d: | egrep -q "^$port\$";
do
# Whoops, the port is busy; try another one.
- echo "$0: Port $port is busy"
+ echo "$0: Port $port is busy" >> $logfile
port=$((1024+($port + $RANDOM)%64000))
done
@@ -57,19 +58,19 @@ function initialization {
# If no certificate/key database has been specified, then find/create
# a local one.
if ! test -f $ssl_db/$stap_certfile; then
- ${stap_exec_prefix}stap-gen-cert $ssl_db || exit 1
+ ${stap_exec_prefix}stap-gen-cert $ssl_db >> $logfile 2>&1 || exit 1
# Now add the server's certificate to the client's database,
# making it a trusted peer. Do this only if the client has been installed.
- if test -f `which ${stap_exec_prefix}stap-client` -a \
- -x `which ${stap_exec_prefix}stap-client`; then
- ${stap_exec_prefix}stap-authorize-server-cert $ssl_db/$stap_certfile
+ if test -f `which ${stap_exec_prefix}stap-client 2>/dev/null` -a \
+ -x `which ${stap_exec_prefix}stap-client 2>/dev/null`; then
+ ${stap_exec_prefix}stap-authorize-server-cert $ssl_db/$stap_certfile >> $logfile 2>&1
fi
elif ! test -f $stap_ssl_db/client/cert8.db; then
# If the client's database does not exist, then initialize it with our certificate.
# Do this only if the client has been installed.
if test -f `which ${stap_exec_prefix}stap-client` -a \
-x `which ${stap_exec_prefix}stap-client`; then
- ${stap_exec_prefix}stap-authorize-server-cert $ssl_db/$stap_certfile
+ ${stap_exec_prefix}stap-authorize-server-cert $ssl_db/$stap_certfile >> $logfile 2>&1
fi
fi
fi
@@ -115,6 +116,10 @@ function parse_options {
get_long_arg $first_token $2
ssl_db=$stap_arg
;;
+ log)
+ get_long_arg $first_token $2
+ logfile=$stap_arg
+ ;;
*)
warning "Option '$first_token' ignored"
advance_p=$(($advance_p + 1))
@@ -282,7 +287,7 @@ function process_r {
if test "$first_char" = "/"; then # fully specified path
kernel_build_tree=$1
version_file_name="$kernel_build_tree/include/config/kernel.release"
- # The file include/config/kernel.release within the
+ # The file include/config/kernel.release within the kernel
# build tree is used to pull out the version information
release=`cat $version_file_name 2>/dev/null`
if test "X$release" = "X"; then
@@ -305,13 +310,14 @@ function process_r {
# Advertise the availability of the server on the network.
function advertise_presence {
# Build up a string representing our server's properties.
+ local service_name="Systemtap Compile Server for $uname_r $arch"
local txt="sysinfo=$uname_r $arch"
# Call avahi-publish-service to advertise our presence.
- avahi-publish-service "Systemtap Compile Server on `uname -n`" \
- $stap_avahi_service_tag $port "$txt" > /dev/null &
+ avahi-publish-service "$service_name" \
+ $stap_avahi_service_tag $port "$txt" >> $logfile 2>&1 &
- echo "Systemtap Compile Server on `uname -n` listening on port $port"
+ echo "$service_name listening on port $port" >> $logfile
}
# function: listen
@@ -323,8 +329,8 @@ function listen {
${stap_exec_prefix}stap-server-connect \
-p $port -n $nss_cert -d $ssl_db -w $nss_pw \
-s "$stap_options" \
- 2>&1 &
- wait '%${stap_exec_prefix}stap-server-connect' >/dev/null 2>&1
+ >> $logfile 2>&1 &
+ wait '%${stap_exec_prefix}stap-server-connect' >> $logfile 2>&1
}
# function: check_db DBNAME
@@ -538,7 +544,7 @@ function check_cert_file {
# Warning error
# Prints its arguments to stderr
function warning {
- echo "$0: WARNING:" "$@" >&2
+ echo "$0: WARNING:" "$@" >> $logfile
}
# function: fatal [ MESSAGE ]
@@ -546,7 +552,7 @@ function warning {
# Fatal error
# Prints its arguments to stderr and exits
function fatal {
- echo "$0: ERROR:" "$@" >&2
+ echo "$0: ERROR:" "$@" >> $logfile
terminate
exit 1
}
@@ -555,15 +561,15 @@ function fatal {
#
# Terminate gracefully.
function terminate {
- echo "$0: Exiting"
+ echo "$0: Exiting" >> $logfile
# Kill the running 'avahi-publish-service' job
- kill -s SIGTERM '%avahi-publish-service' 2> /dev/null
- wait '%avahi-publish-service' >/dev/null 2>&1
+ kill -s SIGTERM '%avahi-publish-service' >> $logfile 2>&1
+ wait '%avahi-publish-service' >> $logfile 2>&1
# Kill any running 'stap-server-connect' job.
- kill -s SIGTERM '%${stap_exec_prefix}stap-server-connect' 2> /dev/null
- wait '%${stap_exec_prefix}stap-server-connect' >/dev/null 2>&1
+ kill -s SIGTERM '%${stap_exec_prefix}stap-server-connect' >> $logfile 2>&1
+ wait '%${stap_exec_prefix}stap-server-connect' >> $logfile 2>&1
exit
}