Last active
February 19, 2022 22:41
-
-
Save naviarh/ec3b598489da2c38dae7be5806ca0283 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 | |
# terminate on errors | |
set -xe | |
# define as docker compose var or default "" | |
WP_BACKUP_URL=${WP_BACKUP_URL:-} | |
#is empty | |
function func_0 { | |
echo 'First start' | |
# download backup from backup url | |
function wget_0 { | |
wget -qO- "$WP_BACKUP_URL" | tar zxC /var/www | |
} | |
# copy wp-content from Wordpress src to directory | |
function wget_1 { | |
echo 'Setting up wp-content directory' | |
cp -r /usr/src/wordpress/* /var/www/ | |
} | |
# check if BACKUP_URL exists by downloading the first byte | |
[[ $(wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK') ]] | |
echo `wget_$?` | |
# 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 | |
} | |
# is not empty | |
function func_1 { | |
echo 'Start' | |
} | |
# is there a file? | |
function check { | |
ls $2 2>/dev/null | grep $1 | wc -l | |
} | |
# check, is there a file? | |
echo `func_$(check index.php /var/www/wp-content/)` | |
# execute CMD[] | |
exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment