Skip to content

Commit ff318f9

Browse files
committed
Create packagecheck.sh
It checks if package is installed
1 parent b1f0474 commit ff318f9

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ services:
1717
- type: bind
1818
source: ./php-fpm/php-fpm.d/z-www.conf
1919
target: '${PHP_INI_DIR_PREFIX}/php-fpm.d/z-www.conf'
20+
- type: bind
21+
source: ./packagecheck.sh
22+
target: '/tmp/packagecheck.sh'
2023
hostname: website
2124
restart: unless-stopped
2225
ports:
@@ -38,7 +41,7 @@ services:
3841
labels:
3942
- 'docker-volume-backup.stop-during-backup=true'
4043
command: >
41-
bash -c "apt-get -y update && apt-get install -y libicu-dev gettext-base && docker-php-ext-install mysqli intl; pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis;
44+
bash -c "apt-get -y update && sh /tmp/packagecheck.sh 'gettext-base' && curl -sSL https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - | sh -s intl mysqli && pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis;
4245
envsubst '$${DB_USER},$${DB_PASSWORD},$${DB_NAME}' < ${WEBSERVER_DOC_ROOT}/index.php.template > ${WEBSERVER_DOC_ROOT}/index.php && grep -qe 'date.timezone = ${LOCAL_TIMEZONE}' ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini || echo 'date.timezone = ${LOCAL_TIMEZONE}' >> ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini; php-fpm"
4346
4447
webserver:
@@ -189,7 +192,7 @@ services:
189192
- "docker-volume-backup.stop-during-backup=true"
190193
- "docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump -uroot -p${MYSQL_ROOT_PASSWORD} --all-databases > /tmp/backup/db_backup_data.sql'"
191194
- "docker-volume-backup.exec-label=database"
192-
command: '--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password'
195+
command: bash -c "apt-get -y update && apt-get install -y gettext-base && export PMA_CONTROLUSER=${PMA_CONTROLUSER} export PMA_CONTROLPASS=${PMA_CONTROLPASS} && envsubst '$$PMA_CONTROLUSER,$$PMA_CONTROLPASS' < /docker-entrypoint-initdb.d/create_tables.sql.template > /docker-entrypoint-initdb.d/create_tables.sql && docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password"
193196

194197
redis:
195198
image: 'redis:latest'

packagecheck.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
PACKAGES=$1
4+
5+
notinstall_pkgs=""
6+
install=false
7+
8+
for pkg in $PACKAGES; do
9+
status="$(dpkg-query -W --showformat='${db:Status-Status}' "$pkg" 2>&1)"
10+
if [ ! $? = 0 ] || [ ! "$status" = installed ]; then
11+
install=true
12+
notinstall_pkgs=$pkg" "$notinstall_pkgs
13+
else
14+
installed_pkgs=$pkg" "$installed_pkgs
15+
fi
16+
done
17+
18+
if "$install"; then
19+
apt-get install -y --no-install-recommends $notinstall_pkgs && rm -rf /var/lib/apt/lists/*
20+
else
21+
echo "### WARNING ${installed_pkgs} Package[s] already installed. ###"
22+
fi

0 commit comments

Comments
 (0)