Last active
July 28, 2021 10:28
-
-
Save thierrypigot/34f0b55f3c14d13a44adb76a3083a33c to your computer and use it in GitHub Desktop.
Local by flywheel - Custom WordPress install script
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 | |
while ! mysqladmin ping --silent; do | |
sleep 1 | |
done | |
if mysql -e "SELECT USER(),CURRENT_USER();" -proot 2> /dev/null | |
then | |
echo "mysql password: root" | |
mysql -e "DROP DATABASE IF EXISTS local; CREATE DATABASE local;" -proot | |
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;" -proot | |
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');FLUSH PRIVILEGES;" -proot | |
elif mysql -e "SELECT USER(),CURRENT_USER();" -plocal 2> /dev/null | |
then | |
echo "mysql password: local" | |
mysql -e "DROP DATABASE IF EXISTS local; CREATE DATABASE local;" -plocal | |
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;" -plocal | |
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');FLUSH PRIVILEGES;" -plocal | |
elif mysql -e "SELECT USER(),CURRENT_USER();" -ppressmatic 2> /dev/null | |
then | |
echo "mysql password: pressmatic" | |
mysql -e "DROP DATABASE IF EXISTS local; CREATE DATABASE local;" -ppressmatic | |
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;" -ppressmatic | |
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');FLUSH PRIVILEGES;" -ppressmatic | |
elif mysql -e "SELECT USER(),CURRENT_USER();" | |
then | |
echo "mysql password: no password" | |
mysql -e "DROP DATABASE IF EXISTS local; CREATE DATABASE local;" --password="" | |
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;" --password="" | |
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');FLUSH PRIVILEGES;" --password="" | |
fi | |
cd /app/ | |
if [ ! -d /app/public ] | |
then | |
echo "public does not exist." | |
mkdir public | |
fi | |
cd public | |
if [ -f /app/public/wp-config.php ] | |
then | |
echo "wp-config.php exists. deleting it." | |
rm wp-config.php | |
fi | |
if [ -f /app/public/wp-blog-header.php ] | |
then | |
echo "wp-blog-header.php exists. configuring and installing." | |
wp --allow-root core config --dbuser="root" --dbname="local" --dbpass="root" --dbprefix="lorem_" --extra-php <<PHP | |
@ini_set( 'display_errors', false ); | |
define( 'WP_DEBUG', false ); | |
define( 'WP_POST_REVISIONS', false ); | |
define( 'DISALLOW_FILE_EDIT', true ); | |
define( 'DISALLOW_FILE_MODS', false ); | |
define( 'POST_BY_EMAIL', true ); | |
PHP | |
case "$6" in | |
ms-subdir ) | |
wp --allow-root core multisite-install --url="$1" --title="$5" --admin_user="$2" --admin_password="$3" --admin_email="$4" ;; | |
ms-subdomain ) | |
wp --allow-root core multisite-install --url="$1" --title="$5" --admin_user="$2" --admin_password="$3" --admin_email="$4" --subdomains ;; | |
no ) | |
wp --allow-root core install --url="$1" --title="$5" --admin_user="$2" --admin_password="$3" --admin_email="$4" ;; | |
esac | |
wp --allow-root core language install fr_FR | |
wp --allow-root core language activate fr_FR | |
wp --allow-root plugin delete akismet | |
wp --allow-root plugin delete hello | |
wp --allow-root rewrite structure "/%postname%/" --hard | |
wp --allow-root rewrite flush --hard | |
wp --allow-root user update 1 --first_name="Thierry" --last_name="Pigot" --nickname="Thierry Pigot" --user_url="https://www.wearewp.pro" --twitter="WeAre_wp" --facebook="https://www.facebook.com/WeAreWP/" --display_name="Thierry Pigot" | |
wp --allow-root option set blog_public 0 | |
wp --allow-root option set rss_use_excerpt 1 | |
wp --allow-root option set default_pingback_flag 0 | |
wp --allow-root option set default_ping_status 0 | |
wp --allow-root option set comment_order desc | |
wp --allow-root option set comment_moderation 1 | |
wp --allow-root option update show_on_front page | |
wp --allow-root option update blogdescription '' | |
wp --allow-root option update timezone_string 'Europe/Paris' | |
rm readme.html | |
rm license.txt | |
wp --allow-root post delete 1 --force # Article exemple - no trash. Comment is also deleted | |
wp --allow-root post delete 2 --force # page exemple | |
wp --allow-root post create --post_type=page --post_title="Accueil" --post_status=publish | |
wp --allow-root post create --post_type=page --post_title="Actualites" --post_status=publish | |
wp --allow-root post create --post_type=page --post_title="Contact" --post_status=publish | |
wp --allow-root post create --post_type=page --post_title="Mentions legales" --post_status=publish | |
wp --allow-root post create --post_type=page --post_title="Credits" --post_status=publish | |
wp --allow-root post create --post_type=page --post_title="Plan du site" --post_status=publish | |
wp --allow-root option update page_on_front 3 | |
wp --allow-root option update page_for_posts 4 | |
wp --allow-root menu create "Menu Haut" | |
wp --allow-root menu item add-post menu-haut 3 | |
wp --allow-root menu item add-post menu-haut 4 | |
wp --allow-root menu item add-post menu-haut 5 | |
wp --allow-root menu create "Menu Bas" | |
wp --allow-root menu item add-post menu-bas 3 | |
wp --allow-root menu item add-post menu-bas 5 | |
wp --allow-root menu item add-post menu-bas 6 | |
wp --allow-root menu item add-post menu-bas 7 | |
wp --allow-root menu item add-post menu-bas 8 | |
# mise a jour des traductions | |
wp --allow-root core language update | |
wp --allow-root rewrite flush --hard | |
else | |
echo "Error! WordPress does not exist." 1>&2 | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment