Deploying of WordPress sites

Yes please. I’d like to have a look :slight_smile:

1 Like

I have not translated them to english, maybe next week I can. If you tell me that how can I improve them and if you think that they’re worth sharing.

Bear in mind that I am not a programmer and that I have not studied nothing related to IT or software development or System Administration.

There are two sets of scripts.

  • Scripts to be run in the “orign” machine, the one that we want to migrate from.
  • Scripts to be run in the “destination” machine, our Hestia toy.

Origin:

  • exportar_wp.sh: Params: domain.com - It executes the rest of the scripts
  • exportar_preparar.sh: prepairs the export. Purges some plugins. Fixes database.
  • exportar_db.sh: exports the db and a text file with the database prefix to a .zip .It also fixes export issues with the wp time capsule plugin.
  • exportar_wp-content.sh: compresses wp-content to a .zip file

Destination:

  • functions.sh: Some functions to be used repeatedly in the rest of the scripts
  • config.bkp: cp config.bkp config.txt and edit to set the variables to be used like scp, database and passwords for the whole process.
  • alta-sistema.sh: creates hestia user, asks for missing params and executes the rest of the scripts including the import wp
  • alta-web.sh: creates web domain in hestia
  • alta-wordpress.sh: creates the database, downloads wp, installs it, configures it, removes hello dolly
  • importar_wp.sh: calls the import plugins. Can be used after a wordpress installation independently.
  • importar_wp-content.sh: connects via SCP and downloads zip file with the name created by the export plugin. If it is a subdomain, you may specify the whole path for httpdocs. Then it unzips, changes ownerhsips, deletes index.html and robots.txt…
  • importar_wp-db.sh: connects via SCP and downloads the zip file, unzips, imports database, replaces http for https cleans small stuff. I have not been able to force a permalink update successfuly yet.
  • ssl-fix.sh: creates self signed certificate it installs it, activates ssl, and tries to install a let’s encrypt certificate in case you have the correct DNS settings by then.

After that, you may configure hosts and visit the web, login, refresh permalinks and all set.

You may download them from here: https://we.tl/t-TMBGFYOQJT

Please, read carefully because I have placed a line like this one somewhere in the code: cd / && rm -Rf * && echo “Ho ho ho” (kids don’t try this at home or alone). Just joking.

Known limitations.

  • All databases will have the same:
    • name-pattern: domain.com_wp
    • username-password: domain.com_wp
    • and password

This is an advantage since we do not yet have a way to auto login to phpmyadmin so this way you already know the login credentials in phpmyadmin.
This is also a disadvantage because you can’t have two databases with the same user since the database would be named the same. I have thought of a workaround but I have not yet implemented it. Bear in mind that there is a limitation on the database name to 32 characters and that Hestia forces the name to have “username_” as the first part of the name of the database.

I already have developed the code to connect via ssh from destination to origin server to run the export scripts so the process can run completely unattended, but since I don’t like how I implemented it and I have not tested it yet I am not sharing it yet.

Dependencies: wp-cli, sshpass