From 4de1cadd19e369e59104c8c0828d95d3201af347 Mon Sep 17 00:00:00 2001
From: Gregory Bartholomew <gregory.lee.bartholomew@gmail.com>
Date: Jan 13 2022 01:51:04 +0000
Subject: Split run.sh into build.sh and preview.sh


---

diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..80cf6f7
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/bash
+# vim:set ts=3:
+
+WPPLUGIN='yet-another-related-posts-plugin co-authors-plus'
+
+set -e
+
+if ! [[ -e mariadb ]]; then
+	mkdir mariadb
+fi
+
+if ! [[ -e opt ]]; then
+	mkdir opt
+	echo downloading opt/wp ...
+	curl -# -L --output-dir opt -o wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
+	chmod +x opt/wp
+fi
+
+if ! [[ -e srv ]]; then
+	mkdir srv
+	for plugin in $WPPLUGIN; do
+		echo downloading srv/$plugin.zip ...
+		curl -# -L --output-dir srv -O https://downloads.wordpress.org/plugin/$plugin.zip
+	done
+fi
+
+exit 0
diff --git a/preview.sh b/preview.sh
new file mode 100755
index 0000000..bc4b683
--- /dev/null
+++ b/preview.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/bash
+# vim:set ts=3:
+
+HOSTPORT=5055
+
+PODMANNS='fedoramagazine'
+DATABASE='wordpress_blog'
+USERNAME='wordpress'
+PASSWORD='chahL5oomaiHiezie8thei)h5'
+
+set -e
+
+function wordpress_stop {
+	echo
+	podman pod stop $PODMANNS
+}
+
+trap wordpress_stop ERR PIPE EXIT HUP INT TERM
+
+podman pod create \
+	--name $PODMANNS \
+	--replace \
+	--infra \
+	--network bridge \
+	--publish $HOSTPORT:80
+
+podman run \
+	--pod $PODMANNS \
+	--name mariadb \
+	--restart on-failure \
+	--env MYSQL_DATABASE="$DATABASE" \
+	--env MYSQL_USER="$USERNAME" \
+	--env MYSQL_PASSWORD="$PASSWORD" \
+	--env MYSQL_ROOT_PASSWORD='f3d0r4 m4g4z1n3' \
+	--volume $PWD/mariadb:/var/lib/mysql:Z \
+	--detach docker.io/library/mariadb
+
+podman run \
+	--pod $PODMANNS \
+	--name wordpress \
+	--env WORDPRESS_DB_HOST="$PODMANNS" \
+	--env WORDPRESS_DB_NAME="$DATABASE" \
+	--env WORDPRESS_DB_USER="$USERNAME" \
+	--env WORDPRESS_DB_PASSWORD="$PASSWORD" \
+	--volume $PWD/opt:/opt:Z \
+	--volume $PWD/srv:/srv:Z \
+	--volume $PWD/fedoramagazine:/var/www/html/wp-content/themes/fedoramagazine:Z \
+	--detach docker.io/library/wordpress
+
+WP="podman exec wordpress /opt/wp --allow-root"
+
+sleep 10
+
+if ! $WP core is-installed; then
+	$WP core install \
+		--url="localhost:$HOSTPORT" \
+		--title='pants' \
+		--admin_user='admin' \
+		--admin_password='password' \
+		--admin_email='null@fedoraproject.org' \
+
+fi
+
+if ! $WP theme is-active fedoramagazine; then
+	$WP theme activate fedoramagazine
+fi
+
+cd srv
+for plugin in *.zip; do
+	if ! $WP plugin is-installed ${plugin%.zip}; then
+		$WP plugin install /srv/$plugin --activate
+	fi
+done
+cd ..
+
+echo "wordpress is listening on http://localhost:$HOSTPORT/; press ctrl-c to stop"
+sleep infinity
+
diff --git a/run.sh b/run.sh
deleted file mode 100755
index 40a0f6f..0000000
--- a/run.sh
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/usr/bin/bash
-# vim:set ts=3:
-
-HOSTPORT=5055
-
-PODMANNS='fedoramagazine'
-DATABASE='wordpress_blog'
-USERNAME='wordpress'
-PASSWORD='chahL5oomaiHiezie8thei)h5'
-
-WPPLUGIN='yet-another-related-posts-plugin co-authors-plus'
-
-set -e
-
-if ! [[ -e mariadb ]]; then
-	mkdir mariadb
-fi
-
-if ! [[ -e opt ]]; then
-	mkdir opt
-	echo downloading opt/wp ...
-	curl -# -L --output-dir opt -o wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
-	chmod +x opt/wp
-fi
-
-if ! [[ -e srv ]]; then
-	mkdir srv
-	for plugin in $WPPLUGIN; do
-		echo downloading srv/$plugin.zip ...
-		curl -# -L --output-dir srv -O https://downloads.wordpress.org/plugin/$plugin.zip
-	done
-fi
-
-function wordpress_stop {
-	echo
-	podman pod stop $PODMANNS
-}
-
-trap wordpress_stop ERR PIPE EXIT HUP INT TERM
-
-podman pod create \
-	--name $PODMANNS \
-	--replace \
-	--infra \
-	--network bridge \
-	--publish $HOSTPORT:80
-
-podman run \
-	--pod $PODMANNS \
-	--name mariadb \
-	--restart on-failure \
-	--env MYSQL_DATABASE="$DATABASE" \
-	--env MYSQL_USER="$USERNAME" \
-	--env MYSQL_PASSWORD="$PASSWORD" \
-	--env MYSQL_ROOT_PASSWORD='f3d0r4 m4g4z1n3' \
-	--volume $PWD/mariadb:/var/lib/mysql:Z \
-	--detach docker.io/library/mariadb
-
-podman run \
-	--pod $PODMANNS \
-	--name wordpress \
-	--env WORDPRESS_DB_HOST="$PODMANNS" \
-	--env WORDPRESS_DB_NAME="$DATABASE" \
-	--env WORDPRESS_DB_USER="$USERNAME" \
-	--env WORDPRESS_DB_PASSWORD="$PASSWORD" \
-	--volume $PWD/opt:/opt:Z \
-	--volume $PWD/srv:/srv:Z \
-	--volume $PWD/fedoramagazine:/var/www/html/wp-content/themes/fedoramagazine:Z \
-	--detach docker.io/library/wordpress
-
-WP="podman exec wordpress /opt/wp --allow-root"
-
-sleep 10
-
-if ! $WP core is-installed; then
-	$WP core install \
-		--url="localhost:$HOSTPORT" \
-		--title='pants' \
-		--admin_user='admin' \
-		--admin_password='password' \
-		--admin_email='null@fedoraproject.org' \
-
-fi
-
-if ! $WP theme is-active fedoramagazine; then
-	$WP theme activate fedoramagazine
-fi
-
-for plugin in $WPPLUGIN; do
-	if ! $WP plugin is-installed $plugin; then
-		$WP plugin install /srv/$plugin.zip --activate
-	fi
-done
-
-echo "wordpress is listening on http://localhost:$HOSTPORT/; press ctrl-c to stop"
-sleep infinity
-

