Static HTML Served WordPress From Raspberry Pi - Part 2

In the previous post, I described what I did to get nginx to serve a WordPress statical html output by the Linux command wget. The only part left is to automate the process, as follows:
1. Set up SSH keys.
2. Create a script, "push-html.sh", that will
a. Run wget to update the statically output html
b. Run rsync over SSH, pushing the updated page
to the Raspberry Pi, updating only as necessary.
3. Bonus, use MobaXterm to make it all "push-button."

​1. Set up SSH keys.
From the desktop (where WordPress is installed), run
run the following as the desktop http user:

ssh-keygen -t rsa -b 2048 # Create public/private key pair. ssh-copy-id http_user@192.168.0.5 # Copy key to http_user@RaspPi

​2. Create script to push static html from Desktop to Raspberry Pi.
Prerequisites:
a. rsync and ssh must be on Desktop and Raspberry Pi.
b. Host file on desktop running WordPress set up so that the desktop's IP address set to lukesnow.no-ip.biz.
c. If a picture is worth a thousand words, then surely a script is worth a hundred! Here is the script, "push-html.sh", that I wrote:

#!/bin/bash

cd /home/http_user/current_static

wget -w 1 -m -N lukesnow.no-ip.biz -o luke-desktop-served-blog.log
# -w waits 1 seconds,
# -m mirrors whole site lukesnow.no-ip.biz,
# -N option only gets updates.
# -o stores messages in log.

# Run rsync over SSH, to update only parts of html on Raspberry Pi
# that have changed.
rsync -avz -e "ssh" ./lukesnow.no-ip.biz/./* html_user@192.168.0.5:/srv/html/

exit

​3. Make it all "push-button" with MobaXterm.
I created a new session in MobaXterm, "luke-desktop-push-to-pi", connecting as the html_user, then under Advanced SSH Settings -> Execute Command: "push-html.sh; logout". Now all I need to do is open MobaXterm, open the session, and it will do all this for me without ever having to type a command! You only have to enter the password once, on the first login; just hit "yes" to save it.

Comments !