PYROS_.sh
1.49 KB
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
#!/usr/bin/env bash
DEBUG=true
DEBUG=false
# test if user passed a command as parameter
#if test $# -lt 1 ; then
#echo "Missing command, use one of the commands below"
#python3 pyros.py --help
#exit
#fi
# Guess Context :
# - NO DOCKER,
# or
# - DOCKER OUT of container,
# or
# - or DOCKER IN container
WITH_DOCKER_IS_SET=true
[ -z $WITH_DOCKER ] && WITH_DOCKER_IS_SET=false
APP_FOLDER=false
[ -d ../app/ ] && APP_FOLDER=true
VENV=false
[ -d ./venv/ ] && VENV=true
# test if docker is installed
DOCKER_CMD=false
[ -x "$(command -v docker)" ] && DOCKER_CMD=true
# test if container is running
DOCKER_CONTAINER_STARTED=false
$DOCKER_CMD && [ $(docker ps | grep 'pyros' | wc -l) -eq 2 ] && DOCKER_CONTAINER_STARTED=true
#
# SYNTHESIS
#
DOCKER=false
[[ $VENV == false && $DOCKER_CMD == true ]] && DOCKER=true
DOCKER_OUT_CONTAINER=false
[[ $DOCKER == true && $WITH_DOCKER_IS_SET == false ]] && DOCKER_OUT_CONTAINER=true
#[[ $DOCKER == false && $WITH_DOCKER_IS_SET == true ]] && DOCKER_IN_CONTAINER=true
if $DEBUG ; then
echo $APP_FOLDER
echo $VENV
echo $DOCKER_CMD
echo $container
# Synthesis
echo $DOCKER
echo $DOCKER_OUT_CONTAINER
exit
fi
# no container ? => start container first
#[ $container == false ] && cd docker/ && docker-compose up -d
# DOCKER_OUT_CONTAINER true ? docker exec
PREFIX=''
#docker exec -it pyros python3 pyros.py $*
[ $DOCKER_OUT_CONTAINER == true ] && cd docker/ && docker-compose up -d && PREFIX='docker exec -it pyros'
echo $PREFIX
$PREFIX python3 pyros.py $*