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

Loading…
Cancel
Save