-
Notifications
You must be signed in to change notification settings - Fork 2
/
start
executable file
·75 lines (60 loc) · 1.73 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
#!/bin/bash
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPTPATH"
if python -V 2>&1| 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 [ ! -f "code/$VERSION/launcher/start.py" ]; 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 $@>/dev/null 2>&1 &
}
# 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 '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
fi
fi
fi
# Start Application
if [ $os_name = 'Darwin' ] && ! [ "$1" = '-hungup' ]; then
PYTHON="/usr/bin/python2.7"
launchWithNoHungup $@
else
launchWithHungup $@
fi