Debian Codegraph @

contrib/debug_server

raw symbols SCIP
1 #!/bin/sh
2 #
3 # Copyright (c) 2013 Holger Weiss <[email protected]>
4 #
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.
8 #
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.
12
13 set -e
14 set -u
15
16 default_config_file='/etc/send_nsca.cfg'
17 default_port='5668'
18
19 die()
20 {
21 echo >&2 "$@"
22 exit 1
23 }
24
25 usage()
26 {
27 die "Usage: $0 [-c <config-file>] [-H <server>] [-p <port>]"
28 }
29
30 xxd </dev/null >/dev/null 2>&1 || die "$0: xxd(1) is required"
31
32 while getopts c:H:hp: option
33 do
34 case $option in
35 c)
36 config_file=$OPTARG
37 ;;
38 H)
39 opt_server=$OPTARG
40 ;;
41 h|\?)
42 usage
43 ;;
44 p)
45 opt_port=$OPTARG
46 ;;
47 esac
48 done
49
50 shift `expr $OPTIND - 1`
51 test $# -eq 0 || usage
52
53 config_file=${config_file:-$default_config_file}
54
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)"
60 fi
61
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'}
69
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"
76
77 # vim:set joinspaces noexpandtab textwidth=80: