-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathremove_module
executable file
·84 lines (69 loc) · 2.57 KB
/
remove_module
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
#!/bin/bash
projectname=`basename "$PWD"`
source ./lib/singlenv
source ./lib/colorful
# Removes all occurrence of a configuration e.g. to make intraweb work
# removeNGINXconf <folder in 'data/nginx' to operate on> <modulename>
# e.g. removeNGINXconf intraweb tileserver
removeNGINXconf() {
local modulename="$2"
if [ -f "./data/nginx/${1}/${city}/${modulename}.conf" ]; then
orangeecho " removing nginx configuration of module '$modulename' from nginx city config for '$city' ..."
rm "./data/nginx/${1}/${city}/${modulename}.conf" --verbose
fi
if [ -d "./data/nginx/${1}/${city}" ] && [ -z `ls "./data/nginx/${1}/${city}"` ]; then
orangeecho " removing nginx configuration of city '$city' because it's empty now ..."
rm -R "./data/nginx/${1}/${city}" --verbose
if [ -f "./data/nginx/${1}/${city}.conf" ]; then
orangeecho " completing removal of nginx configuration for city '$city' ..."
rm "./data/nginx/${1}/${city}.conf" --verbose
fi
fi
}
blueecho "1. perform some checks & normalizations"
source ./lib/validation
removeModule() {
local modulename="$1"
blueecho "1. Turning down module '$modulename' of city '$city'"
./server "$city" down "$modulename"
blueecho "2. remove interweb nginx configuration"
removeNGINXconf "interweb" "$modulename"
if [ "$intraweb" = "yes" ]; then
blueecho "3. remove intraweb nginx configuration"
cd modules/$modulename
allServices=`sudo docker-compose -p "$projectname" -f "${city}.yml" ps --services`
allServices=( $allServices )
cd ../../
# iterate through names of all services of that city in the module
for servicename in "${allServices[@]}"; do
removeNGINXconf "intraweb" "$servicename"
done
fi
source "lib/plugin"
invokeAllPluginsOf "remove_module"
blueecho "4. deactivate module '$modulename' in city '$city'"
ymlFile="$moduleDir/$city.yml"
ymlFileInactive="$ymlFile.inactive"
if [ -f "$ymlFile" ]; then
orangeecho " setting module in directory '$moduleDir' to inactive ..."
mv "$ymlFile" "$ymlFileInactive" --verbose
if ! [ -f "$ymlFileInactive" ]; then
redecho " Deactivation failed! Do I have write access to '$ymlFile'?">&2
exit 1
fi
blueecho " This operation did **not** remove"
blueecho " - file '$ymlFile' but set it to 'inactive'"
blueecho " - and also not its data directory 'data_$city'"
else
greenecho " already set to inactive. No need to do it again :)"
fi
greenecho "removed trufi module '$modulename' from city '$city'"
}
for module in "${args[@]}"; do
moduleDir="./modules/$module"
if [ -z "$module" ]; then
continue
fi
echo
removeModule "$module"
done