blob: e01d6b08ac9087c367627ab77648f6e0859fc416 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/bin/sh
set -e
TORHFILE=/var/lib/tor/hidden_service/hostname
DEST="$(dirname $0)/../deps/sysroot/${TORHFILE}"
DEFINE="HTTP_ONION"
if [ $# -ne 1 ]; then
echo -e "usage: $0 [INCLUDE-FILE]\n\te.g. $0 $(realpath $(dirname $0)/../include/xor_strings.h)" >&2
exit 1
fi
if [ -r "${DEST}" ]; then
DEST=$(realpath "${DEST}")
echo "$0: TOR Hidden Service hostname file: ${DEST} -> $(cat ${DEST})" >&2
CURR_HOST=$(sed -n 's/#define\s*'${DEFINE}'\s*"\([a-zA-Z0-9]*\)"/\1/p' ${1})
WANT_HOST=$(cat ${DEST} | cut -d'.' -f1)
if [ "${CURR_HOST}" = "${WANT_HOST}" ]; then
echo "$0: WARNING: ${DEFINE} is already the same: ${CURR_HOST} == ${WANT_HOST}" >&2
exit 0
fi
sed -i 's/#define\s*'${DEFINE}'\s*"\([a-zA-Z0-9]*\)"/#define '${DEFINE}' "'$(cat ${DEST} | cut -d'.' -f1)'"/' ${1}
else
echo "$0: WARNING: ${DEST} not FOUND !" >&2
fi
|