exporting to production succesfully

This commit is contained in:
Ray Elliott 2020-03-09 20:45:35 +00:00
parent 81f58e0da7
commit 9ce9219a12
4 changed files with 16 additions and 13 deletions

View File

@ -25,7 +25,7 @@ export _wp_plugins_active="elementor wp-mail-smtp gdpr-cookie-compliance regener
export _docker_user="ray"
export _remote_host="wp-stack-five"
export _remote_host="seven"
export _domain="wptest.isnet.uk"
export _docker_base_dir="/var/docker"
export _mysql_root_passwd="db"

View File

@ -37,6 +37,7 @@ $_ssh_cmd_www "cd /var/www/html && wp core download --path=wordpress --skip-cont
$_ssh_cmd_www_cd "wp config create --dbname=wordpress --dbuser=wordpress --dbpass=$_wp_db_passwd"
$_ssh_cmd_www 'sed -i "s/<?php$/<?php\n\ndefine( '\''WP_DEBUG'\'', true );\ndefine( '\''WP_DEBUG_LOG'\'', true );\n/" /var/www/html/wordpress/wp-config.php'
$_ssh_cmd_www_cd "wp core install --url=$_wp_url --title=\"$_wp_title\" --admin_user=$_wp_admin_user --admin_password=\"$_wp_password\" --admin_email=$_wp_email --skip-email"
$_ssh_cmd_www_cd "wp rewrite structure /%postname%/"
printf "\nInstalling themes ..."

View File

@ -7,13 +7,11 @@ else
fi
_host="$_local_hostname.$_local_domain"
echo "Exporting data from '$_host' ..."
_cmd_wp_export="wp db export --dbuser=wordpress --dbpass=$_wp_db_passwd --add-drop-table data.sql"
_ssh_cmd="sshpass -p$_passwd_www ssh $_user_www@$_host"
_scp_cmd="sshpass -p$_passwd_www scp $_user_www@$_host:/tmp/wordpress.tar.gz"
echo "Exporting data archive ..."
echo "Exporting data ..."
$_ssh_cmd "cd /var/www/html/wordpress &&" $_cmd_wp_export
$_ssh_cmd 'cd /var/www/html/wordpress && tar czf /tmp/wordpress.tar.gz .'
$_ssh_cmd "rm /var/www/html/wordpress/data.sql"

View File

@ -5,13 +5,12 @@ _docker_dir="$_docker_base_dir/$_remote_host"
_ssh_cmd="ssh root@$_remote_host.$_domain"
_scp_to_base="root@$_remote_host.$_domain:$_docker_dir"
_tmp_env_file=$(mktemp)
echo "HOST=$_remote_host" > "$_tmp_env_file"
echo "MYSQL_ROOT_PASSWD=$_mysql_root_passwd" >> "$_tmp_env_file"
echo "MYSQL_USER=wordpress" >> "$_tmp_env_file"
echo "MYSQL_PASSWORD=wordpress" >> "$_tmp_env_file"
echo "MYSQL_DATABASE=wordpress" >> "$_tmp_env_file"
echo "HOST=$_remote_host" > .env
echo "DOMAIN=$_domain" >> .env
echo "MYSQL_ROOT_PASSWD=$_mysql_root_passwd" >> .env
echo "MYSQL_USER=wordpress" >> .env
echo "MYSQL_PASSWORD=wordpress" >> .env
echo "MYSQL_DATABASE=wordpress" >> .env
$_ssh_cmd "mkdir -p $_docker_dir/wordpress"
@ -19,7 +18,7 @@ echo "Copying files ..."
scp -r production/config "$_scp_to_base"/config
scp production/Dockerfile "$_scp_to_base"/Dockerfile
scp production/entrypoint.sh "$_scp_to_base"/entrypoint.sh
scp "$_tmp_env_file" "$_scp_to_base"/.env
scp .env "$_scp_to_base"/.env
scp production/docker-compose.yml "$_scp_to_base"/docker-compose.yml
scp wordpress.tar.gz "$_scp_to_base"/wordpress.tar.gz
@ -60,6 +59,11 @@ _cmd_docker_exec="cd $_docker_dir && docker exec -t $_remote_host-wordpress /bin
echo "$_ssh_cmd $_cmd_docker_exec"
$_ssh_cmd "$_cmd_docker_exec"
_cmd_wp="wp rewrite structure /%postname%/"
_cmd_docker_exec="cd $_docker_dir && docker exec -t $_remote_host-wordpress /bin/sh -c '$_cmd_wp'"
echo "$_ssh_cmd $_cmd_docker_exec"
$_ssh_cmd "$_cmd_docker_exec"
# _cmd_wp="wp user create $_wp_admin_user"
# _cmd_docker_exec="cd $_docker_dir && docker exec -t $_remote_host-wordpress /bin/sh -c '$_cmd_wp'"
# echo "$_ssh_cmd $_cmd_docker_exec"
@ -80,4 +84,4 @@ _cmd_docker_exec="cd $_docker_dir && docker exec -t $_remote_host-wordpress /bin
echo "$_ssh_cmd $_cmd_docker_exec"
$_ssh_cmd "$_cmd_docker_exec"
rm "$_tmp_env_file"
rm .env