Skip to content

Commit c1ced35

Browse files
committed
Create packagecheck.sh
It checks if package is installed
1 parent 24b96da commit c1ced35

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ services:
1818
- type: bind
1919
source: ./php-fpm/php-fpm.d/z-www.conf
2020
target: '${PHP_INI_DIR_PREFIX}/php-fpm.d/z-www.conf'
21+
- type: bind
22+
source: ./packagecheck.sh
23+
target: '/tmp/packagecheck.sh'
2124
hostname: yii
2225
restart: unless-stopped
2326
ports:
@@ -39,7 +42,7 @@ services:
3942
labels:
4043
- 'docker-volume-backup.stop-during-backup=true'
4144
command: >
42-
bash -c "apt-get -y update && apt-get install -y zip unzip libicu-dev gettext-base && docker-php-ext-install intl && if pecl install -p -- redis; then pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis; fi; curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer &&
45+
bash -c "apt-get -y update && sh /tmp/packagecheck.sh 'zip unzip gettext-base' && curl -sSL https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - | sh -s intl && if pecl install -p -- redis; then pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis; fi; curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer &&
4346
if [ -f \"${WEBSERVER_DOC_ROOT}/web.php\" ]; then composer update --prefer-dist yiisoft/yii2-app-basic --working-dir=/app/basic; else composer create-project --prefer-dist yiisoft/yii2-app-basic basic; fi &&
4447
composer require --prefer-dist "yiisoft/yii2-redis":~2.0.0 --working-dir=/app/basic; cp -R /app/basic/web/css ${WEBSERVER_DOC_ROOT}/; envsubst '$${DB_USER},$${DB_PASSWORD},$${DB_NAME}' < ${WEBSERVER_DOC_ROOT}/db.php.template > ${WEBSERVER_DOC_ROOT}/db.php &&
4548
export RANDOM_VALUE=$(tr -dc '[:alnum:]' </dev/urandom | head -c 32) && envsubst '$$RANDOM_VALUE' < ${WEBSERVER_DOC_ROOT}/web.php.template > ${WEBSERVER_DOC_ROOT}/web.php &&

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)