Browse Source

Improved generate.sh

master
Chris 6 years ago
parent
commit
159d6cc963
  1. 37
      admin/generate.sh

37
admin/generate.sh

@ -4,33 +4,33 @@
# If this script ist not stored in ~/hugogentmp/ change $DIR
# Path to hugo executable
HUGO=~/bin/hugo
# HUGO=~/kred/hugo/hugo
#HUGO=~/bin/hugo
HUGO=~/kred/hugo/hugo
# Path to output destination. Folder must exists
PUBLIC_WWW=/var/www/virtual/$USER/html/kollegenrunde
#PUBLIC_WWW=~/hugotest/public
#PUBLIC_WWW=/var/www/virtual/$USER/html/kollegenrunde
PUBLIC_WWW=~/hugotest/html/kollegenrunde
# Working dir: here is the script and git's working dirs
TMPDIR=~/hugogentmp
GENDIR=~/kollegengen
TMPPUBLIC=$TMPDIR/public
TMPPUBLIC=$GENDIR/kollegenrunde
# Path to persisted log file, e.g. in web folder
LOG=$TMPDIR/log.txt
LOG=$GENDIR/log.txt
# Path to a temp log file for hugo's stdout
TMPLOG=$TMPDIR/tmplog.txt
TMPLOG=$GENDIR/tmplog.txt
# Path to a temp log file for hugo's errout
TMPERR=$TMPDIR/tmperr.txt
TMPERR=$GENDIR/tmperr.txt
# Tmp file with timestamp string
TMPDATE=$TMPDIR/tmpdate.txt
TMPDATE=$GENDIR/tmpdate.txt
# Paths to the local gits
TMPGIT_HUGO=$TMPDIR/kollegen-hugo
TMPGIT_POSTS=$TMPDIR/kollegen-posts
TMPGIT_HUGO=$GENDIR/kollegen-hugo
TMPGIT_POSTS=$GENDIR/kollegen-posts
# Path to our repositories
GIT_HUGO=https://kollegen.uber.space/gitea/kollegenrunde/kollegen-hugo.git
@ -58,8 +58,8 @@ finish () {
if [ -f $LOG ]
then
echo "Moving log file to $LOG $PUBLIC_WWW"
mv -v $LOG $PUBLIC_WWW
echo "Moving log file to $LOG $PUBLIC_WWW/"
mv -v $LOG "$PUBLIC_WWW/"
fi
if [ -f $TMPLOG ]
@ -99,7 +99,7 @@ fi
date > $TMPDATE
log_file $TMPDATE
log "Using tmp dir $TMPDIR"
log "Using tmp dir $GENDIR"
if [ ! -d $TMPGIT_POSTS ]
then
@ -115,7 +115,7 @@ if [ ! -d $TMPGIT_HUGO ]
then
# jetzt clonen wir das Repository in den temporären Ordner
mkdir -v $TMPGIT_HUGO 2>&1 | tee -a $LOG
git clone $GIT_POSTS $TMPGIT_HUGO 2>&1 | tee -a $LOG
git clone $GIT_HUGO $TMPGIT_HUGO 2>&1 | tee -a $LOG
else
cd $TMPGIT_HUGO && git pull $GIT_HUGO 2>&1 | tee -a $LOG
fi
@ -145,10 +145,15 @@ if [ -d $PUBLIC_WWW ]
then
log "Remove $PUBLIC_WWW"
rm -r -f $PUBLIC_WWW 2>&1 | tee -a $LOG
else
log "Create $PUBLIC_WWW"
mkdir -v $PUBLIC_WWW 2>&1 | tee -a $LOG
fi
# Publish now
log "Copy $TMPPUBLIC to $PUBLIC_WWW"
rm -r -f $PUBLIC_WWW
mv -v $TMPPUBLIC $PUBLIC_WWW 2>&1 | tee -a $LOG
log "Ready, Blog created in $PUBLIC_WWW!"

Loading…
Cancel
Save