From 6e566394d200583396d4248d5420018adc420742 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sat, 16 Nov 2019 21:55:08 +0100 Subject: [PATCH 1/3] improve "run_as()" now runs inside the /var/www/html directory --- 2019.09/apache/entrypoint.sh | 9 +++++---- 2019.09/fpm-alpine/entrypoint.sh | 9 +++++---- 2019.09/fpm/entrypoint.sh | 9 +++++---- 2019.12-dev/apache/entrypoint.sh | 9 +++++---- 2019.12-dev/fpm-alpine/entrypoint.sh | 9 +++++---- 2019.12-dev/fpm/entrypoint.sh | 9 +++++---- docker-entrypoint.sh | 9 +++++---- 7 files changed, 35 insertions(+), 28 deletions(-) diff --git a/2019.09/apache/entrypoint.sh b/2019.09/apache/entrypoint.sh index 9c7ea16..05d629f 100755 --- a/2019.09/apache/entrypoint.sh +++ b/2019.09/apache/entrypoint.sh @@ -3,10 +3,11 @@ set -eu # run an command with the www-data user run_as() { + set -- -eu -c "cd /var/www/html; $*" if [ "$(id -u)" -eq 0 ]; then - su - www-data -s /bin/sh -c "cd /var/www/html;$1" + su - www-data -s /bin/sh "$@" else - sh -c "$1" + sh "$@" fi } @@ -200,7 +201,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then echo "Starting Friendica installation ..." # TODO Let the database time to warm up - not winning a beauty contest sleep 10s - run_as "cd /var/www/html; php /var/www/html/bin/console.php autoinstall $install_options" + run_as "php /var/www/html/bin/console.php autoinstall $install_options" # TODO Workaround because of a strange permission issue rm -fr /var/www/html/view/smarty3/compiled @@ -217,7 +218,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then # upgrade else echo "Upgrading Friendica ..." - run_as 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update' + run_as 'php /var/www/html/bin/console.php dbstructure update' echo "Upgrading finished" fi fi diff --git a/2019.09/fpm-alpine/entrypoint.sh b/2019.09/fpm-alpine/entrypoint.sh index 9c7ea16..05d629f 100755 --- a/2019.09/fpm-alpine/entrypoint.sh +++ b/2019.09/fpm-alpine/entrypoint.sh @@ -3,10 +3,11 @@ set -eu # run an command with the www-data user run_as() { + set -- -eu -c "cd /var/www/html; $*" if [ "$(id -u)" -eq 0 ]; then - su - www-data -s /bin/sh -c "cd /var/www/html;$1" + su - www-data -s /bin/sh "$@" else - sh -c "$1" + sh "$@" fi } @@ -200,7 +201,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then echo "Starting Friendica installation ..." # TODO Let the database time to warm up - not winning a beauty contest sleep 10s - run_as "cd /var/www/html; php /var/www/html/bin/console.php autoinstall $install_options" + run_as "php /var/www/html/bin/console.php autoinstall $install_options" # TODO Workaround because of a strange permission issue rm -fr /var/www/html/view/smarty3/compiled @@ -217,7 +218,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then # upgrade else echo "Upgrading Friendica ..." - run_as 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update' + run_as 'php /var/www/html/bin/console.php dbstructure update' echo "Upgrading finished" fi fi diff --git a/2019.09/fpm/entrypoint.sh b/2019.09/fpm/entrypoint.sh index 9c7ea16..05d629f 100755 --- a/2019.09/fpm/entrypoint.sh +++ b/2019.09/fpm/entrypoint.sh @@ -3,10 +3,11 @@ set -eu # run an command with the www-data user run_as() { + set -- -eu -c "cd /var/www/html; $*" if [ "$(id -u)" -eq 0 ]; then - su - www-data -s /bin/sh -c "cd /var/www/html;$1" + su - www-data -s /bin/sh "$@" else - sh -c "$1" + sh "$@" fi } @@ -200,7 +201,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then echo "Starting Friendica installation ..." # TODO Let the database time to warm up - not winning a beauty contest sleep 10s - run_as "cd /var/www/html; php /var/www/html/bin/console.php autoinstall $install_options" + run_as "php /var/www/html/bin/console.php autoinstall $install_options" # TODO Workaround because of a strange permission issue rm -fr /var/www/html/view/smarty3/compiled @@ -217,7 +218,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then # upgrade else echo "Upgrading Friendica ..." - run_as 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update' + run_as 'php /var/www/html/bin/console.php dbstructure update' echo "Upgrading finished" fi fi diff --git a/2019.12-dev/apache/entrypoint.sh b/2019.12-dev/apache/entrypoint.sh index 9c7ea16..05d629f 100755 --- a/2019.12-dev/apache/entrypoint.sh +++ b/2019.12-dev/apache/entrypoint.sh @@ -3,10 +3,11 @@ set -eu # run an command with the www-data user run_as() { + set -- -eu -c "cd /var/www/html; $*" if [ "$(id -u)" -eq 0 ]; then - su - www-data -s /bin/sh -c "cd /var/www/html;$1" + su - www-data -s /bin/sh "$@" else - sh -c "$1" + sh "$@" fi } @@ -200,7 +201,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then echo "Starting Friendica installation ..." # TODO Let the database time to warm up - not winning a beauty contest sleep 10s - run_as "cd /var/www/html; php /var/www/html/bin/console.php autoinstall $install_options" + run_as "php /var/www/html/bin/console.php autoinstall $install_options" # TODO Workaround because of a strange permission issue rm -fr /var/www/html/view/smarty3/compiled @@ -217,7 +218,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then # upgrade else echo "Upgrading Friendica ..." - run_as 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update' + run_as 'php /var/www/html/bin/console.php dbstructure update' echo "Upgrading finished" fi fi diff --git a/2019.12-dev/fpm-alpine/entrypoint.sh b/2019.12-dev/fpm-alpine/entrypoint.sh index 9c7ea16..05d629f 100755 --- a/2019.12-dev/fpm-alpine/entrypoint.sh +++ b/2019.12-dev/fpm-alpine/entrypoint.sh @@ -3,10 +3,11 @@ set -eu # run an command with the www-data user run_as() { + set -- -eu -c "cd /var/www/html; $*" if [ "$(id -u)" -eq 0 ]; then - su - www-data -s /bin/sh -c "cd /var/www/html;$1" + su - www-data -s /bin/sh "$@" else - sh -c "$1" + sh "$@" fi } @@ -200,7 +201,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then echo "Starting Friendica installation ..." # TODO Let the database time to warm up - not winning a beauty contest sleep 10s - run_as "cd /var/www/html; php /var/www/html/bin/console.php autoinstall $install_options" + run_as "php /var/www/html/bin/console.php autoinstall $install_options" # TODO Workaround because of a strange permission issue rm -fr /var/www/html/view/smarty3/compiled @@ -217,7 +218,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then # upgrade else echo "Upgrading Friendica ..." - run_as 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update' + run_as 'php /var/www/html/bin/console.php dbstructure update' echo "Upgrading finished" fi fi diff --git a/2019.12-dev/fpm/entrypoint.sh b/2019.12-dev/fpm/entrypoint.sh index 9c7ea16..05d629f 100755 --- a/2019.12-dev/fpm/entrypoint.sh +++ b/2019.12-dev/fpm/entrypoint.sh @@ -3,10 +3,11 @@ set -eu # run an command with the www-data user run_as() { + set -- -eu -c "cd /var/www/html; $*" if [ "$(id -u)" -eq 0 ]; then - su - www-data -s /bin/sh -c "cd /var/www/html;$1" + su - www-data -s /bin/sh "$@" else - sh -c "$1" + sh "$@" fi } @@ -200,7 +201,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then echo "Starting Friendica installation ..." # TODO Let the database time to warm up - not winning a beauty contest sleep 10s - run_as "cd /var/www/html; php /var/www/html/bin/console.php autoinstall $install_options" + run_as "php /var/www/html/bin/console.php autoinstall $install_options" # TODO Workaround because of a strange permission issue rm -fr /var/www/html/view/smarty3/compiled @@ -217,7 +218,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then # upgrade else echo "Upgrading Friendica ..." - run_as 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update' + run_as 'php /var/www/html/bin/console.php dbstructure update' echo "Upgrading finished" fi fi diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 9c7ea16..05d629f 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -3,10 +3,11 @@ set -eu # run an command with the www-data user run_as() { + set -- -eu -c "cd /var/www/html; $*" if [ "$(id -u)" -eq 0 ]; then - su - www-data -s /bin/sh -c "cd /var/www/html;$1" + su - www-data -s /bin/sh "$@" else - sh -c "$1" + sh "$@" fi } @@ -200,7 +201,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then echo "Starting Friendica installation ..." # TODO Let the database time to warm up - not winning a beauty contest sleep 10s - run_as "cd /var/www/html; php /var/www/html/bin/console.php autoinstall $install_options" + run_as "php /var/www/html/bin/console.php autoinstall $install_options" # TODO Workaround because of a strange permission issue rm -fr /var/www/html/view/smarty3/compiled @@ -217,7 +218,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then # upgrade else echo "Upgrading Friendica ..." - run_as 'cd /var/www/html; php /var/www/html/bin/console.php dbstructure update' + run_as 'php /var/www/html/bin/console.php dbstructure update' echo "Upgrading finished" fi fi From 802a07d7af8b00c56d35afa80f24ba108ec19556 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sat, 16 Nov 2019 21:59:34 +0100 Subject: [PATCH 2/3] Add "exec" to cron.sh start so it becomes PID 1 --- 2019.09/apache/cron.sh | 2 +- 2019.09/fpm-alpine/cron.sh | 2 +- 2019.09/fpm/cron.sh | 2 +- 2019.12-dev/apache/cron.sh | 2 +- 2019.12-dev/fpm-alpine/cron.sh | 2 +- 2019.12-dev/fpm/cron.sh | 2 +- docker-cron.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/2019.09/apache/cron.sh b/2019.09/apache/cron.sh index cf1f504..708eb8c 100755 --- a/2019.09/apache/cron.sh +++ b/2019.09/apache/cron.sh @@ -8,4 +8,4 @@ done # TODO let the database and the autoinstall time to complete - not winning a beauty contest sleep 15s -php /var/www/html/bin/daemon.php -f start +exec php /var/www/html/bin/daemon.php -f start diff --git a/2019.09/fpm-alpine/cron.sh b/2019.09/fpm-alpine/cron.sh index cf1f504..708eb8c 100755 --- a/2019.09/fpm-alpine/cron.sh +++ b/2019.09/fpm-alpine/cron.sh @@ -8,4 +8,4 @@ done # TODO let the database and the autoinstall time to complete - not winning a beauty contest sleep 15s -php /var/www/html/bin/daemon.php -f start +exec php /var/www/html/bin/daemon.php -f start diff --git a/2019.09/fpm/cron.sh b/2019.09/fpm/cron.sh index cf1f504..708eb8c 100755 --- a/2019.09/fpm/cron.sh +++ b/2019.09/fpm/cron.sh @@ -8,4 +8,4 @@ done # TODO let the database and the autoinstall time to complete - not winning a beauty contest sleep 15s -php /var/www/html/bin/daemon.php -f start +exec php /var/www/html/bin/daemon.php -f start diff --git a/2019.12-dev/apache/cron.sh b/2019.12-dev/apache/cron.sh index cf1f504..708eb8c 100755 --- a/2019.12-dev/apache/cron.sh +++ b/2019.12-dev/apache/cron.sh @@ -8,4 +8,4 @@ done # TODO let the database and the autoinstall time to complete - not winning a beauty contest sleep 15s -php /var/www/html/bin/daemon.php -f start +exec php /var/www/html/bin/daemon.php -f start diff --git a/2019.12-dev/fpm-alpine/cron.sh b/2019.12-dev/fpm-alpine/cron.sh index cf1f504..708eb8c 100755 --- a/2019.12-dev/fpm-alpine/cron.sh +++ b/2019.12-dev/fpm-alpine/cron.sh @@ -8,4 +8,4 @@ done # TODO let the database and the autoinstall time to complete - not winning a beauty contest sleep 15s -php /var/www/html/bin/daemon.php -f start +exec php /var/www/html/bin/daemon.php -f start diff --git a/2019.12-dev/fpm/cron.sh b/2019.12-dev/fpm/cron.sh index cf1f504..708eb8c 100755 --- a/2019.12-dev/fpm/cron.sh +++ b/2019.12-dev/fpm/cron.sh @@ -8,4 +8,4 @@ done # TODO let the database and the autoinstall time to complete - not winning a beauty contest sleep 15s -php /var/www/html/bin/daemon.php -f start +exec php /var/www/html/bin/daemon.php -f start diff --git a/docker-cron.sh b/docker-cron.sh index cf1f504..708eb8c 100755 --- a/docker-cron.sh +++ b/docker-cron.sh @@ -8,4 +8,4 @@ done # TODO let the database and the autoinstall time to complete - not winning a beauty contest sleep 15s -php /var/www/html/bin/daemon.php -f start +exec php /var/www/html/bin/daemon.php -f start From a0660813ea04a000a72909b3aa6086181b78c0a7 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sat, 16 Nov 2019 22:08:39 +0100 Subject: [PATCH 3/3] Remove unneeded "sh -c" command wrapper --- 2019.09/apache/entrypoint.sh | 4 ++-- 2019.09/fpm-alpine/entrypoint.sh | 4 ++-- 2019.09/fpm/entrypoint.sh | 4 ++-- 2019.12-dev/apache/entrypoint.sh | 4 ++-- 2019.12-dev/fpm-alpine/entrypoint.sh | 4 ++-- 2019.12-dev/fpm/entrypoint.sh | 4 ++-- docker-entrypoint.sh | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/2019.09/apache/entrypoint.sh b/2019.09/apache/entrypoint.sh index 05d629f..f007407 100755 --- a/2019.09/apache/entrypoint.sh +++ b/2019.09/apache/entrypoint.sh @@ -45,10 +45,10 @@ clone_develop() { # Removing the whole directory first rm -fr /usr/src/friendica - sh -c "git clone -q -b ${friendica_git} https://github.com/${friendica_repo} /usr/src/friendica" + git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica mkdir /usr/src/friendica/addon - sh -c "git clone -q -b ${addons_git} https://github.com/${friendica_addons_repo} /usr/src/friendica/addon" + git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon echo "Download finished" diff --git a/2019.09/fpm-alpine/entrypoint.sh b/2019.09/fpm-alpine/entrypoint.sh index 05d629f..f007407 100755 --- a/2019.09/fpm-alpine/entrypoint.sh +++ b/2019.09/fpm-alpine/entrypoint.sh @@ -45,10 +45,10 @@ clone_develop() { # Removing the whole directory first rm -fr /usr/src/friendica - sh -c "git clone -q -b ${friendica_git} https://github.com/${friendica_repo} /usr/src/friendica" + git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica mkdir /usr/src/friendica/addon - sh -c "git clone -q -b ${addons_git} https://github.com/${friendica_addons_repo} /usr/src/friendica/addon" + git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon echo "Download finished" diff --git a/2019.09/fpm/entrypoint.sh b/2019.09/fpm/entrypoint.sh index 05d629f..f007407 100755 --- a/2019.09/fpm/entrypoint.sh +++ b/2019.09/fpm/entrypoint.sh @@ -45,10 +45,10 @@ clone_develop() { # Removing the whole directory first rm -fr /usr/src/friendica - sh -c "git clone -q -b ${friendica_git} https://github.com/${friendica_repo} /usr/src/friendica" + git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica mkdir /usr/src/friendica/addon - sh -c "git clone -q -b ${addons_git} https://github.com/${friendica_addons_repo} /usr/src/friendica/addon" + git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon echo "Download finished" diff --git a/2019.12-dev/apache/entrypoint.sh b/2019.12-dev/apache/entrypoint.sh index 05d629f..f007407 100755 --- a/2019.12-dev/apache/entrypoint.sh +++ b/2019.12-dev/apache/entrypoint.sh @@ -45,10 +45,10 @@ clone_develop() { # Removing the whole directory first rm -fr /usr/src/friendica - sh -c "git clone -q -b ${friendica_git} https://github.com/${friendica_repo} /usr/src/friendica" + git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica mkdir /usr/src/friendica/addon - sh -c "git clone -q -b ${addons_git} https://github.com/${friendica_addons_repo} /usr/src/friendica/addon" + git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon echo "Download finished" diff --git a/2019.12-dev/fpm-alpine/entrypoint.sh b/2019.12-dev/fpm-alpine/entrypoint.sh index 05d629f..f007407 100755 --- a/2019.12-dev/fpm-alpine/entrypoint.sh +++ b/2019.12-dev/fpm-alpine/entrypoint.sh @@ -45,10 +45,10 @@ clone_develop() { # Removing the whole directory first rm -fr /usr/src/friendica - sh -c "git clone -q -b ${friendica_git} https://github.com/${friendica_repo} /usr/src/friendica" + git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica mkdir /usr/src/friendica/addon - sh -c "git clone -q -b ${addons_git} https://github.com/${friendica_addons_repo} /usr/src/friendica/addon" + git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon echo "Download finished" diff --git a/2019.12-dev/fpm/entrypoint.sh b/2019.12-dev/fpm/entrypoint.sh index 05d629f..f007407 100755 --- a/2019.12-dev/fpm/entrypoint.sh +++ b/2019.12-dev/fpm/entrypoint.sh @@ -45,10 +45,10 @@ clone_develop() { # Removing the whole directory first rm -fr /usr/src/friendica - sh -c "git clone -q -b ${friendica_git} https://github.com/${friendica_repo} /usr/src/friendica" + git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica mkdir /usr/src/friendica/addon - sh -c "git clone -q -b ${addons_git} https://github.com/${friendica_addons_repo} /usr/src/friendica/addon" + git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon echo "Download finished" diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 05d629f..f007407 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -45,10 +45,10 @@ clone_develop() { # Removing the whole directory first rm -fr /usr/src/friendica - sh -c "git clone -q -b ${friendica_git} https://github.com/${friendica_repo} /usr/src/friendica" + git clone -q -b ${friendica_git} "https://github.com/${friendica_repo}" /usr/src/friendica mkdir /usr/src/friendica/addon - sh -c "git clone -q -b ${addons_git} https://github.com/${friendica_addons_repo} /usr/src/friendica/addon" + git clone -q -b ${addons_git} "https://github.com/${friendica_addons_repo}" /usr/src/friendica/addon echo "Download finished"