-
Notifications
You must be signed in to change notification settings - Fork 4
/
run
executable file
·147 lines (126 loc) · 3.36 KB
/
run
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
config="config/backend_conf"
abort() {
echo "Stopped GOsa process. 'gosa-next' container is keept running. Use 'run --stop' to stop it."
}
trap 'abort' SIGINT
if ! command -v docker &> /dev/null; then
echo "Can't find the docker binary. Please make sure it is installed."
exit 9
fi
if ! docker info &> /dev/null; then
echo "Make sure your docker daemon is running and you're permitted to access it."
exit 9
fi
if [ ! -d .env ]; then
if command -v virtualenv-3.5 >/dev/null 2>&1; then
virtualenv-3.5 --system-site-packages .env
elif command -v virtualenv >/dev/null 2>&1; then
virtualenv --python=python3 --system-site-packages .env
else
echo "No 'virtualenv' for python3 found. Please install a package providing it for your system."
exit 10
fi
fi
if [[ $VIRTUAL_ENV = "" ]]; then
source .env/bin/activate
fi
getopt --test > /dev/null
if [[ $? -ne 4 ]]; then
echo "`getopt --test` failed - aborting"
exit 1
fi
PARSED=`getopt --options dr --longoptions devel,reset,stop,update,init,config: --name "$0" -- "$@"`
if [[ $? -ne 0 ]]; then
echo "HELP"
exit 2
fi
eval set -- "$PARSED"
while true; do
case "$1" in
-r|--reset)
reset=1
shift
;;
--stop)
reset=1
shift
;;
--config)
config=$2
shift 2
;;
--update|--init)
update=1
shift
;;
-d|--devel)
devel=1
shift
;;
--)
shift
break
;;
*)
echo "Error"
exit 3
;;
esac
done
# Stop container?
if [[ $stop -eq 1 ]]; then
cid=$(docker ps -f name=gosa-next --quiet)
if [[ $cid != "" ]]; then
docker stop $cid
fi
exit 0
fi
# Update?
if [[ $update -eq 1 ]]; then
git pull
git submodule update --init
./setup.py develop
(cd ./plugins/gui/frontend/gosa/ && python2 ./generate.py source)
for i in ./plugins/gui/frontend/gosa/plugins/*; do
if [ -d $i ] && [[ $i != *"_template"* ]]; then
(cd $i && python2 ./generate.py build)
fi
done
fi
# Reset docker environment?
if [[ $reset -eq 1 ]]; then
# If there's one running - abort it
cid=$(docker ps -f name=gosa-next --quiet)
if [[ $cid != "" ]]; then
echo "Stopping currently running 'gosa-next' container..."
docker stop $cid &> /dev/null
fi
# Delete old one
cid=$(docker ps -f name=gosa-next --all --quiet)
if [[ $cid != "" ]]; then
docker rm $cid
fi
fi
if ! command -v gosa &> /dev/null; then
echo "Please run './gosa --init' first."
exit 8
fi
# Run in devel mode
if [[ $devel -eq 1 ]]; then
cid=$(docker ps -f name=gosa-next --quiet)
if [[ $cid = "" ]]; then
cid=$(docker ps -f name=gosa-next --all --quiet)
if [[ $cid = "" ]]; then
echo "Creating 'gosa-next' docker container - this may take some time..."
docker run -d -p 389:389 -p 1883:1883 -p 5432:5432 --name gosa-next cpollmeier/gosa3:devel
else
echo "Starting 'gosa-next' docker container..."
docker start $cid
fi
fi
echo "Running GOsa - press Ctrl+C to stop"
gosa --config $config
else
echo "Currently only --devel is supported"
fi