Skip to content

Instantly share code, notes, and snippets.

@centminmod
Created January 7, 2014 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save centminmod/8294750 to your computer and use it in GitHub Desktop.
Save centminmod/8294750 to your computer and use it in GitHub Desktop.
wpcli.sh revised installer rewritten with new wp-cli.org installation method
#!/bin/bash
###############################################
# Official centminmod.com addon: wpcli.sh installer
# written by George Liu (eva2000) vbtechsupport.com
###############################################
# http://wp-cli.org/
# WP-CLI is a set of command-line tools for managing WordPress
# installations. You can update plugins, set up multisite installs,
# create posts etc
###############################################
# install instructions
# chmod +x /usr/local/src/centmin-v1.2.3mod/addons/wpcli.sh
# cd /usr/local/src/centmin-v1.2.3mod/addons
# ./wpcli.sh install
###############################################
WPCLIDIR='/root/wpcli'
# functions
installwpcli() {
mkdir -p $WPCLIDIR
yum -q -y install git
if [[ ! -f /usr/bin/wp ]]; then
echo ""
if [ -s /usr/bin/wp ]; then
echo "/usr/bin/wp [found]"
else
echo "Error: /usr/bin/wp not found !!! Download now......"
wget -cnv --no-check-certificate https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/bin/wp --tries=3
ERROR=$?
if [[ "$ERROR" != '0' ]]; then
echo "Error: /usr/bin/wp download failed."
exit $ERROR
else
echo "Download done."
fi
fi
chmod 0700 /usr/bin/wp
echo ""
if [ -s "${WPCLIDIR}/wp-completion.bash" ]; then
echo "${WPCLIDIR}/wp-completion.bash [found]"
else
echo "Error: ${WPCLIDIR}/wp-completion.bash not found !!! Download now......"
wget -cnv --no-check-certificate https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash -O ${WPCLIDIR}/wp-completion.bash --tries=3
ERROR=$?
if [[ "$ERROR" != '0' ]]; then
echo "Error: ${WPCLIDIR}/wp-completion.bash download failed."
exit $ERROR
else
echo "Download done."
fi
fi
echo ""
WPCLICHECK=$(grep 'WP-CLI' /root/.bash_profile)
if [[ -z "$WPCLICHECK" ]]; then
echo ""
echo "" >> /root/.bash_profile
#echo "# Composer scripts" >> /root/.bash_profile
#echo "PATH=$HOME/.wp-cli/bin:$PATH" >> /root/.bash_profile
#echo "" >> /root/.bash_profile
echo "# WP-CLI completions" >> /root/.bash_profile
echo "source ${WPCLIDIR}/wp-completion.bash" >> /root/.bash_profile
fi
echo "-------------------------------------------------------------"
/usr/bin/wp --info
echo "-------------------------------------------------------------"
echo ""
echo "-------------------------------------------------------------"
echo "wp-cli install completed"
echo "Read http://wp-cli.org/ for full usage info"
echo ""
echo "-------------------------------------------------------------"
echo "Please log out of SSH session and log back in"
echo "You can then call wp-cli via command: wp"
echo "i.e. wp --info"
echo "-------------------------------------------------------------"
fi
}
###############################################
case "$1" in
install)
echo "installing..."
installwpcli
;;
*)
echo "$0 install"
;;
esac
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment