Skip to content

Instantly share code, notes, and snippets.

@ipascual
Last active May 3, 2019 11:37
Show Gist options
  • Save ipascual/0b1d19d5344e232bcfd3107c0cf09e51 to your computer and use it in GitHub Desktop.
Save ipascual/0b1d19d5344e232bcfd3107c0cf09e51 to your computer and use it in GitHub Desktop.
jenkins - magento1 deployment script
# v. 20180110
TARGET=/var/www/B2C_America_PA/html
TMPTARGET=$TARGET/../html-in-progress
BACKUP=$TARGET/../html-backup
USER=apache
GROUP=apache
echo "Temporary folder: $TMPTARGET"
echo "Workspace folder: $WORKSPACE"
echo "Cleaning temporary folder"
sudo rm -rf $TMPTARGET
echo "Making a copy of the workspace to the temporary folder"
sudo cp -R $WORKSPACE $TMPTARGET
echo "Removing not needed files form the temporary folder"
cd $TMPTARGET
sudo rm -rf $TMPTARGET/.git*
sudo rm -rf $TMPTARGET/downloader
sudo rm -rf $TMPTARGET/LICENSE*
sudo rm -rf $TMPTARGET/tests
sudo rm -rf $TMPTARGET/.htaccess.sample
sudo rm -rf $TMPTARGET/php.ini.sample
sudo rm -rf $TMPTARGET/RELEASE*
sudo rm -rf $TMPTARGET/composer*
sudo rm -rf $TMPTARGET/phpMyAdmin
echo "Creating the required symbolic links"
sudo rm -rf $TMPTARGET/media
sudo ln -s $TARGET/../media $TMPTARGET/
sudo rm -rf $TMPTARGET/var
sudo ln -s $TARGET/../var $TMPTARGET/
echo "Changing permissions of the temporary folder to HTTPD user"
sudo sudo chown -R $USER:$GROUP $TMPTARGET
sudo chcon -t httpd_sys_content_t $TARGET -R
sudo chcon -t httpd_sys_rw_content_t $TARGET/../var -R
sudo chcon -t httpd_sys_rw_content_t $TARGET/../media -R
echo "DEPLOYING..."
sudo rm -rf $BACKUP
sudo mv $TARGET $BACKUP
sudo mv $TMPTARGET $TARGET
echo "Flushing cache..."
sudo rm -rf $TARGET/var/cache $TARGET/var/full_page_cache || true
echo "All done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment