-
Notifications
You must be signed in to change notification settings - Fork 14
/
init
executable file
·92 lines (65 loc) · 1.99 KB
/
init
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
90
91
92
#!/bin/bash
stubspath=$1
#create conf-default file concatting the files wanted
#create default conf (" conf1 conf2"), Hox the spaces, currently backends
FIS=$IFS
IFS=':' #'anything' but ' '
rm shared/simplerunner/conf/default >> /dev/null 2>&1
echo " $2" | sed -e 's/ / shared\/simplerunner\/conf\//g' | xargs cat \
>>shared/simplerunner/conf/default
IFS=FIS
shift 2 #stubspath + confs
#create stubs file(s)
#remove old files
rm shared/simplerunner/stubs/* >> /dev/null 2>&1
#init docker-compose
{ echo "version: '2'"; echo 'services:'; } > docker-compose.yml || exit 2
while [ $# -gt 0 ]; do
language=$1
FIS=$IFS
IFS='&'
read -a drivers <<< "${language}"
size="${#drivers[@]}"
language=""
for i in "${!drivers[@]}"
do driver="${drivers[$i]}"
if [[ $i == 0 ]]; then
#language[:stub1:stub2:...:stubn][&driver&driver&driver]
if [[ $driver =~ ":" ]]; then
FIS2=$IFS
IFS=' '
for stub in `echo $driver | tr ':' ' '`
do
if [[ ! $language ]]; then
language=$stub
else
stub=`find $stubspath/ -maxdepth 1 -type d -name "$stub" | sed 's#.*/##'`
echo $stub >> shared/simplerunner/stubs/$language.stubs
fi
done
IFS=$FIS2
else
language=$driver
stub=`find $stubspath/ -maxdepth 1 -type d -name "$language-"* | sed 's#.*/##'`
echo $stub >> shared/simplerunner/stubs/$language.stubs
fi
if [[ $size != 1 ]]; then
continue
fi
fi
#echo $driver
{ echo " $driver:" ;\
echo " build: drivers/$driver" ;\
echo " container_name: bashtls_$driver" ; \
echo " volumes: " ; \
echo " - ./shared:/etc/shared" ;\
echo " - $stubspath:/stubs" ;
echo " - ./drivers/$driver:/driver" ;
echo ' network_mode: "host" ' ; }\
>> docker-compose.yml || exit 4
done
IFS=FIS
#edit docker-compose.yml
shift 1
done
#Todo: add better support for running only wanted stubs + more drivers