Created
February 19, 2022 22:41
-
-
Save naviarh/15a3bdf2dd03a8c60731f637e08733ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# developed for TheDifferent by Florian Kleber for terms of use have a look at the LICENSE file | |
# terminate on errors | |
set -xe | |
# define as docker compose var or default "" | |
WP_BACKUP_URL=${WP_BACKUP_URL:-} | |
# check if volume is not empty | |
if [ ! -f /var/www/wp-content/index.php ]; then | |
# check if BACKUP_URL exists by downloading the first byte | |
if [[ $(wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK') ]]; then | |
# download backup from backup url | |
wget -qO- "$WP_BACKUP_URL" | tar zxC /var/www | |
else | |
echo 'Setting up wp-content directory' | |
# copy wp-content from Wordpress src to directory | |
cp -r /usr/src/wordpress/* /var/www/ | |
fi | |
# set owner to nobody | |
chown -R nobody:nogroup /var/www | |
# generate wordpress secrets | |
wget https://api.wordpress.org/secret-key/1.1/salt/ -O ->> /usr/src/wordpress/wp-secrets.php | |
fi | |
# execute CMD[] | |
exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment