-
Notifications
You must be signed in to change notification settings - Fork 7
/
copy_omod_files.sh
executable file
·46 lines (37 loc) · 1.15 KB
/
copy_omod_files.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
#!/bin/bash
# Source directory where the .omod files are located
SOURCE_DIR="./modules"
# Target directory where the files will be copied
TARGET_DIR="/var/lib/docker/volumes/ssemr_openmrs-data/_data/modules"
# Docker service name
DOCKER_SERVICE="backend"
# Check if the source directory exists
if [ ! -d "$SOURCE_DIR" ]; then
echo "Source directory does not exist: $SOURCE_DIR"
exit 1
fi
# Check if the target directory exists
if [ ! -d "$TARGET_DIR" ]; then
echo "Target directory does not exist: $TARGET_DIR"
exit 1
fi
# Copy .omod files from the source directory to the target directory
echo "Copying .omod files from $SOURCE_DIR to $TARGET_DIR..."
cp "$SOURCE_DIR"/*.omod "$TARGET_DIR"
# Verify if the copy was successful
if [ $? -eq 0 ]; then
echo "Files copied successfully."
else
echo "An error occurred while copying the files."
exit 1
fi
# Restart the Docker container
echo "Restarting Docker service: $DOCKER_SERVICE..."
docker compose restart $DOCKER_SERVICE
# Verify if the restart was successful
if [ $? -eq 0 ]; then
echo "Docker service restarted successfully."
else
echo "An error occurred while restarting the Docker service."
exit 1
fi