From 57f4e0da25a7dd3ad001ea80610dbde9e5ae0ba7 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 12 Jan 2023 05:26:45 +0000 Subject: [PATCH] dev post about script --- .../2023-01-12-non-repo-static-content.md | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 dev/_posts/2023-01-12-non-repo-static-content.md diff --git a/dev/_posts/2023-01-12-non-repo-static-content.md b/dev/_posts/2023-01-12-non-repo-static-content.md new file mode 100644 index 0000000..bbaf5a7 --- /dev/null +++ b/dev/_posts/2023-01-12-non-repo-static-content.md @@ -0,0 +1,39 @@ +--- +title: Non-Repo Static Content +layout: post +date: 2023-01-12 05:19:23 +permalink: /dev/2023/JAN/12-non-repo-static-content.php +excerpt_separator: +--- + +There's a lot of content I don't keep in the repository. So how do I make sure it's all there? + +Hacky Bash scripts. + + + +The nice thing about Jekyll is it's a satic site generator and works after hours of raging at my machine. The bad thing is it deletes the entire documentroot whenever you generate the site. This means anything not already in the repo doesn't get copied over. There's a lot of large content and stuff I don't want to keep there...mostly because it's a secret. So I sat around and though of the best way to restore all this content. I tried a few bash scripts to symlink, but it failed. So I came up with this: + +``` +# pushd /var/www/pickmystatic +# pax -rwlpp . /var/www/pickmy +# popd +``` + +The problem I was having is if a directory already existed; nothing would symlink. pax solved the problem, except pax copied data. I didn't need the redundancy. + +I'm getting ready to put another jekyll blog on another domain, so I decided I should fix this once and for all. So here's the new hacky script: + +``` +dir=$(find $WWW_STATIC -mindepth 1 -type d -printf '%f\n') +for d in $dir +do +[ -d "$PUBLIC_WWW/$d" ] && ln -s $WWW_STATIC/$d/* $PUBLIC_WWW/$d/ +done +ln -s $WWW_STATIC/* $PUBLIC_WWW/ +``` + +This is called as a seperate script in the githook that runs whenever I push a new post (or change) to the repository. It runs after site generation naturally. It gets a list of existing directories from the static directory; and if the directory exists, symlinks all the files in to it. It then goes back and runs a generic symlink of everything. + +It works well enough, with the cavet that it will generate a "file exists" error. It's non-fatal though. +