clone-install-on-test.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. # This script will compress and download the typo3 installation directory from prod-front, and extract and install it on the test host
  3. # <!> this does not clone the database, use clonedb if needed
  4. # <!> This may need sudo rights to run correctly
  5. host=$(hostname)
  6. if [[ $host =~ test-v?[0-9]* ]]
  7. then
  8. echo "Current testing env : $host"
  9. else
  10. echo "Invalid host : $host ; this script is designed to run on testing env only"
  11. exit 1
  12. fi
  13. if [ "$(id -u)" != "0" ]; then
  14. echo "This script must be run as root" 1>&2
  15. exit 1
  16. fi
  17. now=$(date '+%Y%m%d-%H%M')
  18. # shellcheck disable=SC2029
  19. sudo -u exploitation ssh exploitation@prod-front "cd /var/www/typo3/ ; tar cvzf /home/exploitation/typo3_install_$now.tar.gz . --exclude=./public/fileadmin/user_upload/* --exclude=./archive --exclude=./public/fileadmin/_processed_ --exclude=./var/log/* --exclude=./var/cache/*" || exit
  20. sudo -u exploitation scp exploitation@prod-front:/home/exploitation/typo3_install_$now.tar.gz /home/exploitation || exit
  21. rm -rf /var/www/typo3 || exit
  22. mkdir /var/www/typo3
  23. tar xvzf "/home/exploitation/typo3_install_$now.tar.gz" -C /var/www/typo3/ || exit
  24. rm "/home/exploitation/typo3_install_$now.tar.gz"
  25. sudo -u exploitation ssh exploitation@prod-front "rm /home/exploitation/typo3_install_$now.tar.gz"
  26. chown -R exploitation:www-data /var/www/typo3
  27. echo "+ Typo3 install cloned +"