-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
Β·64 lines (55 loc) Β· 1.81 KB
/
Copy pathupdate.sh
File metadata and controls
executable file
Β·64 lines (55 loc) Β· 1.81 KB
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
#!/bin/bash
# Function to display script usage
usage() {
echo "Usage: $0 [--with-build] [--recreate-env] [--no-git-pull]"
echo " -h, --help Display this help message"
echo " --with-build Restart docker compose with build"
echo " --recreate-env Recreate .env file from .env.sample"
echo " --no-git-pull Skip pulling the repository"
echo " --tld <value> Set the domain TLD (default: internal), used with --recreate-env option"
exit 0
}
# Parse command line options
SKIP_BUILD=true
SKIP_PULL=false
LOCAL_TLD="internal"
RECREATE_ENV_FILE=false
while [[ "$#" -gt 0 ]]; do
case "$1" in
-h|--help) usage ;;
--with-build) SKIP_BUILD=false; shift ;;
--recreate-env) RECREATE_ENV_FILE=true; shift ;;
--no-git-pull) SKIP_PULL=true; shift ;;
--tld) LOCAL_TLD="$2"; shift 2 ;;
*) echo "Unknown option: $1"; usage ;;
esac
done
# find the directory of the script
SCRIPT_DIR=$(dirname "$(realpath "$0")")
cd "$SCRIPT_DIR" || exit # change to the script directory
# update the repository
if [ "$SKIP_PULL" = false ]; then
# check .git directory exists
if [ ! -d .git ]; then
echo "Git repository not found. Please clone the repository and try again."
exit 1
fi
git checkout main
git pull origin main
fi
# recreate the .env file if requested
if [ "$RECREATE_ENV_FILE" = true ]; then
cp .env.sample .env
# Add TLD to environment file
echo "" >> .env
echo "# local domain" >> .env
echo "LOCAL_TLD=$LOCAL_TLD" >> .env
fi
# restart the docker containers with or without build
if [ "$SKIP_BUILD" = true ]; then
echo "Starting Docker Compose without build..."
docker compose up -d --remove-orphans
else
echo "Starting Docker Compose with build..."
docker compose up --build -d --remove-orphans
fi