4
4
usage () {
5
5
echo " Usage: $0 [-l] [-f <ftl_branch>] [-c <core_branch>] [-w <web_branch>] [-t <tag>] [use_cache]"
6
6
echo " Options:"
7
- echo " -f, --ftlbranch <branch> Specify FTL branch (cannot be used in conjunction with -l) "
7
+ echo " -f, --ftlbranch <branch> Specify FTL branch"
8
8
echo " -c, --corebranch <branch> Specify Core branch"
9
9
echo " -w, --webbranch <branch> Specify Web branch"
10
10
echo " -p, --paddbranch <branch> Specify PADD branch"
11
11
echo " -t, --tag <tag> Specify Docker image tag (default: pihole:local)"
12
- echo " -l, --local Use locally built FTL binary (requires src/pihole-FTL file) "
12
+ echo " -l, --local Clones the FTL repository and builds the binary locally "
13
13
echo " use_cache Enable caching (by default --no-cache is used)"
14
14
echo " "
15
15
echo " If no options are specified, the following command will be executed:"
@@ -20,11 +20,9 @@ usage() {
20
20
# Set default values
21
21
TAG=" pihole:local"
22
22
DOCKER_BUILD_CMD=" docker buildx build src/. --tag ${TAG} --load --no-cache"
23
- FTL_FLAG=false
24
23
25
24
# Check if buildx is installed
26
- docker buildx version > /dev/null 2>&1
27
- if [ $? -ne 0 ]; then
25
+ if ! docker buildx version > /dev/null 2>&1 ; then
28
26
echo " Error: Docker buildx is required to build this image. For installation instructions, see:"
29
27
echo " https://github.com/docker/buildx#installing"
30
28
exit 1
@@ -56,25 +54,11 @@ while [[ $# -gt 0 ]]; do
56
54
key=" $1 "
57
55
58
56
case $key in
59
- -l | --local)
60
- if [ ! -f " src/pihole-FTL" ]; then
61
- echo " File 'src/pihole-FTL' not found. Exiting."
62
- exit 1
63
- fi
64
- if [ " $FTL_FLAG " = true ]; then
65
- echo " Error: Both -l and -f cannot be used together."
66
- usage
67
- fi
68
- FTL_FLAG=true
57
+ -l | --local)
69
58
DOCKER_BUILD_CMD+=" --build-arg FTL_SOURCE=local"
70
59
shift
71
60
;;
72
- -f | --ftlbranch)
73
- if [ " $FTL_FLAG " = true ]; then
74
- echo " Error: Both -l and -f cannot be used together."
75
- usage
76
- fi
77
- FTL_FLAG=true
61
+ -f | --ftlbranch)
78
62
FTL_BRANCH=" $2 "
79
63
check_branch_exists " ftl" " $FTL_BRANCH "
80
64
DOCKER_BUILD_CMD+=" --build-arg FTL_BRANCH=$FTL_BRANCH "
@@ -122,10 +106,8 @@ done
122
106
123
107
# Execute the docker build command
124
108
echo " Executing command: $DOCKER_BUILD_CMD "
125
- eval " ${DOCKER_BUILD_CMD} "
126
-
127
- # Check exit code of previous command
128
- if [ $? -ne 0 ]; then
109
+ # Execute the docker build command and check its exit status
110
+ if ! eval " ${DOCKER_BUILD_CMD} " ; then
129
111
echo " "
130
112
echo " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
131
113
echo " !! ERROR: Docker build failed, please review logs above !!"
0 commit comments