-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·81 lines (67 loc) · 2.13 KB
/
docker-entrypoint.sh
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
set -euf -o pipefail
if [[ $# -gt 0 ]] && [[ "${1:0:1}" != '-' ]]; then
exec $@
fi
readonly DEFAULT_SS_ENCRYPTION_METHOD='aes-256-cfb'
readonly DEFAULT_SS_PASSWORD='sspassword'
readonly DEFAULT_KCPTUN_SECRET="kcpsecret"
readonly DEFAULT_KCPTUN_CRYPT="aes"
readonly PROG_NAME="$0"
function usage() {
cat << EOF
Usage:
${PROG_NAME} --help
${PROG_NAME} [-m|--method <METHOD>] [-p|--ss-password <PASSWORD>]
Options:
--help show help
-m|--ss-method METHOD shadowsocks encryption method (default: ${DEFAULT_SS_ENCRYPTION_METHOD})
-p|--ss-password PASSWORD shadowsocks password (default: ${DEFAULT_SS_PASSWORD})
-s|--kcptun-secret PASSWORD kcptun pre-shared secret between client and server (default: "${DEFAULT_KCPTUN_SECRET}")
-c|--kcptun-crypt CRYPT aes, aes-128, aes-192, salsa20, blowfish, twofish, cast5, 3des, tea, xtea, xor, sm4, none (default: "${DEFAULT_KCPTUN_CRYPT}")
EOF
}
OPTS=$(getopt -n "$0" -o hm:p:s:c: --long help,ss-method:,ss-password:,kcptun-secret:,kcptun-crypt: -- "$@")
eval set -- "$OPTS"
help='false'
ss_encryption_method="${DEFAULT_SS_ENCRYPTION_METHOD}"
ss_password="${DEFAULT_SS_PASSWORD}"
kcptun_secret="${DEFAULT_KCPTUN_SECRET}"
kcptun_crypt="${DEFAULT_KCPTUN_CRYPT}"
while true; do
case "$1" in
-h | --help)
help='true'
shift;;
-m | --ss-method)
ss_encryption_method="$2"
shift 2;;
-p | --ss-password)
ss_password="$2"
shift 2;;
-s| --kcptun-secret)
kcptun_secret="$2"
shift 2;;
-c | --kcptun-crypt)
kcptun_crypt="$2"
shift 2;;
--)
shift
break
;;
esac
done
if [[ $# != 0 ]]; then
usage
exit 1
fi
if [[ "${help}" = 'true' ]]; then
usage
exit 0
fi
exec env \
SS_METHOD="${ss_encryption_method}" \
SS_PASSWORD="${ss_password}" \
KCPTUN_SECRET="${kcptun_secret}" \
KCPTUN_CRYPT="${kcptun_crypt}" \
/usr/bin/supervisord --nodaemon -c /etc/supervisor/supervisord.conf -d /