refresh the build and publish scripts

This commit is contained in:
Greg Gauthier 2022-06-12 17:57:12 +01:00
parent e5f02d9044
commit 8f9123d15e
6 changed files with 94 additions and 3 deletions

3
.gitignore vendored
View File

@ -3,4 +3,5 @@ public/
**/*workspace **/*workspace
.idea/ .idea/
.hugo_build.lock .hugo_build.lock
logs/
build/

View File

22
hugo-server Executable file
View File

@ -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

43
new Executable file
View File

@ -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

View File

@ -3,10 +3,10 @@
# commit and push... # commit and push...
git add .;git commit -m"$@";git push -u origin master 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 hugo # build the new site
sudo chown -R gmgauthier:www-data ./public/* # set the ownership before transfer sudo chown -R gmgauthier:www-data ./public/* # set the ownership before transfer
rsync --super -avh -e ssh ./public/* gmgauthier@boethius:/hosting/sites/gmgauthier.com 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

25
push-asset Executable file
View File

@ -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