待辦事項 #40345

automate publication of docs

啟用日期: 2020-04-24 14:14 最後更新: 2020-04-26 06:20

回報者:
負責人:
類型:
狀態:
關閉
元件:
優先權:
3
嚴重程度:
5 - 中
處理結果:
修正
檔案:

細節

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.

Ticket History (3/6 Histories)

2020-04-24 14:14 Updated by: sforman
  • New Ticket "automate publication of docs" created
2020-04-26 05:15 Updated by: sforman
評語

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
2020-04-26 05:32 Updated by: sforman
評語

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/
2020-04-26 05:45 Updated by: sforman
評語

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.

2020-04-26 05:55 Updated by: sforman
評語

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/
2020-04-26 06:20 Updated by: sforman
  • 處理結果 Update from to 修正
  • 狀態 Update from 開啟 to 關閉

Attachment File List

No attachments

編輯

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » 登入