Blame view

PYROS 1.43 KB
70921b83   ALEXIS-PC\alexis   adding PYROS scri...
1
2
#!/usr/bin/env bash

a6617686   Etienne Pallier   new wrapper scrip...
3
4
5
DEBUG=true
DEBUG=false

70921b83   ALEXIS-PC\alexis   adding PYROS scri...
6
# test if user passed a command as parameter
a6617686   Etienne Pallier   new wrapper scrip...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#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
70921b83   ALEXIS-PC\alexis   adding PYROS scri...
28
29

# test if docker is installed 
a6617686   Etienne Pallier   new wrapper scrip...
30
31
32
33
34
35
36
DOCKER_CMD=false
[ -x "$(command -v docker)" ] && DOCKER_CMD=true


# test if container is running
container=false
$DOCKER_CMD && [ $(docker ps | grep 'pyros' | wc -l) -eq 2 ] && container=true
70921b83   ALEXIS-PC\alexis   adding PYROS scri...
37

a6617686   Etienne Pallier   new wrapper scrip...
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#
# 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
70921b83   ALEXIS-PC\alexis   adding PYROS scri...
60
61
fi

a6617686   Etienne Pallier   new wrapper scrip...
62
63
64
65
66
67
68
69
70
71
72

# 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 ] && PREFIX='docker exec -it pyros '

echo $PREFIX
$PREFIX python3 pyros.py $*