-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
executable file
·59 lines (53 loc) · 1.66 KB
/
run.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
#!/bin/bash
remove_services() {
read -p "Are you sure you want to remove all services? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
docker compose down --volumes
docker compose rm -f
else
echo "Operation aborted. Services will not be removed."
exit 1
fi
}
copy_files() {
docker compose exec web rm -rf /staticfiles/*
docker compose exec web rm -rf /static/*
docker cp static/. trusted-web-main:/app/static/
docker cp trustly/templates/. trusted-web-main:/app/trustly/templates/
docker compose exec web python manage.py collectstatic --noinput
}
remove_conflicting_containers() {
container_names=("trustly-web-mongodb" "trusted-web-elastic" "trusted-web-main" "trusted-web-nginx")
for container_name in "${container_names[@]}"; do
if [[ $(docker ps -a --filter "name=$container_name" --format '{{.ID}}') ]]; then
echo "Stopping and removing conflicting container: $container_name"
docker rm -f "$container_name"
fi
done
}
if [ "$1" == "build" ]; then
remove_services
remove_conflicting_containers
docker compose build --no-cache
docker compose up
sleep 2
copy_files
echo "search service started"
elif [ "$1" == "stop" ]; then
docker compose down
remove_conflicting_containers
echo "services stopped successfully."
elif [ "$1" == "reload_cache" ]; then
copy_files
docker stop trusted-web-main
docker start trusted-web-main
echo "cache reloaded successfully."
else
docker compose down
remove_conflicting_containers
docker compose up
sleep 2
copy_files
echo "search service started"
fi