From ce78eb3a49e470e82641935045e1c54b8344dd50 Mon Sep 17 00:00:00 2001 From: lars-hagen Date: Fri, 27 Dec 2019 20:12:57 +0100 Subject: [PATCH] added a wordpress installer --- bin/container/downloadWPCtl.sh | 42 ++++++++++++++++++++++++++++++++++ bin/downloadWP.sh | 36 ++--------------------------- 2 files changed, 44 insertions(+), 34 deletions(-) create mode 100755 bin/container/downloadWPCtl.sh mode change 100644 => 100755 bin/downloadWP.sh diff --git a/bin/container/downloadWPCtl.sh b/bin/container/downloadWPCtl.sh new file mode 100755 index 0000000..7908634 --- /dev/null +++ b/bin/container/downloadWPCtl.sh @@ -0,0 +1,42 @@ +#!/bin/bash +if [ -z "$1" ] +then + echo "Missing arguments, exit" + exit 0 +fi + +cd /var/www/vhosts/$1/html +if [ ! -f "./wp-config.php" ]; then + # su -s /bin/bash www-data -c + COUNTER=0 + until [ "$(curl -v mysql:3306 2>&1 | grep native)" ]; + do + echo "Counter: ${COUNTER}" + COUNTER=$((COUNTER+1)) + if [ ${COUNTER} = 10 ]; then + echo '--- MySQL is starting, please wait... ---' + elif [ ${COUNTER} = 100 ]; then + echo '--- MySQL is timeout, exit! ---' + exit 1 + fi + sleep 1 + done + wp core download \ + --allow-root \ + --force + first_www_uid=$(stat -c "%u" /var/www/vhosts/$1) + first_www_gid=$(stat -c "%g" /var/www/vhosts/$1) + chown $first_www_uid:$first_www_gid /var/www/vhosts/$1 -R + +fi + + +www_uid=$(stat -c "%u" /var/www/vhosts/$1) +if [ ${www_uid} -eq 0 ]; then + #echo "./sites/localhost is owned by root, auto changing ownership of ./sites/localhost to uid 1000" + chown 1000:1000 /var/www/vhosts/localhost -R +fi + +#echo "WordPress installation finished." +#exec "$@" + diff --git a/bin/downloadWP.sh b/bin/downloadWP.sh old mode 100644 new mode 100755 index f74c47c..2a421aa --- a/bin/downloadWP.sh +++ b/bin/downloadWP.sh @@ -1,36 +1,4 @@ -#!/bin/bash -cd /var/www/vhosts/$1/html -if [ ! -f "./wp-config.php" ]; then - # su -s /bin/bash www-data -c - COUNTER=0 - until [ "$(curl -v mysql:3306 2>&1 | grep native)" ]; - do - echo "Counter: ${COUNTER}" - COUNTER=$((COUNTER+1)) - if [ ${COUNTER} = 10 ]; then - echo '--- MySQL is starting, please wait... ---' - elif [ ${COUNTER} = 100 ]; then - echo '--- MySQL is timeout, exit! ---' - exit 1 - fi - sleep 1 - done - wp core download \ - --allow-root \ - --force - first_www_uid=$(stat -c "%u" /var/www/vhosts/localhost) - first_www_gid=$(stat -c "%g" /var/www/vhosts/localhost) - chown $first_www_uid:$first_www_gid /var/www/vhosts/localhost -R +#!/usr/bin/env bash -fi - - -www_uid=$(stat -c "%u" /var/www/vhosts/localhost) -if [ ${www_uid} -eq 0 ]; then - #echo "./sites/localhost is owned by root, auto changing ownership of ./sites/localhost to uid 1000" - chown 1000:1000 /var/www/vhosts/localhost -R -fi - -echo "WordPress installation finished." -exec "$@" +docker-compose exec litespeed su -c "downloadWPCtl.sh $1"