Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter gary535d

    (@gary535d)

    Greetings,

    I dug into my archive and found the following two shell scripts (change them to executable and run them – the mySQL script first).

    Bitnami has a software stack that installs just like any other Mac program – and is extensible with a wide range of applications.

    I elected not to follow that route (I did tests to experiment, before I did my formal installation on my Mac mini running OS X Server).

    I decided to use the scripts enclosed as it was a more integrated package to OS X Server than Bitnami – I’d have been running the Bitnami stack as well as Server. This way, I only run Server.

    I have configured both WordPress and ownCloud this way – ownCloud was a more intricate setup and is not yet fully supported on Mac – character sets representing filenames can cause issues.

    These scripts are available from macminivault.com, so you don’t have to be worried that I’m sending you bad or malicious code.

    Anyway, I hope these help, along with the excellent resource that is mac mini vault.

    My next challenge is to configure mail on the Mac mini, and a roundcube webmail interface to mail.

    Next year . . . . . .

    The mySQL script is:

    #!/bin/bash
    #############################################
    # AUTHOR: JONATHAN SCHWENN @jonschwenn #
    # MAC MINI VAULT – MAC MINI COLOCATION #
    # MACMINIVAULT.COM – @MACMINIVAULT #
    # VERSION 2.1 RELEASE DATE SEPT 04 2015 #
    # DESC: THIS SCRIPT INSTALLS MySQL on OSX #
    #############################################
    #REQUIREMENTS:
    # OS X 10.7 or newer
    #############################################
    # CHECK FOR OS X 10.7+
    if [[ $(sw_vers -productVersion | grep -E ’10.[7-9]|1[0-0]’) ]]
    then
    # CHECK FOR EXISTING MySQL
    if [[ -d /usr/local/mysql ]]
    then
    echo “It looks like you already have MySQL installed…”
    echo “This script will most likely fail unless MySQL is completley removed.”
    echo “If MySQL does install, your old version and databases will still be”
    echo “under /usr/local/ and you will have to manually move databases to the”
    echo “new install. It’s important to copy/move with permissions intact.”
    echo “…”
    echo “…”
    while true; do
    read -p “DO YOU WANT TO CONTINUE? [y/N]” yn
    case $yn in
    [Yy]* ) break;;
    [Nn]* ) exit ;;
    * ) echo “Please answer yes or no.”;;
    esac
    done
    fi
    # MYSQL INSTALLER WANTS A ‘pidof’ COMMAND SOMETIMES
    # SO WE’LL GIVE IT A ‘pidof’ COMMAND
    if [[ ! $(command -v pidof) ]]; then
    if [ ! -d “$/usr/local/bin” ]; then
    sudo mkdir -p /usr/local/bin
    fi
    # HARD TO CAT DIRECT TO BIN DIR, PUTTING IN DOCUMENTS THEN MOVING
    sudo cat << ‘EOF’ > ~/Documents/pidof
    #!/bin/sh
    ps axc|awk “{if (\$5==\”$1\”) print \$1}”
    EOF
    sudo mv ~/Documents/pidof /usr/local/bin/pidof
    sudo chmod 755 /usr/local/bin/pidof
    fi
    # LOOKS GOOD, LETS GRAB MySQL AND GET STARTED …
    echo “Downloading MySQL Installers … may take a few moments”
    curl -# -Lo ~/Downloads/MySQL.dmg https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.26-osx10.9-x86_64.dmg
    hdiutil attach -quiet ~/Downloads/MySQL.dmg
    # PLIST TO ALTER MySQL INSTALLER TO NOT ATTEMPT TO INSTALL STARTUP ITEMS
    curl -s -o ~/Downloads/MySQL-install.plist https://raw.githubusercontent.com/MacMiniVault/Mac-Scripts/master/mmvMySQL/install.plist
    # DEAR MySQL, WHY HAVE A SPECIFIC 10.9 DOWNLOAD IF IT JUST HAS THE 10.8 INSTALLER?
    cd /Volumes/mysql-5.6.26-osx10.8-x86_64/
    echo “…”
    echo “…”
    echo “Installing MySQL, administrator password required …”
    sudo installer -applyChoiceChangesXML ~/Downloads/MySQL-install.plist -pkg mysql-5.6.26-osx10.8-x86_64.pkg -target /
    # MySQL START SCRIPT CHANGES PATH – LINKING PIDOF TO THE MySQL DIR
    sudo ln -s /usr/local/bin/pidof /usr/local/mysql/bin/pidof
    echo “…”
    echo “…”
    # AS OF RIGHT NOW MYSQL AUTOMATICALLY INSTALLS THE STARTUP ITEMS AND PREFPANE
    # STARTUP ITEMS DO NOT WORK IN YOSEMITE – WE MADE A LAUNCHD START SETUP
    # TWO FILES ARE NEEDED
    # A PLIST FOR LAUNCHD TO START ON BOOT
    # AND A SCRIPT THAT THE PLIST LOADS, SCRIPT WAITS FOR NETWORKING TO INITIALIZE AND STARTS MySQL
    curl -s -o ~/Downloads/mmv-start.sh https://raw.githubusercontent.com/MacMiniVault/Mac-Scripts/master/mmvMySQL/mmv-start.sh
    sudo mv ~/Downloads/mmv-start.sh /usr/local/mysql/support-files/
    sudo chown root:wheel /usr/local/mysql/support-files/mmv-start.sh

    # LET’S START UP MYSQL
    sudo /usr/local/mysql/support-files/mysql.server start

    # ADDING MYSQL PATH TO BASH PROFILE, MAY CONFLICT WITH EXISTING PROFILES/.RC FILES
    touch ~/.bash_profile >/dev/null 2>&1
    echo -e “\nexport PATH=$PATH:/usr/local/mysql/bin” | sudo tee -a ~/.bash_profile > /dev/null
    sudo mkdir /var/mysql; sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
    sleep 10
    # IF MySQL IS RUNNING, GENERATE, SET, AND DOCUMENT ROOT PASSWORD
    if [[ $(sudo /usr/local/mysql/support-files/mysql.server status | grep “SUCCESS”) ]]
    then
    mypass=”$(cat /dev/urandom | base64 | tr -dc A-Za-z0-9_ | head -c8)”
    echo $mypass > ~/Desktop/MYSQL_PASSWORD
    echo “Setting MySQL root Password to $mypass”
    echo “Placing password on desktop…”
    /usr/local/mysql/bin/mysql -uroot -e “GRANT ALL ON *.* TO ‘root’@’localhost’ IDENTIFIED BY ‘$mypass’ WITH GRANT OPTION;”
    echo “…”
    echo “…”
    # UNMOUNT AND DELELTE DOWNLOADED MySQL INSTALLER
    cd ~/
    hdiutil detach -quiet /Volumes/mysql-5.6.26-osx10.8-x86_64/
    sleep 2
    rm ~/Downloads/MySQL.dmg
    rm ~/Downloads/MySQL-install.plist
    # NEW MY.CNF PERFORMANCE OPTION START
    echo “BASE PERFORMANCE MY.CNF IS JUST A GENERIC SUGGESTION FOR PERFORMANCE”
    echo “YOUR RESULTS MAY VARY AND YOU MAY WANT TO FURTHER TUNE YOUR MY.CNF SETTINGS”
    echo “BASE PERFORMANCE MY.CNF INCREASES BUFFERS/MEMORY USAGE”
    echo “8GB+ RAM IS RECOMMENDED FOR BASE PERFORMANCE MY.CNF”
    echo “…”
    sudo cp /usr/local/mysql/my.cnf /usr/local/mysql/mmv.cnf
    sudo tee -a /usr/local/mysql/mmv.cnf > /dev/null << EOF

    # CUSTOMIZED BY MMVMySQL SCRIPT – JUST GENERIC SETTINGS
    # DO NOT TREAT AS GOSPEL

    innodb_buffer_pool_size=2G
    skip-name_resolve
    max-connect-errors=100000
    max-connections=500

    EOF
    while true; do
    read -p “DO YOU WANT TO LOAD A BASE PERFORMANCE MY.CNF FILE? [y/N]” cnf
    case $cnf in
    [Yy]* ) sudo cp /usr/local/mysql/mmv.cnf /etc/my.cnf; sudo /usr/local/mysql/support-files/mysql.server restart; break ;;
    [Nn]* ) break;;
    * ) echo “Please answer yes or no.”;;
    esac
    done
    # NEW MY.CNF PERFORMANCE OPTION END
    # NEW SEQUEL PRO INSTALL OPTION START
    while true; do
    read -p “DO YOU WANT TO AUTOMATICALLY INSTALL SEQUEL PRO? [Y/n]” sp
    case $sp in
    [Yy]* ) curl -# -o ~/Downloads/SequelPro.dmg https://sequel-pro.googlecode.com/files/sequel-pro-1.0.2.dmg; hdiutil attach -quiet ~/Downloads/SequelPro.dmg;cp -R /Volumes/Sequel\ Pro\ 1.0.2/Sequel\ Pro.app/ /Applications/Sequel\ Pro.app/; hdiutil detach -quiet /Volumes/Sequel\ Pro\ 1.0.2/;sleep 5; rm ~/Downloads/SequelPro.dmg; echo “Sequel Pro is now in your Applications folder!”; break ;;
    [Nn]* ) break;;
    * ) echo “Please answer yes or no.”;;
    esac
    done
    # NEW SEQUEL PRO INSTALL OPTION END
    echo ” “
    echo ” “
    echo “ALL DONE! Install Sequel Pro or phpmyadmin to administer MySQL”
    echo ” “
    echo ” “
    echo “MySQL will start automatically after a reboot. Use the MySQL preference pane in system preferences to manage this.”
    echo “Open a new terminal for the ‘mysql’ command to be recognized in terminal”
    echo ” “
    echo ” “
    else
    “SORRY, MySQL IS NOT RUNNING … THERE MUST BE A PROBLEM”
    fi
    else
    echo “ERROR: YOU ARE NOT RUNNING OS X 10.7 OR NEWER”
    exit 1
    fi

    The WordPress script is:

    #!/bin/bash
    #############################################
    # AUTHOR: JONATHAN SCHWENN @jonschwenn #
    # MAC MINI VAULT – MAC MINI COLOCATION #
    # MACMINIVAULT.COM – @MACMINIVAULT #
    # VERSION 2.0 RELEASE DATE AUG 27, 2014 #
    # DESC: THIS SCRIPT SETS UP WORDPRESS ON #
    # A OS X 10.8+ MACHINE W/ SERVER.APP #
    # AND MYSQL INSTALLED #
    #############################################
    # REQUIREMENTS:
    # OS X 10.8, 10.9 or 10.10
    # SERVER.APP INSTALLED / INITIALIZED
    # MYSQL INSTALLED
    #############################################
    #CHECK FOR OS X 10.8/10.9/10.10, SERVER.app, and MySQL
    OSX=no
    if [[ $(sw_vers -productVersion | grep ‘10.8’) ]]
    then
    OSX=yes
    fi
    if [[ $(sw_vers -productVersion | grep ‘10.9’) ]]
    then
    OSX=yes
    fi
    if [[ $(sw_vers -productVersion | grep ‘10.10’) ]]
    then
    OSX=yes
    fi
    OSX=yes

    if [[ $OSX = yes && $(serverinfo –configured | grep ‘has’) && $(which mysql) ]]
    then
    echo “Congratulations, you are running OS X 10.8 or higher and have Server.app and MySQL installed….”
    #GET LATEST WORDPRESS VERSION
    cd ~/Downloads
    curl -Ls -o mmvwordpress.tar.gz https://www.ads-software.com/latest.tar.gz
    tar xzf mmvwordpress.tar.gz
    cd wordpress
    mv wp-config-sample.php wp-config.php
    #START WEB SERVICE AND MAKE SURE PHP IS ENABLED
    echo “YOU MAY BE ASKED FOR YOUR SYSTEM ADMINISTRATOR PASSWORD….”
    sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin start web > /dev/null 2>&1
    sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/webappctl start com.apple.webapp.php > /dev/null 2>&1
    #ASK FOR DOMAIN NAME – THANKS TO @SHAUNINMAN FOR SOME OF THE REGEX USED IN VALIDATION OF DOMAIN
    echo “ENTER DOMAIN NAME:”
    regex=’^[a-zA-Z0-9\-\.]+\.((a[cdefgilmnoqrstuwxz]|aero|arpa)|(b[abdefghijmnorstvwyz]|biz)|(c[acdfghiklmnorsuvxyz]|cat|com|coop)|d[ejkmoz]|(e[ceghrstu]|edu)|f[ijkmor]|(g[abdefghilmnpqrstuwy]|gov)|h[kmnrtu]|(i[delmnoqrst]|info|int)|(j[emop]|jobs)|k[eghimnprwyz]|l[abcikrstuvy]|(m[acdeghklmnopqrstuvwxyz]|mil|mobi|museum)|(n[acefgilopruz]|name|net)|(om|org)|(p[aefghklmnrstwy]|pro)|qa|r[eouw]|s[abcdeghijklmnortvyz]|(t[cdfghjklmnoprtvwz]|travel)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])$’
    while read domain; do
    if [[ $domain =~ $regex ]]; then
    echo “BUILDING WORDPRESS SITE….. “
    if [[ $(sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin settings web | grep $domain) ]]; then
    echo “DOMAIN ALREADY EXISTS ON THIS SERVER …”
    echo “”
    echo “PLEASE ENTER A DOMAIN NAME:”
    else
    break 2
    fi
    else
    echo “YOU DID NOT ENTER A VALID DOMAIN NAME”
    echo “”
    echo “PLEASE ENTER A DOMAIN NAME:”
    fi
    done
    #CREATE DATABASE NAME AND USER
    wpname=”$(cat /dev/urandom | base64 | tr -dc A-Za-z0-9_ | head -c8)”
    wpname=wp_$wpname
    wppass=”$(cat /dev/urandom | base64 | tr -dc A-Za-z0-9_ | head -c15)”
    echo “ENTER MySQL ROOT PASSWORD TO CREATE DATABASE AND USER:”
    mysql -uroot -p -e “CREATE DATABASE IF NOT EXISTS $wpname;GRANT ALL ON *.* TO ‘$wpname’@’localhost’ IDENTIFIED BY ‘$wppass’;FLUSH PRIVILEGES;”
    #CREATE WORDPRESS DOCUMENTROOT AND OWN BY APACHE
    sudo mkdir /Library/Server/Web/Data/Sites/$domain > /dev/null 2>&1
    sudo cp -R ~/Downloads/wordpress/* /Library/Server/Web/Data/Sites/$domain > /dev/null 2>&1
    sudo rm -rf ~/Downloads/wordpress
    sudo sed -i -e “s/^define(‘DB_NAME’, ‘database_name_here’);/define(‘DB_NAME’, ‘$wpname’);/” /Library/Server/Web/Data/Sites/$domain/wp-config.php > /dev/null 2>&1
    sudo sed -i -e “s/^define(‘DB_USER’, ‘username_here’);/define(‘DB_USER’, ‘$wpname’);/” /Library/Server/Web/Data/Sites/$domain/wp-config.php > /dev/null 2>&1
    sudo sed -i -e “s/^define(‘DB_PASSWORD’, ‘password_here’);/define(‘DB_PASSWORD’, ‘$wppass’);/” /Library/Server/Web/Data/Sites/$domain/wp-config.php > /dev/null 2>&1
    sudo chown -R _www:staff /Library/Server/Web/Data/Sites/$domain > /dev/null 2>&1
    echo “SUCCESS: CREATE VIRTUAL HOST IN SERVER.APP AND FOLLOW REST OF READ-ME DOCUMENTATION”
    #LEAVING THIS AREA BLANK

    #EVENTUALLY WANT TO SCRIPT IN VHOST CREATION WITH serveradmin

    #END IF STATEMENT CHECKING FOR OS X & SERVER.APP & MySQL
    else
    echo “ERROR: YOU ARE NOT RUNNING OS X 10.8/10.9/10.10 OR YOU DO NOT HAVE SERVER.APP MySQL INSTALLED”
    exit 1
    fi

Viewing 1 replies (of 1 total)