Skip to content

Instantly share code, notes, and snippets.

@rob-gordon
Last active August 10, 2019 10:38
Show Gist options
  • Select an option

  • Save rob-gordon/4cc8eb2a2b8285c428cf82d597f48fa0 to your computer and use it in GitHub Desktop.

Select an option

Save rob-gordon/4cc8eb2a2b8285c428cf82d597f48fa0 to your computer and use it in GitHub Desktop.
WP Repository Init Bash
DB_HOST=
DB_USER=
DB_PASSWORD=
DB_PORT=3306
DB_NAME=
# ignore node dependency directories
node_modules/
# ignore log files and databases
*.log
*.sql
*.sqlite
# continuous integration
.env
export $(grep -v '^#' .env | xargs)
mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASSWORD" $DB_NAME
# mysql path
MYSQL_PATH="$1"
DEFAULT_PATH=mysql.sql
if [ -z "$MYSQL_PATH" ]
then
if [ -f "$DEFAULT_PATH" ]; then
MYSQL_PATH="$(pwd)/$DEFAULT_PATH"
else
echo "\$MYSQL_PATH is empty"
exit 1
fi
fi
# export .env variables
export $(grep -v '^#' .env | xargs)
# create database
mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASSWORD" -e "create database $DB_NAME"
# upload database to newly created database
mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" < "$MYSQL_PATH"
version: '3'
services:
wp:
image: andreccosta/wordpress-xdebug
ports:
- '8080:80'
volumes:
- ./src:/var/www/html
environment:
WORDPRESS_DB_NAME: '${DB_NAME}'
WORDPRESS_DB_HOST: '${DB_HOST}'
WORDPRESS_DB_USER: '${DB_USER}'
WORDPRESS_DB_PASSWORD: '${DB_PASSWORD}'
XDEBUG_CONFIG: remote_host=host.docker.internal
{
"scripts": {
"start": "docker-compose up -d",
"stop": "docker-compose down"
}
}
#!/usr/bin/env bash
# Run this with curl http://foo.com/script.sh | bash -s arg1 arg2
FOLDERNAME=${PWD##*/}
GIST="https://gist.githubusercontent.com/rob-gordon/4cc8eb2a2b8285c428cf82d597f48fa0/raw/"
LATEST="c0e754b3ea53306fbf6ee91a7ba795b232ea6da9"
PACKAGE="$GIST$LATEST/package.json"
DBINIT="$GIST$LATEST/dbinit"
DBCONNECT="$GIST$LATEST/dbconnect"
DOCKERCOMPOSE="$GIST$LATEST/docker-compose.yml"
WPGITIGNORE="$GIST$LATEST/wpgitignore"
GITIGNORE="$GIST$LATEST/.gitignore"
MYENV="$GIST$LATEST/.env"
##### package #####
curl $PACKAGE > package.json
npm init -y
##### helper scripts #####
mkdir scripts
curl $DBINIT > scripts/dbinit
curl $DBCONNECT > scripts/dbconnect
chmod +x scripts/dbinit
chmod +x scripts/dbconnect
curl $DOCKERCOMPOSE > docker-compose.yml
##### git #####
curl $WPGITIGNORE > src/.gitignore
curl $GITIGNORE > .gitignore
git init
git add -A
git commit -m "init commit"
git clean -dfX # remove all files not being tracked
################
curl $MYENV > .env # done AFTER the git removal
echo "Edit .env file"
echo "Make sure mysql.sql is in the root"
echo "Then: scripts/initdb"
echo "Then: npm run start"
/*
# ignore everything in the root except the "wp-content" directory.
!wp-content/
# ignore everything in the "wp-content" directory, except:
# "mu-plugins", "plugins", "themes" directory
wp-content/*
!wp-content/mu-plugins/
!wp-content/plugins/
!wp-content/themes/
# ignore these plugins
wp-content/plugins/hello.php
# ignore specific themes
wp-content/themes/twenty*/
# ignore node dependency directories
node_modules/
# ignore log files and databases
*.log
*.sql
*.sqlite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment