File: rebind

package info (click to toggle)
websockify 0.6.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 744 kB
  • ctags: 574
  • sloc: python: 1,541; ansic: 1,037; ruby: 533; cs: 142; sh: 122; makefile: 31
file content (21 lines) | stat: -rwxr-xr-x 530 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash

mydir="$(readlink -f "$(dirname "${0}")")"
mylib="${mydir}/../lib/websockify/rebind.so"
[ -e "${mylib}" ] || { echo "${mylib} not found" >&2; exit 1; }

usage() {
    echo "Usage: $(basename $0) OLD_PORT NEW_PORT COMMAND_LINE"
    echo
    echo "Launch COMMAND_LINE, but intercept system calls to bind"
    echo "to OLD_PORT and instead bind them to localhost:NEW_PORT"
    exit 2
}

# Parameter defaults

export REBIND_PORT_OLD="${1}"
export REBIND_PORT_NEW="${2}"
shift 2

LD_PRELOAD="${mylib}" exec "${@}"