Skip to content

Commit d0da8d7

Browse files
committed
Create packagecheck.sh
It checks if package is installed
1 parent 99658c3 commit d0da8d7

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
@@ -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: joomla
2124
restart: unless-stopped
2225
ports:
@@ -32,7 +35,7 @@ services:
3235
TZ: '${LOCAL_TIMEZONE}'
3336
labels:
3437
- 'docker-volume-backup.stop-during-backup=true'
35-
entrypoint: bash -c "apt-get -y update && apt-get install -y golang git && go get github.com/mailhog/mhsendmail && cp /root/go/bin/mhsendmail /usr/bin/mhsendmail && 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; /entrypoint.sh 'php-fpm'"
38+
entrypoint: bash -c "apt-get -y update && sh /tmp/packagecheck.sh 'golang git' && go get github.com/mailhog/mhsendmail && cp /root/go/bin/mhsendmail /usr/bin/mhsendmail && 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; /entrypoint.sh 'php-fpm'"
3639

3740
webserver:
3841
depends_on:

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)