Skip to content

Instantly share code, notes, and snippets.

@splittingred
Created September 22, 2011 21:35
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save splittingred/1236123 to your computer and use it in GitHub Desktop.
Save splittingred/1236123 to your computer and use it in GitHub Desktop.
Bash script to install a new MODX Revolution 2.2+ install via CLI
Examples of above script:
# into a standard directory, where config.xml resides in the current working directory
sh install.sh /home/modx/public_html/
# with a custom config.xml file
sh install.sh /home/modx/public_html/ /opt/local/modx/config.xml
#!/bin/bash
DIR="$( cd -P "$( dirname "$0" )" && pwd )/"
CONFIGFILE='chz'
if [ $# -lt 2 ] ; then
CONFIGFILE="${DIR}config.xml"
else
CONFIGFILE=$2
fi
if [ ! -f ${CONFIGFILE} ]; then
echo "No config file found at ${CONFIGFILE}"; exit
fi
echo "Using config file at ${CONFIGFILE}"
if [ ! -d $1 ]; then
echo "Creating directory: $1"
mkdir $1
fi
cd $1
echo "Getting file from modx.com..."
wget -O modx.zip http://modx.com/download/latest/
echo "Unzipping file..."
unzip "./modx.zip" -d ./
ZDIR=`ls -F | grep "\/" | head -1`
if [ "${ZDIR}" = "/" ]; then
echo "Failed to find directory..."; exit
fi
if [ -d "${ZDIR}" ]; then
cd ${ZDIR}
echo "Moving out of temp dir..."
mv ./* ../
cd ../
rm -r "./${ZDIR}"
echo "Removing zip file..."
rm "./modx.zip"
cd "setup"
echo "Running setup..."
php ./index.php --installmode=new --config=${CONFIGFILE}
echo "Done!"
else
echo "Failed to find directory: ${ZDIR}"
exit
fi
cd ${DIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment