From 8f9123d15e2ccba4af4e39b4ba69278701d8c793 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Sun, 12 Jun 2022 17:57:12 +0100 Subject: [PATCH] refresh the build and publish scripts --- .gitignore | 3 ++- build.sh => build | 0 hugo-server | 22 ++++++++++++++++++++++ new | 43 +++++++++++++++++++++++++++++++++++++++++++ publish | 4 ++-- push-asset | 25 +++++++++++++++++++++++++ 6 files changed, 94 insertions(+), 3 deletions(-) rename build.sh => build (100%) create mode 100755 hugo-server create mode 100755 new create mode 100755 push-asset diff --git a/.gitignore b/.gitignore index bcfb58f..1c063d3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ public/ **/*workspace .idea/ .hugo_build.lock - +logs/ +build/ diff --git a/build.sh b/build similarity index 100% rename from build.sh rename to build diff --git a/hugo-server b/hugo-server new file mode 100755 index 0000000..b0cc1a7 --- /dev/null +++ b/hugo-server @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +export LOG=./logs/hugo-server.log + +if ! [ -z "$1" ]; then + if [[ "$1" == "start" ]]; then + hugo server -D --disableFastRender --enableGitInfo -v --debug > $LOG 2>&1 & + echo "Server started on $(pidof hugo)" + elif [[ "$1" == "stop" ]]; then + kill -9 $(pidof hugo) + elif [[ "$1" == "status" ]]; then + pid=$(pidof hugo) + if ! [ -z "$pid" ]; then + echo "Hugo Server Active. PID: ${pid}" + else + echo "Hugo Server Is Inactive." + fi + fi +else + echo "You can 'start' or 'stop' the server, or get the 'status'." + exit 1 +fi diff --git a/new b/new new file mode 100755 index 0000000..ed9f550 --- /dev/null +++ b/new @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +export ED='tilde' +# export ED='vi' + +Help() +{ + # Display Help + echo "Add a new post to a hugo blog" + echo + echo "Syntax: new -c contentType -t 'some title'" + echo "options:" + echo "c Content Type: 'post', 'podcast', 'reading'" + echo "t Content Title: \"Any Plain Text At All\"" + echo "h This display." + exit 0 +} + +while getopts c:t:h flag +do + case "${flag}" in + c) contentType=${OPTARG};; + t) title=${OPTARG};; + h) Help + esac +done + +if [ -z "$contentType" ]; then + echo "Specify a content type. Eg. '-c post'" + exit 1 +fi + +if [ -z "$title" ]; then + echo "Specify an entry title. Eg. '-t \"The Hamburg Happening\"'" + exit 1 +fi + +tmp=${title// /-} +filename=${tmp,,} +echo $filename + +hugo new ${contentType}/${filename}.md +$ED content/${contentType}/${filename}.md diff --git a/publish b/publish index 2e184a3..cf07d7d 100755 --- a/publish +++ b/publish @@ -3,10 +3,10 @@ # commit and push... git add .;git commit -m"$@";git push -u origin master -sudo rm -R public # destroy the old build first +rm -rf public # destroy the old build first hugo # build the new site sudo chown -R gmgauthier:www-data ./public/* # set the ownership before transfer rsync --super -avh -e ssh ./public/* gmgauthier@boethius:/hosting/sites/gmgauthier.com -echo "ls -lA /hosting/sites/gmgauthier.com" | ssh gmgauthier@boethius /bin/bash +# echo "ls -lA /hosting/sites/gmgauthier.com" | ssh gmgauthier@boethius /bin/bash diff --git a/push-asset b/push-asset new file mode 100755 index 0000000..a600a11 --- /dev/null +++ b/push-asset @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +if [[ -z "$1" ]]; then + echo "Supply a file with full path to be published" + exit 1 +fi + +file=$(basename ${1}) + +# The assumption is all images are for the blog +if [[ "$1" =~ .*\.(gif|jpg|png) ]]; then + s3cmd put -P ${1} s3://gmgauthier/blog/img/${file} +fi + +# The assumption is all audio is for the podcast +if [[ "$1" =~ .*\.(mp3|ogg|wav) ]]; then + s3cmd put -P ${1} s3://gmgauthier/podcast/audio/${file} +fi + +# The assumption is all video is generic +if [[ "$1" =~ .*\.(mp4|mkv|m4v) ]]; then + s3cmd put -P ${1} s3://gmgauthier/videos/${file} +fi + +