diff options
| -rw-r--r-- | content/posts/how-this-blog-works/index.org | 42 | 
1 files changed, 42 insertions, 0 deletions
| diff --git a/content/posts/how-this-blog-works/index.org b/content/posts/how-this-blog-works/index.org index fa1acb2..aa1f329 100644 --- a/content/posts/how-this-blog-works/index.org +++ b/content/posts/how-this-blog-works/index.org @@ -176,3 +176,45 @@ through how I run by blog.    #+END_SRC  ** Local machine + +   This is the script used to deploy the website. It's placed in the +   root of the hugo git repository. + +   #+BEGIN_SRC shell +   #!/bin/sh + +   cd '$(dirname "$0")' +   hugo +   rsync -va --progress --rsync-path="/usr/bin/openrsync" public/ blog@lambda.cx:/var/www/htdocs/lambda.cx/blog +   #+END_SRC + +   Going through it line by line: + +   - ~cd '$(dirname "$0")'~ Changes to the script's directory. This is +     used in case you're running it from somewhere else. +   - ~hugo~ Compile the website into static files located in the +     =public= directory. +   - ~rsync -va --progress --rsync-path="/usr/bin/openrsync" public/ +     blog@lambda.cx:/var/www/htdocs/lambda.cx/blog~ This one is bigger +     so I'll break it down. +     - =rsync= A command that synchronizes files between two directories +     - =-v= Be verbose, this is optional but I like it +     - =-a= Stands for "archive": copy recursively, keep +       permissions, etc. See the =rsync= man page if you're curious. +     - =--progress= Show progress, also optional +     - ~--rsync-path="/usr/bin/openrsync"~ This line is very important +       for OpenBSD servers. OpenBSD has its own =rsync= implementation +       called =openrsync=. Without this argument, =rsync= will connect +       to the server, see that the =rsync= command doesn't exist, and +       fail. +     - =public/= Specify which folder we want to sync. The trailing +       =/= is important. Without it =rsync= will copy the folder +       instead of the folder's contents, which is what we want. +     - =blog@lambda.cx:/var/www/htdocs/lambda.cx/blog= Login to user +       =blog= on server =lambda.cx=, syncing files with the +       =/var/www/htdocs/lambda.cx/blog= directory. + +     The reason to use =rsync= here instead of something like =scp= is +     that =rsync= won't copy files it doesn't need to, so if 3/4 of +     the files didn't change when you updated the blog, it won't waste +     time re-uploading them. | 
