2024-11-02 13:47:50 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2024-11-11 16:56:16 +00:00
|
|
|
# docker-dotclear:x.x-anf
|
|
|
|
# Container starting script
|
2024-11-02 13:47:50 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2024-11-11 16:56:16 +00:00
|
|
|
# Read image version
|
|
|
|
export VER_DOTCLEAR=$(sed -n "s/^\s*\"release_version\":\s*\"\(.*\)\",/\1/p" /usr/src/dotclear/release.json)
|
|
|
|
|
|
|
|
# Simple versions comparison function that works with Dotclear versioning
|
|
|
|
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
|
|
|
|
|
|
|
|
# Check if Dotclear is already on system
|
2024-11-02 13:47:50 +00:00
|
|
|
if ! [ -e index.php -a -e src/App.php ]; then
|
|
|
|
# First installation
|
|
|
|
echo >&2 "Dotclear not found in $(pwd) - copying now..."
|
|
|
|
if [ "$(ls -A)" ]; then
|
|
|
|
echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!"
|
|
|
|
( set -x; ls -A; sleep 5 )
|
|
|
|
fi
|
2024-11-11 16:56:16 +00:00
|
|
|
echo >&2 "Copying Dotclear structure..."
|
|
|
|
cp -R /var/lib/dotclear /var/www
|
2024-11-02 13:47:50 +00:00
|
|
|
echo >&2 "Copying Dotclear files..."
|
|
|
|
tar cf - --one-file-system -C /usr/src/dotclear . | tar xf -
|
|
|
|
echo >&2 "Complete! Dotclear has been successfully copied to $(pwd)"
|
|
|
|
else
|
|
|
|
echo >&2 "Dotclear found in $(pwd), checking upgrade..."
|
|
|
|
# Check if Dotclear needs upgrade
|
|
|
|
VER_CURRENT=$(sed -n "s/^\s*\"release_version\":\s*\"\(.*\)\",/\1/p" release.json)
|
2024-11-11 16:56:16 +00:00
|
|
|
if [ $(version $VER_DOTCLEAR) -gt $(version $VER_CURRENT) ]; then
|
2024-11-02 13:47:50 +00:00
|
|
|
echo >&2 "Upgrading Dotclear files from ${VER_CURRENT} to ${VER_DOTCLEAR}, please wait..."
|
|
|
|
tar cf - --one-file-system -C /usr/src/dotclear . | tar xf -
|
|
|
|
echo >&2 "Complete! Dotclear files have been successfully upgraded to ${VER_DOTCLEAR}"
|
|
|
|
else
|
|
|
|
echo >&2 "No need to upgrade Dotclear ${VER_DOTCLEAR}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2024-11-12 20:12:07 +00:00
|
|
|
# DEBUG mode for unstable release
|
|
|
|
if [ "$CNL_DOTCLEAR" == "unstable" ]; then
|
|
|
|
echo >&2 "Enabling Dotclear DEBUG mode"
|
|
|
|
sed -i -e "s/ \/\*== DC_DEBUG ==/ \/\/\*== DC_DEBUG ==/g" /var/www/dotclear/app/src/Config.php
|
|
|
|
else
|
|
|
|
echo >&2 "Disabling Dotclear DEBUG mode"
|
|
|
|
sed -i -e "s/ \/\/\*== DC_DEBUG ==/ \/\*== DC_DEBUG ==/g" /var/www/dotclear/app/src/Config.php
|
|
|
|
fi
|
|
|
|
|
2024-11-11 16:56:16 +00:00
|
|
|
# Fix www permissions
|
2024-11-02 13:47:50 +00:00
|
|
|
echo >&2 "Setting up permissions..."
|
2024-11-11 16:56:16 +00:00
|
|
|
chown -R www:www /var/www/dotclear
|
2024-11-02 13:47:50 +00:00
|
|
|
|
2024-11-11 16:56:16 +00:00
|
|
|
# Print summary to docker logs
|
2024-11-02 13:47:50 +00:00
|
|
|
echo >&2 "Alpine $(cat /etc/alpine-release)"
|
|
|
|
echo >&2 "$(nginx -v)PHP $(php -r "echo PHP_VERSION;")"
|
|
|
|
echo >&2 "Dotclear: ${VER_DOTCLEAR}"
|
|
|
|
|
2024-11-11 16:56:16 +00:00
|
|
|
# Start web server
|
2024-11-02 13:47:50 +00:00
|
|
|
php-fpm83 -D # FPM must start first in daemon mode
|
|
|
|
nginx # Then nginx in no daemon mode
|
|
|
|
|
|
|
|
exec "$@"
|