Skip to content

Commit

Permalink
Merge pull request #446 from cytopia/custom-startup-scripts
Browse files Browse the repository at this point in the history
Custom startup scripts
  • Loading branch information
cytopia authored Dec 27, 2018
2 parents 3260e68 + 4e44082 commit 93c16d4
Show file tree
Hide file tree
Showing 40 changed files with 1,206 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .devilbox/www/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


$DEVILBOX_VERSION = 'v0.15';
$DEVILBOX_DATE = '2018-12-23';
$DEVILBOX_DATE = '2018-12-26';
$DEVILBOX_API_PAGE = 'devilbox-api/status.json';

//
Expand Down
2 changes: 1 addition & 1 deletion .devilbox/www/htdocs/info_vhostgen.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<p>Note: If the resulting virtual host config does not reflect the vhost-gen template changes, you will need to restart the Devilbox.</p>
<a href="/vhosts.php"><i class="fa fa-chevron-left" aria-hidden="true"></i> Overview</a><br/>
<br/><h3>virtual host config</h3><br/>
<a title="Virtual host: <?php echo $vHost['name'];?>.conf" target="_blank" href="/vhost.d/<?php echo $vhost;?>.conf">
<a title="Virtual host: <?php echo $vhost;?>.conf" target="_blank" href="/vhost.d/<?php echo $vhost;?>.conf">
<i class="fa fa-external-link" aria-hidden="true"></i> <?php echo $vhost;?>.conf
</a>
<br/><br/><h3>vhost-gen config</h3><br/>
Expand Down
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@
/cfg/php-fpm-7.3/*.conf
/cfg/php-fpm-7.4/*.conf

# Ignore custom PHP-FPM startup scripts
/cfg/php-startup-5.2/*.sh
/cfg/php-startup-5.3/*.sh
/cfg/php-startup-5.4/*.sh
/cfg/php-startup-5.5/*.sh
/cfg/php-startup-5.6/*.sh
/cfg/php-startup-7.0/*.sh
/cfg/php-startup-7.1/*.sh
/cfg/php-startup-7.2/*.sh
/cfg/php-startup-7.3/*.sh
/cfg/php-startup-7.4/*.sh

# Ignore custom PHP-FPM modules
/mod/php-fpm-5.2/*.so
/mod/php-fpm-5.3/*.so
Expand Down
23 changes: 21 additions & 2 deletions .tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ PROJECT = vhost-tests
VHOST = $(PROJECT).loc


# -------------------------------------------------------------------------------------------------
# Misc Targets
# -------------------------------------------------------------------------------------------------
update-readme:
cat "../README.md" \
| perl -00 -pe "s/<!-- modules -->.*<!-- \/modules -->/<!-- modules -->\n$$(./get-modules.sh)\n<!-- \/modules -->/s" \
> "../README.md"

# -------------------------------------------------------------------------------------------------
# Testing Targets
# -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -80,7 +88,7 @@ pull:
@echo "####################################################################################################"
@echo "# PULLING LATEST CONTAINER"
@echo "####################################################################################################"
cd $(DEVILBOX_PATH) && docker-compose pull
cd $(DEVILBOX_PATH) && until docker-compose pull; do sleep 1; done
@echo
@echo

Expand Down Expand Up @@ -136,7 +144,8 @@ info:
###
### Run tests
###
test: test-vhost test-intra
test: test-vhost test-intra test-startup


test-intra:
@echo "####################################################################################################"
Expand Down Expand Up @@ -270,6 +279,16 @@ test-vhost:
@echo


test-startup:
@echo "####################################################################################################"
@echo "# RUNNING TESTS: STARTUP"
@echo "####################################################################################################"
@echo
@if ! $(CURRENT_PATH)startup-tests/startup.sh; then \
exit 1; \
fi


# -------------------------------------------------------------------------------------------------
# Helper Targets
# -------------------------------------------------------------------------------------------------
Expand Down
233 changes: 233 additions & 0 deletions .tests/get-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
#!/usr/bin/env bash

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
COMPOSEPATH="${SCRIPTPATH}/.."
PHP_TAG="$( grep 'devilbox/php' "${COMPOSEPATH}/docker-compose.yml" | sed 's/^.*-work-//g' )"

###
### Get PHP modules (5 rounds)
###

if ! PHP52="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '52-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP52="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '52-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP52="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '52-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP52="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '52-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP52="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '52-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
>&2 echo "Failed to retrieve modules for PHP 5.2"
exit 1
fi
fi
fi
fi
fi
if ! PHP53="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '53-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP53="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '53-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP53="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '53-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP53="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '53-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP53="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '53-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
>&2 echo "Failed to retrieve modules for PHP 5.3"
exit 1
fi
fi
fi
fi
fi
if ! PHP54="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '54-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP54="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '54-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP54="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '54-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP54="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '54-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP54="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '54-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
>&2 echo "Failed to retrieve modules for PHP 5.4"
exit 1
fi
fi
fi
fi
fi
if ! PHP55="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '55-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP55="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '55-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP55="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '55-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP55="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '55-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP55="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '55-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
>&2 echo "Failed to retrieve modules for PHP 5.5"
exit 1
fi
fi
fi
fi
fi
if ! PHP56="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '56-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP56="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '56-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP56="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '56-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP56="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '56-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP56="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '56-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
>&2 echo "Failed to retrieve modules for PHP 5.6"
exit 1
fi
fi
fi
fi
fi
if ! PHP70="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '70-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP70="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '70-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP70="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '70-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP70="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '70-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP70="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '70-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
>&2 echo "Failed to retrieve modules for PHP 7.0"
exit 1
fi
fi
fi
fi
fi
if ! PHP71="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '71-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP71="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '71-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP71="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '71-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP71="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '71-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP71="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '71-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
>&2 echo "Failed to retrieve modules for PHP 7.1"
exit 1
fi
fi
fi
fi
fi
if ! PHP72="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '72-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP72="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '72-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP72="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '72-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP72="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '72-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP72="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '72-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
>&2 echo "Failed to retrieve modules for PHP 7.2"
exit 1
fi
fi
fi
fi
fi
if ! PHP73="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '73-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP73="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '73-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP73="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '73-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP73="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '73-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP73="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '73-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
>&2 echo "Failed to retrieve modules for PHP 7.3"
exit 1
fi
fi
fi
fi
fi
if ! PHP74="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '74-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP74="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '74-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP74="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '74-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP74="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '74-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
sleep 5;
if ! PHP74="$( curl -sS https://raw.githubusercontent.com/devilbox/docker-php-fpm/${PHP_TAG}/README.md | tac | tac | grep -E '74-mods' | sed -e 's/.*">//g' -e 's/<.*//g' )"; then
>&2 echo "Failed to retrieve modules for PHP 7.4"
exit 1
fi
fi
fi
fi
fi

ALL="$( echo "${PHP52}, ${PHP53}, ${PHP54}, ${PHP55}, ${PHP56}, ${PHP70}, ${PHP71}, ${PHP72}, ${PHP73}, ${PHP74}" | sed 's/,/\n/g' | sed -e 's/^\s*//g' -e 's/\s*$//g' | sort -u )"

Y=""

echo "| Modules | PHP 5.2 | PHP 5.3 | PHP 5.4 | PHP 5.5 | PHP 5.6 | PHP 7.0 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 |"
echo "|----------------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|"
echo "${ALL}" | while read line; do
printf "| %-15s%s" "${line}" "|"

if echo ",${PHP52}," | sed 's/,\s/,/g' | grep -Eq ",${line},"; then
printf " %s |" "${Y}"
else
printf " |"
fi
if echo ",${PHP53}," | sed 's/,\s/,/g' | grep -Eq ",${line},"; then
printf " %s |" "${Y}"
else
printf " |"
fi
if echo ",${PHP54}," | sed 's/,\s/,/g' | grep -Eq ",${line},"; then
printf " %s |" "${Y}"
else
printf " |"
fi
if echo ",${PHP55}," | sed 's/,\s/,/g' | grep -Eq ",${line},"; then
printf " %s |" "${Y}"
else
printf " |"
fi
if echo ",${PHP56}," | sed 's/,\s/,/g' | grep -Eq ",${line},"; then
printf " %s |" "${Y}"
else
printf " |"
fi
if echo ",${PHP70}," | sed 's/,\s/,/g' | grep -Eq ",${line},"; then
printf " %s |" "${Y}"
else
printf " |"
fi
if echo ",${PHP71}," | sed 's/,\s/,/g' | grep -Eq ",${line},"; then
printf " %s |" "${Y}"
else
printf " |"
fi
if echo ",${PHP72}," | sed 's/,\s/,/g' | grep -Eq ",${line},"; then
printf " %s |" "${Y}"
else
printf " |"
fi
if echo ",${PHP73}," | sed 's/,\s/,/g' | grep -Eq ",${line},"; then
printf " %s |" "${Y}"
else
printf " |"
fi
if echo ",${PHP74}," | sed 's/,\s/,/g' | grep -Eq ",${line},"; then
printf " %s |" "${Y}"
else
printf " |"
fi

printf "\n"
done
38 changes: 38 additions & 0 deletions .tests/startup-tests/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

set -e
set -u
set -o pipefail

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
COMPOSEPATH="${SCRIPTPATH}/../../"
CONTAINER="$( cd "${COMPOSEPATH}" && docker-compose ps -q php )"

#FILES="$()"
cd "${COMPOSEPATH}" && docker-compose exec -T php bash -c "find /startup.d/*.sh-example -type f -print0 2>/dev/null" \
| xargs -0 -n 1 echo \
| while read f; do

echo "# ----------------------------------------------------------------------------------------"
echo "# [TEST] ${f}"
echo "# ----------------------------------------------------------------------------------------"
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
sleep 5
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
sleep 5
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
sleep 5
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
sleep 5
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
echo "[FAIl] ${f}"
exit 1
fi
fi
fi
fi
fi
echo "[OK] ${f}"
echo
echo
done
Loading

0 comments on commit 93c16d4

Please sign in to comment.