forked from wujiming/docker-XX-Net-VPN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start
89 lines (76 loc) · 2.41 KB
/
start
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
82
83
84
85
86
87
88
89
#!/bin/bash
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPTPATH
if python -V | grep -q "Python 3" ;then
PYTHON="python2"
else
PYTHON="python"
fi
if [ -f code/version.txt ]; then
VERSION=`cat code/version.txt`
else
VERSION="default"
fi
if [ ! -d "code/$VERSION" ]; then
VERSION="default"
fi
echo "XX-Net version:$VERSION"
# launch xx-net service by ignore hungup signal
function launchWithNoHungup() {
nohup ${PYTHON} code/${VERSION}/launcher/start.py 2&> /dev/null &
}
# launch xx-net service by hungup signal
function launchWithHungup() {
${PYTHON} code/${VERSION}/launcher/start.py
}
# get operating system name
os_name=`uname -s`
# check command avalibility
function has_command() {
command -v $1 > /dev/null
}
# Install Packages
if [ $os_name = 'Linux' ]; then
if ! python -c 'import OpenSSL' 2> /dev/null; then
echo 'You have not installed pyOpenSSL yet.'
if [[ $- == *i* ]]; then
# interactive shell
echo 'Installing pyOpenSSL for your system... Please type in your password if requested'
if has_command zypper; then
# openSUSE
sudo zypper in -y python-pyOpenSSL
elif has_command apt-get; then
# Debian or Debian-like
sudo apt-get install -y python-openssl
elif has_command dnf; then
# Fedora
sudo dnf install -y pyOpenSSL
elif has_command yum; then
# RedHat
sudo yum install -y pyOpenSSL
elif has_command pacman; then
# ArchLinux
sudo pacman -S --noconfirm openssl python2-pyopenssl
# Do Someting for OpenWRT
fi
else
# non-interactive shell
echo 1>&2 'Please install pyOpenSSL.'
#exit 1
fi
fi
elif [ $os_name = 'Darwin' ]; then
if [ `python -c 'import OpenSSL; print(OpenSSL.SSL.OPENSSL_VERSION_NUMBER > 0x1000200)' 2> /dev/null | grep True | wc -l` != 1 ]; then
PYTHON="/usr/bin/python2.7"
echo 'Warning: using system python'
echo 'Please install python from Homebrew or MacPorts for HTTP/2 support'
echo 'brew install python'
echo 'pip install pyOpenSSL'
fi
fi
# Start Application
if [ $os_name = 'Darwin' ] && ! [ "$1" = '-hungup' ]; then
launchWithNoHungup
else
launchWithHungup
fi