File: common.sh

package info (click to toggle)
trojan 1.16.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 472 kB
  • sloc: cpp: 2,815; sh: 102; python: 28; makefile: 11
file content (29 lines) | stat: -rw-r--r-- 490 bytes parent folder | download | duplicates (2)
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
27
28
29
function check_available() {
    if ! command -v "$1" > /dev/null; then
        echo "$1 is required."
        exit 1
    fi
}

function wait_port() {
    until nc -z 127.0.0.1 "$1"; do
        sleep 0.1
    done
}

if [[ "$#" != "1" ]]; then
    echo "usage: $0 path_to_trojan"
    exit 1
fi

check_available curl
check_available nc
check_available openssl
check_available python3

SCRIPTDIR="$(dirname "$0")"
TMPDIR="$(mktemp -d)"

echo "$TMPDIR"
cp "$1" "$TMPDIR/trojan"
cd "$SCRIPTDIR"