-
Notifications
You must be signed in to change notification settings - Fork 105
/
launch-testing.sh
executable file
·90 lines (78 loc) · 1.86 KB
/
launch-testing.sh
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
#!/bin/bash
# Helper script to cleanup the build environment, rebuild and relaunch. For the
# desktop notification to work the script assumes the user belongs to docker group
NOTIFY_TIMEOUT=10000
BUILD_IMAGE=0
BUILD_NOCACHE=""
CLEAN=0
DEBUG=0
RUN=0
params=""
COMPOSE_FILE="docker-compose.yml"
usage()
{
cat << EOF
OTRS development launch script.
Usage: $0 OPTIONS
OPTIONS:
-b Build image.
-B Build image (--no-cache).
-c Clean volumes.
-f compsoe file to use (default is docker-compose.yml)
-r Run container.
-h Print help.
-V Debug mode.
EOF
}
# trap ctrl-c and call ctrl_c()
trap ctrl_c INT
function ctrl_c() {
echo "Ctrl C pressed."
exit 0
}
while getopts bBcf:rhV option
do
case "${option}"
in
b) BUILD_IMAGE=1
;;
B) BUILD_IMAGE=1
BUILD_NOCACHE="--no-cache"
;;
c) CLEAN=1
;;
f) COMPOSE_FILE="${OPTARG}"
;;
r) RUN=1
;;
h) usage
exit
;;
V) DEBUG=1
;;
esac
done
if [ ${DEBUG} -eq 1 ]; then
set -x
fi
docker-compose rm -f -v
if [ ${CLEAN} -eq 1 ]; then
sudo rm -fr volumes/config
sudo rm -fr volumes/mysql/*
sudo chown -R 27 volumes/mysql
sudo rm -fr volumes/skins
params="--no-cache"
fi
if [ ${BUILD_IMAGE} -eq 1 ]; then
docker-compose build ${BUILD_NOCACHE}
if [ $? -gt 0 ]; then
out=$(echo ${out}|tail -n 10)
notify-send 'App rebuild failure' "There was an error building the container, see console for build output" -t ${NOTIFY_TIMEOUT} -i dialog-error && \
paplay /usr/share/sounds/freedesktop/stereo/suspend-error.oga && exit 1
#echo ${out}
else
notify-send 'App rebuild ready' 'Docker container rebuild finished, starting up container.' -t ${NOTIFY_TIMEOUT} -i dialog-information && \
paplay /usr/share/sounds/freedesktop/stereo/complete.oga
fi
fi
[ ${RUN} -eq 1 ] && docker-compose -f ${COMPOSE_FILE} up