2018-12-02 02:08:31 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
|
2023-11-09 09:03:35 +01:00
|
|
|
if [[ -n "$NEXTCLOUD_PROJECT_NAME" ]]; then
|
2022-03-19 20:00:38 +01:00
|
|
|
containerName="${NEXTCLOUD_PROJECT_NAME}[_-]"
|
2022-03-19 20:15:31 +01:00
|
|
|
matchEnd="[\._-]\d+"
|
2019-06-21 02:15:55 +02:00
|
|
|
else
|
2022-03-19 20:15:31 +01:00
|
|
|
matchEnd=","
|
2019-06-21 02:15:55 +02:00
|
|
|
fi
|
2018-12-02 02:08:31 +01:00
|
|
|
|
2019-06-21 02:15:55 +02:00
|
|
|
containerName="${containerName}${NEXTCLOUD_CONTAINER_NAME}"
|
|
|
|
|
2023-08-07 22:26:14 +02:00
|
|
|
# Get the ID of the first matching container so we can exec something in it later
|
2018-12-02 02:08:31 +01:00
|
|
|
docker ps --format '{{.Names}},{{.ID}}' | \
|
2023-11-09 09:03:35 +01:00
|
|
|
grep -E "^${containerName}${matchEnd}" | \
|
2023-08-07 22:26:14 +02:00
|
|
|
awk '{split($0,a,","); print a[2]}' | \
|
|
|
|
head -n 1
|