Commit 0e2cab68 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

added with-resolver(.in) script for easy launching

parent c7022fb2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -19,4 +19,9 @@ lib_LTLIBRARIES = libresolv-ns-override.la
libresolv_ns_override_la_SOURCES = resolv-ns-override.c
libresolv_ns_override_la_LDFLAGS = --version-info 0:0:0

bin_SCRIPTS = with-resolver
CLEANFILES = $(bin_SCRIPTS)
EXTRA_DIST = with-resolver.in
Makefile: with-resolver.in

ACLOCAL_AMFLAGS = -I m4
+1 −1
Original line number Diff line number Diff line
@@ -23,4 +23,4 @@ LT_INIT()

AC_CONFIG_MACRO_DIR([m4])

AC_OUTPUT([Makefile])
AC_OUTPUT([Makefile with-resolver])

with-resolver.in

0 → 100644
+50 −0
Original line number Diff line number Diff line
#!/bin/sh
prefix="@prefix@"
exec_prefix="@exec_prefix@"
libdir="@libdir@"
package_name="@PACKAGE_NAME@"

usage() {
cat <<END_USAGE
Usage: `basename $0` [-h] <NAME_SERVER> {<NAME_SERVER> ...} -- <CMD> {<ARGS> ...}

    -h --help  Display this message

    <NAME_SERVER>       An IP address to request resolves from.
    <CMD> {<ARGS> ...}  The command to run.

END_USAGE
}

bad_arg() {
	usage >&2
	echo "Bad argument: $1" >&2
	exit 2
}

num=0
while [ $# -gt 0 ]; do
	num=$((num+1))
	case "$1" in
		--help|-h) usage ;;
		--) shift; break ;;
		-*) bad_arg "$1" ;;
		*) eval `printf 'export NAMESERVER%i=%s' $num "$1"` ;;
	esac
	shift
done
case `uname` in
	# OSX/Darwin is not actually supported by the library yet...
	Darwin) LD_PRELOAD="${libdir}/lib${package_name}.dylib" ;;
	Linux) LD_PRELOAD="${libdir}/lib${package_name}.so" ;;
	'')
		echo "Cannot get the platform" >&2
		exit 3
		;;
	*)
		echo "Unknown platform `uname`" >&2
		exit 3
		;;
esac
export LD_PRELOAD
exec "$@"