Skip to content

Commit d626248

Browse files
fix: add full paths for grep commands in cron scripts
- Add GREP_BIN variable to both Docker run and Docker Compose scripts - Use full paths for grep commands to handle cron environment limitations - Update path discovery section to include grep binary location - Ensure scripts work reliably in minimal cron PATH environment
1 parent aaeb063 commit d626248

File tree

1 file changed

+9
-3
lines changed
  • crowdsec-docs/unversioned/getting_started/installation

1 file changed

+9
-3
lines changed

crowdsec-docs/unversioned/getting_started/installation/docker.mdx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ For containers started with `docker run`, create this script:
143143
144144
CONTAINER_NAME="crowdsec" # Adjust to your container name
145145
DOCKER_BIN="/usr/bin/docker" # Adjust path if needed
146+
GREP_BIN="/usr/bin/grep" # Adjust path if needed
146147
147148
# Check if container is running
148-
if ! $DOCKER_BIN ps --format "table {{.Names}}" | grep -q "^${CONTAINER_NAME}$"; then
149+
if ! $DOCKER_BIN ps --format "table {{.Names}}" | $GREP_BIN -q "^${CONTAINER_NAME}$"; then
149150
echo "Container ${CONTAINER_NAME} is not running"
150151
exit 1
151152
fi
@@ -173,9 +174,10 @@ For Docker Compose deployments, use this script instead:
173174
174175
cd /path/to/your/docker-compose/directory # Adjust path
175176
DOCKER_BIN="/usr/bin/docker" # Adjust path if needed
177+
GREP_BIN="/usr/bin/grep" # Adjust path if needed
176178
177179
# Check if service is running
178-
if ! $DOCKER_BIN compose ps crowdsec | grep -q "Up"; then
180+
if ! $DOCKER_BIN compose ps crowdsec | $GREP_BIN -q "Up"; then
179181
echo "CrowdSec service is not running"
180182
exit 1
181183
fi
@@ -209,11 +211,15 @@ fi
209211
:::tip
210212
**Docker Compose is recommended** as it doesn't require knowing the exact container name and works with the service name from your `docker-compose.yml`.
211213

212-
**Finding Docker binary path:**
214+
**Finding binary paths:**
213215
```bash
214216
# Find docker binary (includes compose subcommand)
215217
which docker
216218
# Common paths: /usr/bin/docker, /usr/local/bin/docker
219+
220+
# Find grep binary
221+
which grep
222+
# Common paths: /usr/bin/grep, /bin/grep
217223
```
218224

219225
**Cron schedule examples:**

0 commit comments

Comments
 (0)