Last active
December 17, 2025 17:30
-
-
Save n8finch/0ceddc0f29695d14aad33818fed6e9ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/bash | |
| # Credit: https://gist.github.com/bacoords/7a3d8eba7ec36adbb3d28ae8e328bf61 | |
| # Credit to https://github.com/rizaardiyanto1412/rizaardiyanto1412/blob/main/installwp.sh | |
| # Check if WP-CLI is installed | |
| if ! command -v wp &> /dev/null; then | |
| echo "WP-CLI is not installed. Please install it first." | |
| exit 1 | |
| fi | |
| # Check for MySQL client | |
| MYSQL_CMD="mysql" | |
| if ! command -v mysql &> /dev/null; then | |
| echo "MySQL client not found. Please ensure DBngin is installed and running, or install MySQL client." | |
| exit 1 | |
| fi | |
| # Check if --multi flag is passed | |
| MULTISITE=false | |
| for arg in "$@"; do | |
| if [ "$arg" == "--multi" ]; then | |
| MULTISITE=true | |
| fi | |
| done | |
| # Prompt for new site folder | |
| read -p "Enter the new site folder name: " SITE_NAME | |
| # Validate folder name input | |
| if [ -z "$SITE_NAME" ]; then | |
| echo "Folder name cannot be empty. Exiting." | |
| exit 1 | |
| fi | |
| # Set variables | |
| DB_USER="root" # DBngin typically uses root without password by default | |
| DB_PASSWORD="" # Empty password as per DBngin default | |
| DB_HOST="127.0.0.1" | |
| WP_TITLE="My $SITE_NAME Site" | |
| WP_ADMIN_USER="asdf" | |
| WP_ADMIN_PASSWORD="asdf" | |
| WP_ADMIN_EMAIL="[email protected]" | |
| SITE_SLUG=$(echo "$SITE_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-') | |
| SITE_DB_NAME=$(echo "$SITE_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '_') | |
| # Create new site directory | |
| mkdir "$HOME/Herd/$SITE_SLUG" && cd "$HOME/Herd/$SITE_SLUG" || exit | |
| WP_URL="$SITE_SLUG.test" | |
| DB_NAME="$SITE_DB_NAME" | |
| echo "Using the following values:" | |
| echo "WordPress URL: $WP_URL" | |
| echo "Database Name: $DB_NAME" | |
| # Create database | |
| "$MYSQL_CMD" -h"$DB_HOST" -u"$DB_USER" -e "CREATE DATABASE IF NOT EXISTS \`$DB_NAME\`;" | |
| if [ $? -ne 0 ]; then | |
| echo "Failed to create database. Please check your DBngin setup and ensure MySQL is running." | |
| exit 1 | |
| fi | |
| # Download WordPress core | |
| wp core download | |
| # Create wp-config.php | |
| wp config create --dbname="$DB_NAME" --dbuser="$DB_USER" --dbpass="$DB_PASSWORD" --dbhost="$DB_HOST" | |
| # Install WordPress (Single or Multisite) | |
| if [ "$MULTISITE" = true ]; then | |
| echo "Installing as a subdomain-based multisite..." | |
| wp core install --url="$WP_URL" --title="$WP_TITLE" --admin_user="$WP_ADMIN_USER" --admin_password="$WP_ADMIN_PASSWORD" --admin_email="$WP_ADMIN_EMAIL" | |
| wp core multisite-convert --title="$WP_TITLE" --subdomains | |
| wp plugin install --activate-network disable-emails | |
| else | |
| echo "Installing as a single site..." | |
| wp core install --url="$WP_URL" --title="$WP_TITLE" --admin_user="$WP_ADMIN_USER" --admin_password="$WP_ADMIN_PASSWORD" --admin_email="$WP_ADMIN_EMAIL" | |
| wp plugin install --activate disable-emails | |
| fi | |
| # Wish I didn't have to do this, but... | |
| wp plugin delete hello akismet | |
| # Set admin user role to administrator (in case of multisite) | |
| wp user add-role 1 administrator | |
| # Symlink UW Theme and Plugins | |
| UMARK_DIR="/Users/admin/Desktop/hello/uw-mark" | |
| if [ -d "$UMARK_DIR" ]; then | |
| echo "Linking UW Theme and Plugins..." | |
| mkdir -p wp-content/themes | |
| mkdir -p wp-content/plugins | |
| ln -s "$UMARK_DIR/uw-theme-classic" "wp-content/themes/uw-theme" | |
| ln -s "$UMARK_DIR/uw-theme-gutenberg" "wp-content/themes/uw-theme-gutenberg" | |
| ln -s "$UMARK_DIR/uw-theme-blocks" "wp-content/plugins/uw-theme-blocks" | |
| ln -s "$UMARK_DIR/uw-people" "wp-content/plugins/uw-people" | |
| ln -s "$UMARK_DIR/uw-events-gutenberg" "wp-content/plugins/uw-events-gutenberg" | |
| ln -s "$UMARK_DIR/uw-theme-to-gutenberg-converter" "wp-content/plugins/uw-theme-to-gutenberg-converter" | |
| wp theme activate uw-theme-gutenberg | |
| wp plugin activate --all | |
| else | |
| echo "UW Mark directory not found at $UMARK_DIR. Skipping theme and plugin linking." | |
| fi | |
| echo "WordPress installation complete!" | |
| echo "Site URL: $WP_URL" | |
| echo "Database Name: $DB_NAME" | |
| echo "Admin username: $WP_ADMIN_USER" | |
| echo "Admin password: $WP_ADMIN_PASSWORD" | |
| echo "Remember to change the admin password after logging in!" | |
| echo "cd into the site directory at: $HOME/Herd/$SITE_SLUG" | |
| # RENAME TABLE | |
| # wp_comments TO wwcmsp_2196_comments, | |
| # wp_commentmeta TO wwcmsp_2196_commentmeta, | |
| # wp_users TO wwcmsp_2196_users, | |
| # wp_usermeta TO wwcmsp_2196_usermeta; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment