automate publication of docs
In the docs ( https://osdn.net/docs/ProjectWeb_Services ) it says that the web site static content dir (CGI is available, coo'):
/home/groups/<the first letter of the project Unix name>/<the first and the second letters of the project UNIX name>/<project UNIX name>/htdocs/
Becomes:
/home/groups/j/jo/joypy/htdocs/
So the command will be something like (note the trailing slash on the source directory? It's not in the scp man page but the program behaves like rsync where it indicates to copy the contents of the dir not the dir itself. Good to know.):
scp -r \ ~/Desktop/ArchLayer/System/source/Thun/docs/sphinx_docs/_build/html/ \ sforman@shell.osdn.net:/home/groups/j/jo/joypy/htdocs/
But how to delete the old contents? This tar command will archive and delete the old site, in a tarball with the date in the name (although it has a space in it, I can look up the format string I want to use)
tar cvz --remove-files \ -f $HOME/site-backup-$(date -u +'%F-%T').tgz \ /home/groups/j/jo/joypy/htdocs/*
If I put that in a little script in my home dir I can execute that with ssh (why not just run the command directly? I don't trust the quoting and I don't want to look it up and test it right now. Putting the incantation in a file is faster and easier.)
Wow! Nearly two years since I last logged in:
sforman@bock:~/Desktop/ArchLayer/System/source/Thun$ ssh sforman@shell.osdn.net Last login: Wed Jun 27 07:42:14 2018 from c-69-181-182-62.hsd1.ca.comcast.net
I put the backup script in a file called backup-and-remove-htdocs in my home dir and set it to executable. Now I can run it remotely with ssh. So the combined command to replace the website with the latest version is:
cd <...>/Thun ssh sforman@shell.osdn.net '$HOME/backup-and-remove-htdocs' && \ scp -r ./docs/sphinx_docs/_build/html/ \ sforman@shell.osdn.net:/home/groups/j/jo/joypy/htdocs/
That almost works, the only wrinkle is that it puts the content in .../htdocs/html rather than just in .../htdocs, d'oh!
I guess the man page was right after all.
Use rsync instead:
cd <...>/Thun ssh sforman@shell.osdn.net '$HOME/backup-and-remove-htdocs' && \ rsync -rv --progress ./docs/sphinx_docs/_build/html/ \ sforman@shell.osdn.net:/home/groups/j/jo/joypy/htdocs/
The OSDN service provides https://joypy.osdn.io/ which I sort of manually upload using FTP, I was doing this with a different machine that I don't have at the moment, so I don't have the notes I made.
In any event, I should write a simple script to handle publishing the site when changes are made.