From 3ba902a37daa8f28552ca43665458f97d0634e26 Mon Sep 17 00:00:00 2001 From: Stefan Kreutz Date: Thu, 28 Apr 2022 14:55:17 +0200 Subject: Move shell scripts to dedicated directory --- check | 21 --------------------- deploy | 58 ---------------------------------------------------------- script/check | 21 +++++++++++++++++++++ script/deploy | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ script/watch | 3 +++ site.hs | 2 +- 6 files changed, 84 insertions(+), 80 deletions(-) delete mode 100755 check delete mode 100755 deploy create mode 100755 script/check create mode 100755 script/deploy create mode 100755 script/watch diff --git a/check b/check deleted file mode 100755 index 6428077..0000000 --- a/check +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/sh - -# Run third-party markup checkers. -# See W3C Developer Tools at https://w3c.github.io/developers/tools/ - -open() { - xdg-open "$@" >/dev/null 2>&1 & -} - -# W3C Nu HTML Checker -open "https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.skreutz.com%2Fposts%2Funix-domain-socket-forwarding-with-openssh%2F" - -# W3C CSS Validator -open "https://jigsaw.w3.org/css-validator/validator?uri=https%3A%2F%2Fwww.skreutz.com%2F&profile=css3svg&usermedium=all&warning=1&vextwarning=&lang=en" - -# W3C Feed Validator -open "https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fwww.skreutz.com%2Ffeeds%2Fposts.rss" -open "https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fwww.skreutz.com%2Ffeeds%2Fposts.atom" - -# W3C Link Checker -open "https://validator.w3.org/checklink?uri=https%3A%2F%2Fwww.skreutz.com%2F&hide_type=all&recursive=on&depth=10&check=Check" diff --git a/deploy b/deploy deleted file mode 100755 index 0a37a83..0000000 --- a/deploy +++ /dev/null @@ -1,58 +0,0 @@ -#! /bin/sh - -# Deploy the static website. -# -# Re-generates the static website from source and asserts a clean working tree -# before uploading the website to the server. -# -# Submits the sitemap URL to Google and Bing. - -set -o errexit -set -o nounset - -# Git root directory -root="$( git rev-parse --show-toplevel )" - -# Source directory with a trailing slash for rsync -src="${root}/_site/" - -# Git revision -rev="$( git rev-parse --verify HEAD )" - -# ISO 8601 timestamp -now="$( date -u "+%Y-%m-%dT%H:%M:%SZ" )" - -# Archive file name -archive="./${now}_${rev}.tar.gz" - -printf "Re-generating static website from source ...\\n" -( cd "${root}" \ - && cabal v2-run exe:site -- clean >/dev/null 2>&1 \ - && cabal v2-run exe:site -- build >/dev/null 2>&1 ) - -[ -z "$( git status --porcelain )" ] || { - ( >&2 printf "error: dirty working tree\\n" ) - printf "Aborting deployment due to unstaged changes or untracked files.\\n" - exit 1 -} - -openrsync --rsync-path=openrsync --archive --delete --verbose \ - "${src}" "engine.skreutz.com:/var/www/htdocs/www.skreutz.com" - -tar -czf "${archive}" "${src}" -scp "${archive}" engine.skreutz.com:archive/www/ -rm "${archive}" - -curl \ - --silent \ - --output /dev/null \ - http://www.google.com/ping?sitemap=https://www.skreutz.com/sitemap.xml \ - || ( >&2 printf "error: failed to submit live sitemap to google.com\\n" ) - -curl \ - --silent \ - --output /dev/null \ - http://www.bing.com/ping?sitemap=https%3A%2F%2Fwww.skreutz.com/sitemap.xml \ - || ( >&2 printf "error: failed to submit live sitemap to bing.com\\n" ) - -/bin/sh "${root}/check" diff --git a/script/check b/script/check new file mode 100755 index 0000000..6428077 --- /dev/null +++ b/script/check @@ -0,0 +1,21 @@ +#! /bin/sh + +# Run third-party markup checkers. +# See W3C Developer Tools at https://w3c.github.io/developers/tools/ + +open() { + xdg-open "$@" >/dev/null 2>&1 & +} + +# W3C Nu HTML Checker +open "https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.skreutz.com%2Fposts%2Funix-domain-socket-forwarding-with-openssh%2F" + +# W3C CSS Validator +open "https://jigsaw.w3.org/css-validator/validator?uri=https%3A%2F%2Fwww.skreutz.com%2F&profile=css3svg&usermedium=all&warning=1&vextwarning=&lang=en" + +# W3C Feed Validator +open "https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fwww.skreutz.com%2Ffeeds%2Fposts.rss" +open "https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fwww.skreutz.com%2Ffeeds%2Fposts.atom" + +# W3C Link Checker +open "https://validator.w3.org/checklink?uri=https%3A%2F%2Fwww.skreutz.com%2F&hide_type=all&recursive=on&depth=10&check=Check" diff --git a/script/deploy b/script/deploy new file mode 100755 index 0000000..ec2a6f3 --- /dev/null +++ b/script/deploy @@ -0,0 +1,59 @@ +#! /bin/sh + +# Deploy the static website. +# +# Re-generates the static website from source and asserts a clean working tree +# before uploading the website to the server. +# +# Submits the sitemap URL to Google and Bing. + +set -o errexit +set -o nounset + +# Git root directory +root="$( git rev-parse --show-toplevel )" + +# Source directory with a trailing slash for rsync +src="${root}/_site/" + +# Git revision +rev="$( git rev-parse --verify HEAD )" + +# ISO 8601 timestamp +now="$( date -u "+%Y-%m-%dT%H:%M:%SZ" )" + +# Archive file name +archive="./${now}_${rev}.tar.gz" + +printf "Re-generating static website from source ...\\n" +( cd "${root}" \ + && cabal v2-run exe:site -- clean >/dev/null 2>&1 \ + && cabal v2-run exe:site -- build >/dev/null 2>&1 ) + +[ -z "$( git status --porcelain )" ] || { + ( >&2 printf "error: dirty working tree\\n" ) + printf "Aborting deployment due to unstaged changes or untracked files.\\n" + exit 1 +} + +openrsync --rsync-path=openrsync --archive --delete --verbose \ + "${src}" "engine.skreutz.com:/var/www/htdocs/www.skreutz.com" + +tar -czf "${archive}" "${src}" +scp "${archive}" engine.skreutz.com:archive/www/ +rm "${archive}" + +curl \ + --silent \ + --output /dev/null \ + http://www.google.com/ping?sitemap=https://www.skreutz.com/sitemap.xml \ + || ( >&2 printf "error: failed to submit live sitemap to google.com\\n" ) + +curl \ + --silent \ + --output /dev/null \ + http://www.bing.com/ping?sitemap=https%3A%2F%2Fwww.skreutz.com/sitemap.xml \ + || ( >&2 printf "error: failed to submit live sitemap to bing.com\\n" ) + +# shellcheck source=./check +. "${root}/script/check" diff --git a/script/watch b/script/watch new file mode 100755 index 0000000..f12d1a7 --- /dev/null +++ b/script/watch @@ -0,0 +1,3 @@ +#! /bin/sh + +cabal v2-run exe:site -- watch diff --git a/site.hs b/site.hs index 6509e4c..17d0aed 100644 --- a/site.hs +++ b/site.hs @@ -93,7 +93,7 @@ main = hakyllWith hakyllConfig $ do hakyllConfig :: Configuration hakyllConfig = defaultConfiguration { previewPort = 8080 - , deployCommand = "./deploy" + , deployCommand = "./script/deploy" } postContext :: Context String -- cgit v1.2.3