Merge pull request #88 from nupplaphil/task/mysql_wait

Add MySQL DB wait possibility
This commit is contained in:
Hypolite Petovan 2019-11-28 16:08:36 -05:00 committed by GitHub
commit ba7371ad99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 692 additions and 361 deletions

47
.bin/wait-for-connection Executable file
View File

@ -0,0 +1,47 @@
#!/usr/local/bin/php
<?php
/**
* This script tries to connect to a database for a given interval
* Useful in case of installation e.g. to wait for the database to not generate unnecessary errors
*
* Usage: php bin/wait-for-connection {HOST} {PORT} [{TIMEOUT}]
*/
$timeout = 60;
switch ($argc) {
case 4:
$timeout = (float)$argv[3];
case 3:
$host = $argv[1];
$port = (int)$argv[2];
break;
default:
fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n");
exit(2);
}
if ($timeout < 0) {
fwrite(STDERR, 'Timeout must be greater than zero'."\n");
exit(2);
}
if ($port < 1) {
fwrite(STDERR, 'Port must be an integer greater than zero'."\n");
exit(2);
}
$socketTimeout = (float)ini_get('default_socket_timeout');
if ($socketTimeout > $timeout) {
$socketTimeout = $timeout;
}
$stopTime = time() + $timeout;
do {
$sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout);
if ($sock !== false) {
fclose($sock);
fwrite(STDOUT, "\n");
exit(0);
}
sleep(1);
fwrite(STDOUT, '.');
} while (time() < $stopTime);
fwrite(STDOUT, "\n");
exit(1);

View File

@ -24,7 +24,8 @@ services:
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- SITENAME=
- FRIENDICA_URL=
- FRIENDICA_SITENAME=
- SMTP=
env_file:
- db.env
@ -42,6 +43,8 @@ services:
entrypoint: /cron.sh
depends_on:
- db
env_file:
- db.env
hostname: friendica.local
volumes:

View File

@ -24,8 +24,9 @@ services:
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- SITENAME=
- SMTP=
- FRIENDICA_URL=
- FRIENDICA_SITENAME=
- SMTP=
env_file:
- db.env
depends_on:

View File

@ -24,7 +24,8 @@ services:
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- SITENAME=
- FRIENDICA_URL=
- FRIENDICA_SITENAME=
- SMTP=
env_file:
- db.env

View File

@ -1,78 +1,76 @@
version: '2.1'
services:
db:
image: mariadb
restart: always
volumes:
- db:/var/lib/mysql/
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
env_file:
- db.env
app:
build: ./app
restart: always
volumes:
- friendica:/var/www/html
environment:
- AUTOINSTALL=true
- MAILNAME=
- TZ=
- LANGUAGE=
env_file:
- db.env
depends_on:
- db
hostname: friendica.local
labels:
- "traefik.backend=friendica"
- "traefik.frontend.entryPoints=https"
- "traefik.frontend.headers.SSLRedirect=true"
- "traefik.frontend.headers.STSSeconds=15768000"
- "traefik.frontend.headers.STSIncludeSubdomains=false"
- "traefik.frontend.headers.forceSTSHeader=true"
- "traefik.friendica.frontend.rule=Host:friendica.local"
- "traefik.friendica.frontend.port=80"
- "traefik.enable=true"
- "traefik.docker.network=proxy-tier"
networks:
- proxy-tier
- default
cron:
build: ./app
restart: always
volumes:
- friendica:/var/www/html
entrypoint: /cron.sh
environment:
- MAILNAME=
- TZ=
- LANGUAGE=
env_file:
- db.env
depends_on:
- db
hostname: friendica.local
proxy:
build: ./proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
container_name: traefik
networks:
- default
- proxy-tier
volumes:
db:
friendica:
networks:
version: '2.1'
services:
db:
image: mariadb
restart: always
volumes:
- db:/var/lib/mysql/
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
env_file:
- db.env
app:
build: ./app
restart: always
volumes:
- friendica:/var/www/html
environment:
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- FRIENDICA_URL=
- FRIENDICA_SITENAME=
- SMTP=
env_file:
- db.env
depends_on:
- db
hostname: friendica.local
labels:
- "traefik.backend=friendica"
- "traefik.frontend.entryPoints=https"
- "traefik.frontend.headers.SSLRedirect=true"
- "traefik.frontend.headers.STSSeconds=15768000"
- "traefik.frontend.headers.STSIncludeSubdomains=false"
- "traefik.frontend.headers.forceSTSHeader=true"
- "traefik.friendica.frontend.rule=Host:friendica.local"
- "traefik.friendica.frontend.port=80"
- "traefik.enable=true"
- "traefik.docker.network=proxy-tier"
networks:
- proxy-tier
- default
cron:
build: ./app
restart: always
volumes:
- friendica:/var/www/html
entrypoint: /cron.sh
env_file:
- db.env
depends_on:
- db
hostname: friendica.local
proxy:
build: ./proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
container_name: traefik
networks:
- default
- proxy-tier
volumes:
db:
friendica:
networks:
proxy-tier:

View File

@ -20,6 +20,9 @@ services:
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- FRIENDICA_URL=
- FRIENDICA_SITENAME=
- SMTP=
env_file:
- db.env
depends_on:
@ -32,10 +35,6 @@ services:
volumes:
- friendica:/var/www/html
entrypoint: /cron.sh
environment:
- MAILNAME=
- TZ=
- LANGUAGE=
env_file:
- db.env
depends_on:

View File

@ -1,87 +1,85 @@
version: '2.1'
services:
db:
image: mariadb
restart: always
volumes:
- db:/var/lib/mysql/
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
env_file:
- db.env
app:
build: ./app
restart: always
volumes:
- friendica:/var/www/html
environment:
- AUTOINSTALL=true
- MAILNAME=
- TZ=
- LANGUAGE=
env_file:
- db.env
depends_on:
- db
hostname: friendica.local
cron:
build: ./app
restart: always
volumes:
- friendica:/var/www/html
entrypoint: /cron.sh
environment:
- MAILNAME=
- TZ=
- LANGUAGE=
env_file:
- db.env
depends_on:
- db
- app
hostname: friendica.local
web:
image: nginx
restart: always
volumes:
- friendica:/var/www/html:ro
- ./web/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- app
networks:
- default
- proxy-tier
labels:
- "traefik.backend=friendica"
- "traefik.frontend.entryPoints=https,http"
- "traefik.frontend.headers.STSSeconds=15768000"
- "traefik.frontend.headers.STSIncludeSubdomains=false"
- "traefik.frontend.headers.forceSTSHeader=true"
- "traefik.friendica.frontend.rule=Host:friendica.local"
- "traefik.friendica.frontend.port=80"
- "traefik.enable=true"
- "traefik.docker.network=proxy-tier"
proxy:
build: ./proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
container_name: traefik
networks:
- default
- proxy-tier
volumes:
db:
friendica:
networks:
version: '2.1'
services:
db:
image: mariadb
restart: always
volumes:
- db:/var/lib/mysql/
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
env_file:
- db.env
app:
build: ./app
restart: always
volumes:
- friendica:/var/www/html
environment:
- FRIENDICA_ADMIN_MAIL=
- FRIENDICA_TZ=
- FRIENDICA_LANG=
- FRIENDICA_URL=
- FRIENDICA_SITENAME=
- SMTP=
env_file:
- db.env
depends_on:
- db
hostname: friendica.local
cron:
build: ./app
restart: always
volumes:
- friendica:/var/www/html
entrypoint: /cron.sh
env_file:
- db.env
depends_on:
- db
- app
hostname: friendica.local
web:
image: nginx
restart: always
volumes:
- friendica:/var/www/html:ro
- ./web/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- app
networks:
- default
- proxy-tier
labels:
- "traefik.backend=friendica"
- "traefik.frontend.entryPoints=https,http"
- "traefik.frontend.headers.STSSeconds=15768000"
- "traefik.frontend.headers.STSIncludeSubdomains=false"
- "traefik.frontend.headers.forceSTSHeader=true"
- "traefik.friendica.frontend.rule=Host:friendica.local"
- "traefik.friendica.frontend.port=80"
- "traefik.enable=true"
- "traefik.docker.network=proxy-tier"
proxy:
build: ./proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
container_name: traefik
networks:
- default
- proxy-tier
volumes:
db:
friendica:
networks:
proxy-tier:

View File

@ -140,6 +140,7 @@ RUN set -ex; \
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
COPY bin/* /usr/local/bin/
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]

View File

@ -0,0 +1,47 @@
#!/usr/local/bin/php
<?php
/**
* This script tries to connect to a database for a given interval
* Useful in case of installation e.g. to wait for the database to not generate unnecessary errors
*
* Usage: php bin/wait-for-connection {HOST} {PORT} [{TIMEOUT}]
*/
$timeout = 60;
switch ($argc) {
case 4:
$timeout = (float)$argv[3];
case 3:
$host = $argv[1];
$port = (int)$argv[2];
break;
default:
fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n");
exit(2);
}
if ($timeout < 0) {
fwrite(STDERR, 'Timeout must be greater than zero'."\n");
exit(2);
}
if ($port < 1) {
fwrite(STDERR, 'Port must be an integer greater than zero'."\n");
exit(2);
}
$socketTimeout = (float)ini_get('default_socket_timeout');
if ($socketTimeout > $timeout) {
$socketTimeout = $timeout;
}
$stopTime = time() + $timeout;
do {
$sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout);
if ($sock !== false) {
fclose($sock);
fwrite(STDOUT, "\n");
exit(0);
}
sleep(1);
fwrite(STDOUT, '.');
} while (time() < $stopTime);
fwrite(STDOUT, "\n");
exit(1);

View File

@ -1,11 +1,12 @@
#!/bin/sh
trap "break;exit" HUP INT TERM
while [ ! -f /var/www/html/config/local.ini.php ] && [ ! -f /var/www/html/config/local.config.php ]; do
while [ ! -f /var/www/html/bin/daemon.php ]; do
sleep 1
done
# TODO let the database and the autoinstall time to complete - not winning a beauty contest
sleep 15s
exec php /var/www/html/bin/daemon.php -f start
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
exec php /var/www/html/bin/daemon.php -f start
echo "[ERROR] Waited 300 seconds, no response" >&2
fi

View File

@ -17,14 +17,14 @@ version_greater() {
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
if [ -n "${FRIENDICA_SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$FRIENDICA_SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:root:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
@ -100,7 +100,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n "${FRIENDICA_ADMIN_MAIL+x}" ] && [ -n "${FRIENDICA_URL+x}" ]; then
echo "Installation with environment variables"
FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
@ -117,30 +117,28 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.config.php" ]; then
echo "Installation with prepared local.config.php"
install_options="-f /usr/src/local.config.php"
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'" --url "'$FRIENDICA_URL'"'
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
echo "Starting Friendica installation ..."
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "[ERROR] Waited 300 seconds, no response" >&2
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi

View File

@ -116,6 +116,7 @@ RUN set -ex; \
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
COPY bin/* /usr/local/bin/
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View File

@ -0,0 +1,47 @@
#!/usr/local/bin/php
<?php
/**
* This script tries to connect to a database for a given interval
* Useful in case of installation e.g. to wait for the database to not generate unnecessary errors
*
* Usage: php bin/wait-for-connection {HOST} {PORT} [{TIMEOUT}]
*/
$timeout = 60;
switch ($argc) {
case 4:
$timeout = (float)$argv[3];
case 3:
$host = $argv[1];
$port = (int)$argv[2];
break;
default:
fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n");
exit(2);
}
if ($timeout < 0) {
fwrite(STDERR, 'Timeout must be greater than zero'."\n");
exit(2);
}
if ($port < 1) {
fwrite(STDERR, 'Port must be an integer greater than zero'."\n");
exit(2);
}
$socketTimeout = (float)ini_get('default_socket_timeout');
if ($socketTimeout > $timeout) {
$socketTimeout = $timeout;
}
$stopTime = time() + $timeout;
do {
$sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout);
if ($sock !== false) {
fclose($sock);
fwrite(STDOUT, "\n");
exit(0);
}
sleep(1);
fwrite(STDOUT, '.');
} while (time() < $stopTime);
fwrite(STDOUT, "\n");
exit(1);

View File

@ -1,11 +1,12 @@
#!/bin/sh
trap "break;exit" HUP INT TERM
while [ ! -f /var/www/html/config/local.ini.php ] && [ ! -f /var/www/html/config/local.config.php ]; do
while [ ! -f /var/www/html/bin/daemon.php ]; do
sleep 1
done
# TODO let the database and the autoinstall time to complete - not winning a beauty contest
sleep 15s
exec php /var/www/html/bin/daemon.php -f start
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
exec php /var/www/html/bin/daemon.php -f start
echo "[ERROR] Waited 300 seconds, no response" >&2
fi

View File

@ -17,14 +17,14 @@ version_greater() {
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
if [ -n "${FRIENDICA_SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$FRIENDICA_SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:root:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
@ -100,7 +100,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n "${FRIENDICA_ADMIN_MAIL+x}" ] && [ -n "${FRIENDICA_URL+x}" ]; then
echo "Installation with environment variables"
FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
@ -117,30 +117,28 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.config.php" ]; then
echo "Installation with prepared local.config.php"
install_options="-f /usr/src/local.config.php"
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'" --url "'$FRIENDICA_URL'"'
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
echo "Starting Friendica installation ..."
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "[ERROR] Waited 300 seconds, no response" >&2
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi

View File

@ -131,6 +131,7 @@ RUN set -ex; \
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
COPY bin/* /usr/local/bin/
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]

View File

@ -0,0 +1,47 @@
#!/usr/local/bin/php
<?php
/**
* This script tries to connect to a database for a given interval
* Useful in case of installation e.g. to wait for the database to not generate unnecessary errors
*
* Usage: php bin/wait-for-connection {HOST} {PORT} [{TIMEOUT}]
*/
$timeout = 60;
switch ($argc) {
case 4:
$timeout = (float)$argv[3];
case 3:
$host = $argv[1];
$port = (int)$argv[2];
break;
default:
fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n");
exit(2);
}
if ($timeout < 0) {
fwrite(STDERR, 'Timeout must be greater than zero'."\n");
exit(2);
}
if ($port < 1) {
fwrite(STDERR, 'Port must be an integer greater than zero'."\n");
exit(2);
}
$socketTimeout = (float)ini_get('default_socket_timeout');
if ($socketTimeout > $timeout) {
$socketTimeout = $timeout;
}
$stopTime = time() + $timeout;
do {
$sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout);
if ($sock !== false) {
fclose($sock);
fwrite(STDOUT, "\n");
exit(0);
}
sleep(1);
fwrite(STDOUT, '.');
} while (time() < $stopTime);
fwrite(STDOUT, "\n");
exit(1);

View File

@ -1,11 +1,12 @@
#!/bin/sh
trap "break;exit" HUP INT TERM
while [ ! -f /var/www/html/config/local.ini.php ] && [ ! -f /var/www/html/config/local.config.php ]; do
while [ ! -f /var/www/html/bin/daemon.php ]; do
sleep 1
done
# TODO let the database and the autoinstall time to complete - not winning a beauty contest
sleep 15s
exec php /var/www/html/bin/daemon.php -f start
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
exec php /var/www/html/bin/daemon.php -f start
echo "[ERROR] Waited 300 seconds, no response" >&2
fi

View File

@ -17,14 +17,14 @@ version_greater() {
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
if [ -n "${FRIENDICA_SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$FRIENDICA_SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:root:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
@ -100,7 +100,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n "${FRIENDICA_ADMIN_MAIL+x}" ] && [ -n "${FRIENDICA_URL+x}" ]; then
echo "Installation with environment variables"
FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
@ -117,30 +117,28 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.config.php" ]; then
echo "Installation with prepared local.config.php"
install_options="-f /usr/src/local.config.php"
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'" --url "'$FRIENDICA_URL'"'
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
echo "Starting Friendica installation ..."
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "[ERROR] Waited 300 seconds, no response" >&2
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi

View File

@ -126,6 +126,7 @@ ENV FRIENDICA_ADDONS 2019.12-dev
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
COPY bin/* /usr/local/bin/
ENTRYPOINT ["/entrypoint-dev.sh"]
CMD ["apache2-foreground"]

View File

@ -0,0 +1,47 @@
#!/usr/local/bin/php
<?php
/**
* This script tries to connect to a database for a given interval
* Useful in case of installation e.g. to wait for the database to not generate unnecessary errors
*
* Usage: php bin/wait-for-connection {HOST} {PORT} [{TIMEOUT}]
*/
$timeout = 60;
switch ($argc) {
case 4:
$timeout = (float)$argv[3];
case 3:
$host = $argv[1];
$port = (int)$argv[2];
break;
default:
fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n");
exit(2);
}
if ($timeout < 0) {
fwrite(STDERR, 'Timeout must be greater than zero'."\n");
exit(2);
}
if ($port < 1) {
fwrite(STDERR, 'Port must be an integer greater than zero'."\n");
exit(2);
}
$socketTimeout = (float)ini_get('default_socket_timeout');
if ($socketTimeout > $timeout) {
$socketTimeout = $timeout;
}
$stopTime = time() + $timeout;
do {
$sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout);
if ($sock !== false) {
fclose($sock);
fwrite(STDOUT, "\n");
exit(0);
}
sleep(1);
fwrite(STDOUT, '.');
} while (time() < $stopTime);
fwrite(STDOUT, "\n");
exit(1);

View File

@ -1,11 +1,12 @@
#!/bin/sh
trap "break;exit" HUP INT TERM
while [ ! -f /var/www/html/config/local.ini.php ] && [ ! -f /var/www/html/config/local.config.php ]; do
while [ ! -f /var/www/html/bin/daemon.php ]; do
sleep 1
done
# TODO let the database and the autoinstall time to complete - not winning a beauty contest
sleep 15s
exec php /var/www/html/bin/daemon.php -f start
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
exec php /var/www/html/bin/daemon.php -f start
echo "[ERROR] Waited 300 seconds, no response" >&2
fi

View File

@ -17,14 +17,14 @@ version_greater() {
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
if [ -n "${FRIENDICA_SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$FRIENDICA_SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:root:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
@ -100,7 +100,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n "${FRIENDICA_ADMIN_MAIL+x}" ] && [ -n "${FRIENDICA_URL+x}" ]; then
echo "Installation with environment variables"
FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
@ -117,30 +117,28 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.config.php" ]; then
echo "Installation with prepared local.config.php"
install_options="-f /usr/src/local.config.php"
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'" --url "'$FRIENDICA_URL'"'
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
echo "Starting Friendica installation ..."
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "[ERROR] Waited 300 seconds, no response" >&2
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi

View File

@ -102,6 +102,7 @@ ENV FRIENDICA_ADDONS 2019.12-dev
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
COPY bin/* /usr/local/bin/
ENTRYPOINT ["/entrypoint-dev.sh"]
CMD ["php-fpm"]

View File

@ -0,0 +1,47 @@
#!/usr/local/bin/php
<?php
/**
* This script tries to connect to a database for a given interval
* Useful in case of installation e.g. to wait for the database to not generate unnecessary errors
*
* Usage: php bin/wait-for-connection {HOST} {PORT} [{TIMEOUT}]
*/
$timeout = 60;
switch ($argc) {
case 4:
$timeout = (float)$argv[3];
case 3:
$host = $argv[1];
$port = (int)$argv[2];
break;
default:
fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n");
exit(2);
}
if ($timeout < 0) {
fwrite(STDERR, 'Timeout must be greater than zero'."\n");
exit(2);
}
if ($port < 1) {
fwrite(STDERR, 'Port must be an integer greater than zero'."\n");
exit(2);
}
$socketTimeout = (float)ini_get('default_socket_timeout');
if ($socketTimeout > $timeout) {
$socketTimeout = $timeout;
}
$stopTime = time() + $timeout;
do {
$sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout);
if ($sock !== false) {
fclose($sock);
fwrite(STDOUT, "\n");
exit(0);
}
sleep(1);
fwrite(STDOUT, '.');
} while (time() < $stopTime);
fwrite(STDOUT, "\n");
exit(1);

View File

@ -1,11 +1,12 @@
#!/bin/sh
trap "break;exit" HUP INT TERM
while [ ! -f /var/www/html/config/local.ini.php ] && [ ! -f /var/www/html/config/local.config.php ]; do
while [ ! -f /var/www/html/bin/daemon.php ]; do
sleep 1
done
# TODO let the database and the autoinstall time to complete - not winning a beauty contest
sleep 15s
exec php /var/www/html/bin/daemon.php -f start
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
exec php /var/www/html/bin/daemon.php -f start
echo "[ERROR] Waited 300 seconds, no response" >&2
fi

View File

@ -17,14 +17,14 @@ version_greater() {
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
if [ -n "${FRIENDICA_SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$FRIENDICA_SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:root:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
@ -100,7 +100,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n "${FRIENDICA_ADMIN_MAIL+x}" ] && [ -n "${FRIENDICA_URL+x}" ]; then
echo "Installation with environment variables"
FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
@ -117,30 +117,28 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.config.php" ]; then
echo "Installation with prepared local.config.php"
install_options="-f /usr/src/local.config.php"
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'" --url "'$FRIENDICA_URL'"'
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
echo "Starting Friendica installation ..."
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "[ERROR] Waited 300 seconds, no response" >&2
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi

View File

@ -117,6 +117,7 @@ ENV FRIENDICA_ADDONS 2019.12-dev
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
COPY bin/* /usr/local/bin/
ENTRYPOINT ["/entrypoint-dev.sh"]
CMD ["php-fpm"]

View File

@ -0,0 +1,47 @@
#!/usr/local/bin/php
<?php
/**
* This script tries to connect to a database for a given interval
* Useful in case of installation e.g. to wait for the database to not generate unnecessary errors
*
* Usage: php bin/wait-for-connection {HOST} {PORT} [{TIMEOUT}]
*/
$timeout = 60;
switch ($argc) {
case 4:
$timeout = (float)$argv[3];
case 3:
$host = $argv[1];
$port = (int)$argv[2];
break;
default:
fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n");
exit(2);
}
if ($timeout < 0) {
fwrite(STDERR, 'Timeout must be greater than zero'."\n");
exit(2);
}
if ($port < 1) {
fwrite(STDERR, 'Port must be an integer greater than zero'."\n");
exit(2);
}
$socketTimeout = (float)ini_get('default_socket_timeout');
if ($socketTimeout > $timeout) {
$socketTimeout = $timeout;
}
$stopTime = time() + $timeout;
do {
$sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout);
if ($sock !== false) {
fclose($sock);
fwrite(STDOUT, "\n");
exit(0);
}
sleep(1);
fwrite(STDOUT, '.');
} while (time() < $stopTime);
fwrite(STDOUT, "\n");
exit(1);

View File

@ -1,11 +1,12 @@
#!/bin/sh
trap "break;exit" HUP INT TERM
while [ ! -f /var/www/html/config/local.ini.php ] && [ ! -f /var/www/html/config/local.config.php ]; do
while [ ! -f /var/www/html/bin/daemon.php ]; do
sleep 1
done
# TODO let the database and the autoinstall time to complete - not winning a beauty contest
sleep 15s
exec php /var/www/html/bin/daemon.php -f start
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
exec php /var/www/html/bin/daemon.php -f start
echo "[ERROR] Waited 300 seconds, no response" >&2
fi

View File

@ -17,14 +17,14 @@ version_greater() {
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
if [ -n "${FRIENDICA_SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$FRIENDICA_SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:root:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
@ -100,7 +100,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n "${FRIENDICA_ADMIN_MAIL+x}" ] && [ -n "${FRIENDICA_URL+x}" ]; then
echo "Installation with environment variables"
FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
@ -117,30 +117,28 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.config.php" ]; then
echo "Installation with prepared local.config.php"
install_options="-f /usr/src/local.config.php"
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'" --url "'$FRIENDICA_URL'"'
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
echo "Starting Friendica installation ..."
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "[ERROR] Waited 300 seconds, no response" >&2
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi

View File

@ -101,6 +101,7 @@ ENV FRIENDICA_ADDONS %%VERSION%%
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
COPY bin/* /usr/local/bin/
ENTRYPOINT ["/%%ENTRYPOINT%%"]
CMD ["%%CMD%%"]

View File

@ -116,6 +116,7 @@ ENV FRIENDICA_ADDONS %%VERSION%%
COPY *.sh upgrade.exclude /
COPY config/* /usr/src/friendica/config/
COPY bin/* /usr/local/bin/
ENTRYPOINT ["/%%ENTRYPOINT%%"]
CMD ["%%CMD%%"]

View File

@ -67,7 +67,7 @@ There are three options to enable the cron-job for Friendica:
## Possible Environment Variables
**Friendica Settings**
- `FRIENDICA_ADMIN_MAIL` E-Mail address of the administrator.
- `FRIENDICA_URL` The Friendica URL path.
- `FRIENDICA_TZ` The default localization of the Friendica server.
- `FRIENDICA_LANG` The default language of the Friendica server.
- `FRIENDICA_PHP_PATH` The path of the PHP binary.

View File

@ -1,11 +1,12 @@
#!/bin/sh
trap "break;exit" HUP INT TERM
while [ ! -f /var/www/html/config/local.ini.php ] && [ ! -f /var/www/html/config/local.config.php ]; do
while [ ! -f /var/www/html/bin/daemon.php ]; do
sleep 1
done
# TODO let the database and the autoinstall time to complete - not winning a beauty contest
sleep 15s
exec php /var/www/html/bin/daemon.php -f start
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
exec php /var/www/html/bin/daemon.php -f start
echo "[ERROR] Waited 300 seconds, no response" >&2
fi

View File

@ -17,14 +17,14 @@ version_greater() {
}
setup_ssmtp() {
if [ -n "${SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$SITENAME' with '$SMTP' ..."
if [ -n "${FRIENDICA_SITENAME+x}" ] && [ -n "${SMTP+x}" ] && [ "${SMTP}" != "localhost" ]; then
echo "Setup SSMTP for '$FRIENDICA_SITENAME' with '$SMTP' ..."
smtp_from=${SMTP_FROM:-no-reply}
# Setup SSMTP
sed -i "s/:root:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${SITENAME}:/g" /etc/passwd
sed -i "s/:root:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
sed -i "s/:Linux\ User:/:${FRIENDICA_SITENAME}:/g" /etc/passwd
# add possible mail-senders
{
@ -100,7 +100,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
echo "New Friendica instance"
install=false
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n ${FRIENDICA_ADMIN_MAIL+x} ]; then
if [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ] && [ -n "${MYSQL_USER+x}" -o -n "${MYSQL_USERNAME+x}" ] && [ -n "${FRIENDICA_ADMIN_MAIL+x}" ] && [ -n "${FRIENDICA_URL+x}" ]; then
echo "Installation with environment variables"
FRIENDICA_PHP_PATH=${FRIENDICA_PHP_PATH:-/usr/local/php}
@ -117,30 +117,28 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
install_options='-s --dbhost "'$MYSQL_HOST'" --dbport "'$MYSQL_PORT'" --dbdata "'$MYSQL_DATABASE'" --dbuser "'$MYSQL_USERNAMEFULL'" --dbpass "'$MYSQL_PASSWORD'"'
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'"'
install=true
elif [ -f "/usr/src/config/local.config.php" ]; then
echo "Installation with prepared local.config.php"
install_options="-f /usr/src/local.config.php"
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'" --url "'$FRIENDICA_URL'"'
install=true
fi
if [ "$install" = true ]; then
echo "Starting Friendica installation ..."
# TODO Let the database time to warm up - not winning a beauty contest
sleep 10s
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
echo "Waiting for MySQL $MYSQL_HOST initialization..."
if /usr/local/bin/wait-for-connection "$MYSQL_HOST" "$MYSQL_PORT" 300; then
# TODO Workaround because of a strange permission issue
rm -fr /var/www/html/view/smarty3/compiled
echo "Starting Friendica installation ..."
run_as "php /var/www/html/bin/console.php autoinstall $install_options"
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
rm -fr /var/www/html/view/smarty3/compiled
# load other config files (*.config.php) to the config folder
if [ -d "/usr/src/config" ]; then
rsync $rsync_options --ignore-existing /usr/src/config/ /var/www/html/config/
fi
echo "Installation finished"
else
echo "[ERROR] Waited 300 seconds, no response" >&2
fi
echo "Installation finished"
else
echo "Running web-based installer on first connect!"
fi

View File

@ -135,6 +135,7 @@ function create_variant() {
cp upgrade.exclude "$dir/"
cp -rT .config "$dir/config"
cp -rT .bin "$dir/bin"
travisEnvAmd64='\n - env: VERSION='"$dockerName"' VARIANT='"$variant"' ARCH=amd64'"$travisEnvAmd64"
for arch in i386 amd64; do