-
Notifications
You must be signed in to change notification settings - Fork 118
/
run_linux.sh
executable file
·60 lines (51 loc) · 1.84 KB
/
run_linux.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
#!/usr/bin/env bash
DEBUG_FILE="./run_linux.log"
export PIPENV_VENV_IN_PROJECT=1
date '+%d/%m/%Y %H:%M:%S' | tee $DEBUG_FILE
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
echo "system is ${machine}" | tee -a $DEBUG_FILE
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ ! -d "$DIR/.venv" ]; then
echo "no virtualenv detected doing setup before running" | tee -a $DEBUG_FILE
echo "need to install dependencies" | tee -a $DEBUG_FILE
if [ "${machine}" = "Linux" ]; then
echo "this is linux - install linux deps"
apt-get update || { echo 'apt-get failed failed' | tee -a $DEBUG_FILE ; exit 1; }
apt-get install -y --no-install-recommends \
g++ \
gcc \
libc6-dev \
make \
pkg-config \
libffi-dev \
python3.6 \
python3-pip \
python3-setuptools \
python3-dev \
git || { echo 'Installing dependencies failed' | tee -a $DEBUG_FILE ; exit 1; }
elif [ "${machine}" = "Mac" ]; then
$(xcode-select -p) || xcode-select --install
else
echo "No suitable linux version!" | tee -a $DEBUG_FILE
fi
if [ "${machine}" = "Linux" ] || [ "${machine}" = "Mac" ]; then
pip3 install pipenv || { echo 'Installing virtualenv failed' | tee -a $DEBUG_FILE ; exit 1; }
pipenv install || { echo 'Installing python dependencies failed' | tee -a $DEBUG_FILE ; exit 1; }
fi
fi
echo "Trying to run the bot" | tee -a $DEBUG_FILE
# start bot directly if nomenu passed in to script
if [[ $1 == *"menu"* ]]; then
echo "Running with menu" | tee -a $DEBUG_FILE
pipenv run python3 ./src/menu.py "$@"
else
echo "Running without menu" | tee -a $DEBUG_FILE
pipenv run python3 ./src/init.py "$@"
fi