Skip to content

Commit

Permalink
Add base osm themes
Browse files Browse the repository at this point in the history
  • Loading branch information
Firefishy committed May 28, 2024
1 parent 8007513 commit 0244da7
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
jq \
unzip \
; \
rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -82,7 +83,7 @@ RUN set -ex; \

# TMPFS /tmp
# TMPFS /run
# Persistent /usr/src/wordpress/wp-content/uploads
# Persistent /usr/src/wordpress/wp-content/uploads (wordpress:wordpress)

# Add custom entrypoint to enable plugins/themes and run migrations during container startup
COPY entrypoint-addon.sh /usr/local/bin/
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ services:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
retries: 10
interval: 5s

# cli:
# image: wordpress:cli
Expand Down
3 changes: 3 additions & 0 deletions entrypoint-addon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ set -Eeuo pipefail
echo "Running standard entrypoint to populate wp-config.php"
docker-entrypoint.sh apache2 -l

# Ensure wordpress core database is installed
if ! wp --path=/usr/src/wordpress core is-installed; then
wp --path=/usr/src/wordpress core install --url=http://localhost:8080 --title="Wordpress" --admin_user="osm_admin" --admin_email="[email protected]" --skip-email
fi

# Ensure wordpress core database is up to date
wp --path=/usr/src/wordpress core update-db

# Activate all plugins
wp --path=/usr/src/wordpress plugin activate --all

exec "$@"
49 changes: 45 additions & 4 deletions wp-addon-install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,48 @@
#!/usr/bin/env bash
set -Eeuo pipefail

curl -Lsg 'https://api.wordpress.org/plugins/info/1.1/?action=plugin_information&request[slug]=wp-fail2ban' | jq -r .download_link
# wp-last-login
# wp-2fa
# wp-fail2ban
install_wordpress_addon() {
local type=$1
local slug=$2

if [[ "$type" != "plugin" && "$type" != "theme" ]]; then
echo "Invalid type. Use 'plugin' or 'theme'."
return 1
fi

local api_url="https://api.wordpress.org/${type}s/info/1.2/?action=${type}_information&request[slug]=${slug}"
local download_link=$(curl -Lsg "$api_url" | jq -r '.download_link')

if [[ -z "$download_link" || "$download_link" == "null" ]]; then
echo "Invalid slug or no download link found."
return 1
fi

local target_dir="/usr/src/wordpress/wp-content/${type}s"
mkdir -p "$target_dir"

curl -L "$download_link" -o "/tmp/${slug}.zip"
unzip -q "/tmp/${slug}.zip" -d "$target_dir"
rm "/tmp/${slug}.zip"

echo "${type^} '${slug}' installed successfully to ${target_dir}."
}

remove_wordpress_addon() {
local type=$1
local slug=$2

if [[ "$type" != "plugin" && "$type" != "theme" ]]; then
echo "Invalid type. Use 'plugin' or 'theme'."
return 1
fi

rm -Rf "/usr/src/wordpress/wp-content/${type}s/${slug}"

echo "${type^} '${slug}' removed successfully."
}

install_wordpress_addon plugin wp-last-login
install_wordpress_addon plugin wp-2fa
install_wordpress_addon plugin wp-fail2ban
remove_wordpress_addon plugin hello.php

0 comments on commit 0244da7

Please sign in to comment.