Update embedded libev code to version 4.22
[nsca-ng.git] / contrib / debug_server
blob7259ad07cf2fb63e5a41df1a599399b722ad4368
1 #!/bin/sh
3 # Copyright (c) 2013 Holger Weiss <holger@weiss.in-berlin.de>
5 # This file is free software; Holger Weiss gives unlimited permission to copy
6 # and/or distribute it, with or without modifications, as long as this notice is
7 # preserved.
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY, to the extent permitted by law; without even the implied
11 # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 set -e
14 set -u
16 default_config_file='/etc/send_nsca.cfg'
17 default_port='5668'
19 die()
21 echo >&2 "$@"
22 exit 1
25 usage()
27 die "Usage: $0 [-c <config-file>] [-H <server>] [-p <port>]"
30 xxd </dev/null >/dev/null 2>&1 || die "$0: xxd(1) is required"
32 while getopts c:H:hp: option
34 case $option in
36 config_file=$OPTARG
39 opt_server=$OPTARG
41 h|\?)
42 usage
45 opt_port=$OPTARG
47 esac
48 done
50 shift `expr $OPTIND - 1`
51 test $# -eq 0 || usage
53 config_file=${config_file:-$default_config_file}
55 if [ -r "$config_file" ]
56 then
57 eval "`sed 's/[[:space:]]*=[[:space:]]*/=/' "$config_file"`"
58 else
59 echo >&2 "Cannot read $config_file (continuing anyway)"
62 server=${server:-'localhost'}
63 server=${opt_server:-$server}
64 port=${port:-$default_port}
65 port=${opt_port:-$port}
66 identity=${identity:-`hostname -s`}
67 password=${password:-'change-me'}
68 ciphers=${tls_ciphers:-'PSK-AES256-CBC-SHA:PSK-AES128-CBC-SHA:PSK-3DES-EDE-CBC-SHA:PSK-RC4-SHA'}
70 exec openssl s_client \
71 -crlf \
72 -cipher "$ciphers" \
73 -psk_identity "$identity" \
74 -psk `printf '%s' "$password" | xxd -p | tr -d '\n'` \
75 -connect "$server:$port"
77 # vim:set joinspaces noexpandtab textwidth=80: