#!/bin/bash #################################################################################################### #### author: SlickStack ############################################################################ #### link: https://slickstack.io ################################################################### #### mirror: http://mirrors.slickstack.io/bash/ss-install-wordpress-cli.txt ######################## #### path: /var/www/ss-install-wordpress-cli ####################################################### #### destination: n/a (not a boilerplate) ########################################################## #### purpose: Reinstalls the entire WP-CLI module for SlickStack servers (idempotent) ############## #### module version: WP-CLI x.x.x ################################################################## #### sourced by: ss-install, ss-install-wordpress ################################################## #### bash aliases: ss install wordpress cli, ss install wp cli, ss install wp-cli ################## #################################################################################################### ## SS-CONFIG MUST BE PROPERLY CONFIGURED AND ON CURRENT BUILD BEFORE RUNNING SS-INSTALL ## ## ENSURE YOUR SS-CONFIG BUILD REMAINS CURRENT BY RUNNING SS-UPDATE OCCASIONALLY ## ## include SlickStack configuration ## source /var/www/ss-config ## include SlickStack functions ## source /var/www/ss-functions #################################################################################################### #### SS-Install-WordPress-CLI: Message (Begin Script) ############################################## #################################################################################################### ## this is a simple message that announces to the shell the purpose of this bash script ## ## it will only be noticed by sudo users who manually call ss core bash scripts ## ## echo message ## echo -e "${PURPLE}Running ss-install-wordpress-cli: Reinstalls the entire WP-CLI module for SlickStack servers (idempotent)... ${NOCOLOR}" sleep "$SLEEP_MESSAGE_BEGIN" #################################################################################################### #### SS-Install-WordPress-CLI: Cleanup Temporary Files ############################################# #################################################################################################### ## delete tmp files ## rm /tmp/wp-cli* rm /tmp/wp-completion* #################################################################################################### ### SS-Install-Bash: Prepare WP-CLI Configuration ################################################## #################################################################################################### ## to keep things simple we include the WP-CLI aliases within our own Bash aliases file ## ## here we retrieve latest WP-CLI files and move aliases to /var/www/meta/ ## ## uninstall current wp-cli versions ## rm /usr/local/bin/wp rm /home/wp-completion.bash rm /home/${SUDO_USER}/wp-cli.yml rm /var/www/meta/.wp-completion* rm /var/www/meta/wp-cli.yml rm /var/www/html/.wp-cli rm /var/www/html/wp-cli sed -i '/WP-CLI/d' /home/${SUDO_USER}/.bashrc sed -i '/wp-completion/d' /home/${SUDO_USER}/.bashrc ## symlinks for wp-cli.yml ## ln /home/${SUDO_USER}/.wp-cli/config.yml /var/www/meta/wp-cli.yml ln /root/.wp-cli/config.yml /var/www/meta/wp-cli.yml ## download latest versions ## wget -O /tmp/wp-cli.phar http://mirrors.slickstack.io/wp-cli/wp-cli.phar wget -O /tmp/wp-cli.yml http://mirrors.slickstack.io/wp-cli/wp-cli-yml.txt wget -O /tmp/wp-completion.txt http://mirrors.slickstack.io/wp-cli/wp-completion.txt ## make files executable ## chmod +x /tmp/wp-cli.phar ## copy files to destinations ## cp /tmp/wp-cli.phar /usr/local/bin/wp cp /tmp/wp-cli.yml /var/www/meta/wp-cli.yml cp /tmp/wp-completion.txt /var/www/meta/.wp-completion #################################################################################################### #### SS-Install-WordPress-CLI: Reset Permissions (WordPress CLI) ################################### #################################################################################################### ## run ss-perms-wordpress-cli ## source /var/www/ss-perms-wordpress-cli #################################################################################################### #### SS-Install-WordPress-CLI: Cleanup Temporary Files ############################################# #################################################################################################### ## delete tmp files ## rm /tmp/wp-cli* rm /tmp/wp-completion* #################################################################################################### #### SS-Install-WordPress-CLI: Touch Timestamp File (End Script) ################################### #################################################################################################### ## this is a dummy timestamp file that will remember the last time this script was run ## ## it can be useful for developer reference and is sometimes used by SlickStack ## ## script timestamp ## touch /var/www/meta/.timestamp-ss-install-wordpress-cli #################################################################################################### #### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ############### #################################################################################################### ## Ref: ## SS_EOF