Skip to content

Commit c569e94

Browse files
committed
Added more flexibillity for the command switching
1 parent 4e4017f commit c569e94

File tree

4 files changed

+81
-4
lines changed

4 files changed

+81
-4
lines changed

scripts/composer

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
#!/usr/bin/env bash
22

3-
docker-compose exec -e COMPOSER_MEMORY_LIMIT=-1 php-fpm composer $*
3+
# List of possible php containers
4+
CONTAINERS=("php-fpm" "php-fpm-xdebug")
5+
6+
# Find the active container
7+
for CONTAINER in "${CONTAINERS[@]}"; do
8+
if docker-compose ps --services --filter "status=running" | grep -q "^${CONTAINER}$"; then
9+
ACTIVE_CONTAINER=$CONTAINER
10+
break
11+
fi
12+
done
13+
14+
# Check if an active container is found
15+
if [ -z "$ACTIVE_CONTAINER" ]; then
16+
echo "No container of ${CONTAINERS[*]} inactive."
17+
exit 1
18+
fi
19+
20+
echo "The container is used: $ACTIVE_CONTAINER"
21+
22+
docker-compose exec -e COMPOSER_MEMORY_LIMIT=-1 "$ACTIVE_CONTAINER" composer "$@"

scripts/magento

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
#!/usr/bin/env bash
22

3-
docker-compose exec -T php-fpm /home/magento/bin/magento $*
3+
# List of possible php containers
4+
CONTAINERS=("php-fpm" "php-fpm-xdebug")
5+
6+
# Find the active container
7+
for CONTAINER in "${CONTAINERS[@]}"; do
8+
if docker-compose ps --services --filter "status=running" | grep -q "^${CONTAINER}$"; then
9+
ACTIVE_CONTAINER=$CONTAINER
10+
break
11+
fi
12+
done
13+
14+
# Check if an active container is found
15+
if [ -z "$ACTIVE_CONTAINER" ]; then
16+
echo "No container of ${CONTAINERS[*]} inactive."
17+
exit 1
18+
fi
19+
20+
echo "The container is used: $ACTIVE_CONTAINER"
21+
22+
docker-compose exec -T "$ACTIVE_CONTAINER" /home/magento/bin/magento "$@"

scripts/n98

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
#!/usr/bin/env bash
22

3-
docker-compose exec -T php-fpm /usr/local/bin/n98-magerun2 $*
3+
# List of possible php containers
4+
CONTAINERS=("php-fpm" "php-fpm-xdebug")
5+
6+
# Find the active container
7+
for CONTAINER in "${CONTAINERS[@]}"; do
8+
if docker-compose ps --services --filter "status=running" | grep -q "^${CONTAINER}$"; then
9+
ACTIVE_CONTAINER=$CONTAINER
10+
break
11+
fi
12+
done
13+
14+
# Check if an active container is found
15+
if [ -z "$ACTIVE_CONTAINER" ]; then
16+
echo "No container of ${CONTAINERS[*]} inactive."
17+
exit 1
18+
fi
19+
20+
echo "The container is used: $ACTIVE_CONTAINER"
21+
22+
docker-compose exec -T "$ACTIVE_CONTAINER" /usr/local/bin/n98-magerun2 "$@"

scripts/php

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
#!/usr/bin/env bash
22

3-
docker-compose exec -T php-fpm php $*
3+
# List of possible php containers
4+
CONTAINERS=("php-fpm" "php-fpm-xdebug")
5+
6+
# Find the active container
7+
for CONTAINER in "${CONTAINERS[@]}"; do
8+
if docker-compose ps --services --filter "status=running" | grep -q "^${CONTAINER}$"; then
9+
ACTIVE_CONTAINER=$CONTAINER
10+
break
11+
fi
12+
done
13+
14+
# Check if an active container is found
15+
if [ -z "$ACTIVE_CONTAINER" ]; then
16+
echo "No container of ${CONTAINERS[*]} inactive."
17+
exit 1
18+
fi
19+
20+
echo "The container is used: $ACTIVE_CONTAINER"
21+
22+
# Execution of the command
23+
docker-compose exec -T "$ACTIVE_CONTAINER" php "$@"

0 commit comments

Comments
 (0)