From 9552327281c3d72e87cb5e31866abc5450b87b03 Mon Sep 17 00:00:00 2001 From: Anthony Correa Date: Sun, 17 Dec 2023 11:39:46 -0600 Subject: [PATCH] Renamed to Selig, combine scripts, plugin import --- .env.sample | 2 +- .gitignore | 3 ++- README.md | 14 ++++++++------ chihounds/docker-run.sh | 2 +- chihounds/wp-cli.sh | 3 +-- chihounds/wp-import.sh | 28 +--------------------------- chihounds/wp-install.sh | 8 +------- cmbabaseball/docker-run.sh | 2 +- cmbabaseball/wp-cli.sh | 3 +-- cmbabaseball/wp-import.sh | 28 +--------------------------- cmbabaseball/wp-install.sh | 8 +------- shared/wp-cli.sh | 2 ++ shared/wp-import.sh | 32 ++++++++++++++++++++++++++++++++ shared/wp-install.sh | 7 +++++++ 14 files changed, 60 insertions(+), 82 deletions(-) mode change 100755 => 120000 chihounds/wp-cli.sh mode change 100755 => 120000 chihounds/wp-import.sh mode change 100755 => 120000 chihounds/wp-install.sh mode change 100755 => 120000 cmbabaseball/wp-cli.sh mode change 100755 => 120000 cmbabaseball/wp-import.sh mode change 100755 => 120000 cmbabaseball/wp-install.sh create mode 100755 shared/wp-cli.sh create mode 100755 shared/wp-import.sh create mode 100755 shared/wp-install.sh diff --git a/.env.sample b/.env.sample index 56eaee7..5b3b751 100644 --- a/.env.sample +++ b/.env.sample @@ -1,4 +1,4 @@ -PROJECT_NAME=kenesaw +PROJECT_NAME=selig WORDPRESS_ADMIN_USER= WORDPRESS_ADMIN_EMAIL= diff --git a/.gitignore b/.gitignore index f4a375e..14ba177 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.sql *.tgz -.env \ No newline at end of file +.env +*.zip diff --git a/README.md b/README.md index 1034d75..997e069 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Kenesaw +# Selig -Kenesaw is a Docker project to set-up two Wordpress servers, one for a league, one for a team. It uses Caddy for the webserver and a single MariaDB instance for the server. +Selig is a Docker project to set-up two Wordpress servers, one for a league, one for a team. It uses Caddy for the webserver and a single MariaDB instance for the server. Each Wordpress instance setups their own database within the MariaDB instance. @@ -9,17 +9,19 @@ Each Wordpress instance setups their own database within the MariaDB instance. There are two environment files, one at the project root and one under each WordPress folder ([cmbabaseball](./cmbabaseball/.env), [chihounds](./chihounds/.env)). ### Init -Each WordPress site has an `wp-install.sh` script ([cmbabaseball](./cmbabaseball/wp-install.sh), [chihounds](./chihounds/wp-install.sh)). It creates the database and install Wordpress using the common `wp-admin` user info provided in the project root via a ephemeral wp-cli container. (Theoretically, this can be changed by overwriting the environment variables in the website-specific env file, but I didn't test that and I don't know what the order would have to be). +Each WordPress site has an `wp-install.sh` script ([cmbabaseball](./cmbabaseball/wp-install), [chihounds](./chihounds/wp-install)). It creates the database and install Wordpress using the common `wp-admin` user info provided in the project root via a ephemeral wp-cli container. (Theoretically, this probably can be changed by overwriting the environment variables in the website-specific env file, but I didn't test that and I don't know what the order would have to be). It also preinstalls a list of plugins as defined in the site's .env. + +Currently, the scripts are exactly the same, so they are symbolic links to the shared directory. ```sh -./cmbabaseball/init-wordpress.sh -./chihounds/init-wordpress.sh +./cmbabaseball/init-wordpress +./chihounds/init-wordpress ``` OR ```sh -./*/init-wordpress.sh +./*/init-wordpress ``` ### Import diff --git a/chihounds/docker-run.sh b/chihounds/docker-run.sh index 36b7234..ce7c27f 100755 --- a/chihounds/docker-run.sh +++ b/chihounds/docker-run.sh @@ -1,4 +1,4 @@ cd "$(dirname "$0")" -PROJECT_NAME=kenesaw +PROJECT_NAME=selig CONTAINER_NAME=chihounds docker run --rm --user 33:33 --volume ${PROJECT_NAME}_${CONTAINER_NAME}-wpdata:/var/www/html --env-file ../.env --env-file .env --network ${PROJECT_NAME}_network "$@" \ No newline at end of file diff --git a/chihounds/wp-cli.sh b/chihounds/wp-cli.sh deleted file mode 100755 index 59558d5..0000000 --- a/chihounds/wp-cli.sh +++ /dev/null @@ -1,2 +0,0 @@ -cd "$(dirname "$0")" -./docker-run.sh wordpress:cli "$@" \ No newline at end of file diff --git a/chihounds/wp-cli.sh b/chihounds/wp-cli.sh new file mode 120000 index 0000000..5600699 --- /dev/null +++ b/chihounds/wp-cli.sh @@ -0,0 +1 @@ +../shared/wp-cli.sh \ No newline at end of file diff --git a/chihounds/wp-import.sh b/chihounds/wp-import.sh deleted file mode 100755 index 17464aa..0000000 --- a/chihounds/wp-import.sh +++ /dev/null @@ -1,27 +0,0 @@ -cd "$(dirname "$0")" - -./docker-run.sh \ --v ./data/import.sql:/import.sql \ --v ./data/import-uploads.tgz:/import-uploads.tgz \ -wordpress:cli sh -c ' - -if [ -f /import.sql ]; then - echo "Importing Database..." - wp db query < /import.sql - echo "Replacing default site url (https://localhost->$WORDPRESS_SITEURL)" - wp search-replace "https://localhost" "$WORDPRESS_SITEURL" --format=count - echo "Re-adding the admin user" - wp user create $WORDPRESS_ADMIN_USER $WORDPRESS_ADMIN_EMAIL --user_pass=$WORDPRESS_ADMIN_PASSWORD --role=administrator --porcelain - echo "Done." -fi && \ -if [ -f /import-uploads.tgz ]; then - echo "Importing Uploads..." - tar -xz --overwrite -f /import-uploads.tgz -C /var/www/html/wp-content/uploads . - echo "Done." -fi && \ -if [ -f /import-plugins.tgz ]; then - echo "Importing Plugins..." - tar -xzk--overwrite -f /import-plugins.tgz -C /var/www/html/wp-content/plugins . - echo "Done." -fi -' \ No newline at end of file diff --git a/chihounds/wp-import.sh b/chihounds/wp-import.sh new file mode 120000 index 0000000..e94e273 --- /dev/null +++ b/chihounds/wp-import.sh @@ -0,0 +1 @@ +../shared/wp-import.sh \ No newline at end of file diff --git a/chihounds/wp-install.sh b/chihounds/wp-install.sh deleted file mode 100755 index 17db762..0000000 --- a/chihounds/wp-install.sh +++ /dev/null @@ -1,7 +0,0 @@ -cd "$(dirname "$0")" -./wp-cli.sh sh -c ' -wp db create || true && \ -wp core install --title="$WORDPRESS_TITLE" --url="$WORDPRESS_SITEURL" --admin_user=$WORDPRESS_ADMIN_USER --admin_email=$WORDPRESS_ADMIN_EMAIL --admin_password=$WORDPRESS_ADMIN_PASSWORD && \ -wp theme install $WP_THEMES --activate; \ -wp plugin install $WP_PLUGINS --activate -' \ No newline at end of file diff --git a/chihounds/wp-install.sh b/chihounds/wp-install.sh new file mode 120000 index 0000000..6b6fe3a --- /dev/null +++ b/chihounds/wp-install.sh @@ -0,0 +1 @@ +../shared/wp-install.sh \ No newline at end of file diff --git a/cmbabaseball/docker-run.sh b/cmbabaseball/docker-run.sh index 68ebf41..3848c9f 100755 --- a/cmbabaseball/docker-run.sh +++ b/cmbabaseball/docker-run.sh @@ -1,4 +1,4 @@ cd "$(dirname "$0")" -PROJECT_NAME=kenesaw +PROJECT_NAME=selig CONTAINER_NAME=cmbabaseball docker run --rm --user 33:33 --volume ${PROJECT_NAME}_${CONTAINER_NAME}-wpdata:/var/www/html --env-file ../.env --env-file .env --network ${PROJECT_NAME}_network "$@" \ No newline at end of file diff --git a/cmbabaseball/wp-cli.sh b/cmbabaseball/wp-cli.sh deleted file mode 100755 index 59558d5..0000000 --- a/cmbabaseball/wp-cli.sh +++ /dev/null @@ -1,2 +0,0 @@ -cd "$(dirname "$0")" -./docker-run.sh wordpress:cli "$@" \ No newline at end of file diff --git a/cmbabaseball/wp-cli.sh b/cmbabaseball/wp-cli.sh new file mode 120000 index 0000000..5600699 --- /dev/null +++ b/cmbabaseball/wp-cli.sh @@ -0,0 +1 @@ +../shared/wp-cli.sh \ No newline at end of file diff --git a/cmbabaseball/wp-import.sh b/cmbabaseball/wp-import.sh deleted file mode 100755 index 17464aa..0000000 --- a/cmbabaseball/wp-import.sh +++ /dev/null @@ -1,27 +0,0 @@ -cd "$(dirname "$0")" - -./docker-run.sh \ --v ./data/import.sql:/import.sql \ --v ./data/import-uploads.tgz:/import-uploads.tgz \ -wordpress:cli sh -c ' - -if [ -f /import.sql ]; then - echo "Importing Database..." - wp db query < /import.sql - echo "Replacing default site url (https://localhost->$WORDPRESS_SITEURL)" - wp search-replace "https://localhost" "$WORDPRESS_SITEURL" --format=count - echo "Re-adding the admin user" - wp user create $WORDPRESS_ADMIN_USER $WORDPRESS_ADMIN_EMAIL --user_pass=$WORDPRESS_ADMIN_PASSWORD --role=administrator --porcelain - echo "Done." -fi && \ -if [ -f /import-uploads.tgz ]; then - echo "Importing Uploads..." - tar -xz --overwrite -f /import-uploads.tgz -C /var/www/html/wp-content/uploads . - echo "Done." -fi && \ -if [ -f /import-plugins.tgz ]; then - echo "Importing Plugins..." - tar -xzk--overwrite -f /import-plugins.tgz -C /var/www/html/wp-content/plugins . - echo "Done." -fi -' \ No newline at end of file diff --git a/cmbabaseball/wp-import.sh b/cmbabaseball/wp-import.sh new file mode 120000 index 0000000..e94e273 --- /dev/null +++ b/cmbabaseball/wp-import.sh @@ -0,0 +1 @@ +../shared/wp-import.sh \ No newline at end of file diff --git a/cmbabaseball/wp-install.sh b/cmbabaseball/wp-install.sh deleted file mode 100755 index 17db762..0000000 --- a/cmbabaseball/wp-install.sh +++ /dev/null @@ -1,7 +0,0 @@ -cd "$(dirname "$0")" -./wp-cli.sh sh -c ' -wp db create || true && \ -wp core install --title="$WORDPRESS_TITLE" --url="$WORDPRESS_SITEURL" --admin_user=$WORDPRESS_ADMIN_USER --admin_email=$WORDPRESS_ADMIN_EMAIL --admin_password=$WORDPRESS_ADMIN_PASSWORD && \ -wp theme install $WP_THEMES --activate; \ -wp plugin install $WP_PLUGINS --activate -' \ No newline at end of file diff --git a/cmbabaseball/wp-install.sh b/cmbabaseball/wp-install.sh new file mode 120000 index 0000000..6b6fe3a --- /dev/null +++ b/cmbabaseball/wp-install.sh @@ -0,0 +1 @@ +../shared/wp-install.sh \ No newline at end of file diff --git a/shared/wp-cli.sh b/shared/wp-cli.sh new file mode 100755 index 0000000..59558d5 --- /dev/null +++ b/shared/wp-cli.sh @@ -0,0 +1,2 @@ +cd "$(dirname "$0")" +./docker-run.sh wordpress:cli "$@" \ No newline at end of file diff --git a/shared/wp-import.sh b/shared/wp-import.sh new file mode 100755 index 0000000..a5974fc --- /dev/null +++ b/shared/wp-import.sh @@ -0,0 +1,32 @@ +cd "$(dirname "$0")" + +./docker-run.sh \ +-v ./data/import.sql:/import.sql \ +-v ./data/import-uploads.tgz:/import-uploads.tgz \ +-v ./data/plugins:/import-plugins \ +wordpress:cli sh -c ' + +if [ -f /import.sql ]; then + echo "Importing Database..." + wp db query < /import.sql + echo "Replacing default site url (https://localhost->$WORDPRESS_SITEURL)" + wp search-replace "https://localhost" "$WORDPRESS_SITEURL" --format=count + echo "Re-adding the admin user" + wp user create $WORDPRESS_ADMIN_USER $WORDPRESS_ADMIN_EMAIL --user_pass=$WORDPRESS_ADMIN_PASSWORD --role=administrator --porcelain + echo "Done." +fi && \ +if [ -f /import-uploads.tgz ]; then + echo "Importing Uploads..." + tar -xz --overwrite -f /import-uploads.tgz -C /var/www/html/wp-content/uploads . + echo "Done." +fi && \ +if [ -n "$(ls -A /import-plugins 2>/dev/null)" ]; then + echo "Importing Plugins..." + for I in /import-plugins/*.zip; do + [ -f "$I" ] || continue + echo "$I" + wp plugin install "$I" --activate + done + echo "Done." +fi +' \ No newline at end of file diff --git a/shared/wp-install.sh b/shared/wp-install.sh new file mode 100755 index 0000000..17db762 --- /dev/null +++ b/shared/wp-install.sh @@ -0,0 +1,7 @@ +cd "$(dirname "$0")" +./wp-cli.sh sh -c ' +wp db create || true && \ +wp core install --title="$WORDPRESS_TITLE" --url="$WORDPRESS_SITEURL" --admin_user=$WORDPRESS_ADMIN_USER --admin_email=$WORDPRESS_ADMIN_EMAIL --admin_password=$WORDPRESS_ADMIN_PASSWORD && \ +wp theme install $WP_THEMES --activate; \ +wp plugin install $WP_PLUGINS --activate +' \ No newline at end of file