From a3fd4c4043b7b3a58dfc9fabe899999c037e70c4 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Thu, 8 Sep 2016 09:35:53 +0100
Subject: [PATCH] Tidying

---
 src/freedombone-app-blogstatic | 53 +++++++++++++---------------------
 1 file changed, 20 insertions(+), 33 deletions(-)

diff --git a/src/freedombone-app-blogstatic b/src/freedombone-app-blogstatic
index 1815ea8c5..f1a9f4951 100755
--- a/src/freedombone-app-blogstatic
+++ b/src/freedombone-app-blogstatic
@@ -171,45 +171,36 @@ function mesh_install_blogstatic {
         return
     fi
 
-    if [ ! -d $rootdir/home/$MY_USERNAME/Public/Blog ]; then
-        mkdir -p $rootdir/home/$MY_USERNAME/Public/Blog
-        chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Public
-    fi
-
-    STATIC_BLOG_INSTALL_DIR=/home/$MY_USERNAME/CreateBlog
-    STATIC_BLOG_PATH=/home/$MY_USERNAME/Public/Blog
-
     chroot "$rootdir" apt-get -y install python-pip
     chroot "$rootdir" pip install ipython
     chroot "$rootdir" pip install Markdown
     chroot "$rootdir" pip install typogrify
     chroot "$rootdir" pip install pelican
 
+    STATIC_BLOG_INSTALL_DIR=/home/$MY_USERNAME/CreateBlog
+    STATIC_BLOG_PATH=/home/$MY_USERNAME/Public/Blog
+
     if [ ! -d $rootdir$STATIC_BLOG_INSTALL_DIR ]; then
         mkdir -p $rootdir$STATIC_BLOG_INSTALL_DIR
     fi
 
-    if [ ! -d $rootdir$STATIC_BLOG_INSTALL_DIR/content ]; then
-        mkdir -p $rootdir$STATIC_BLOG_INSTALL_DIR/content
-    fi
-
     if [ ! -d $rootdir$STATIC_BLOG_PATH ]; then
         mkdir -p $rootdir$STATIC_BLOG_PATH
     fi
 
-    STATIC_BLOG_FILE=$rootdir$STATIC_BLOG_INSTALL_DIR/pelicanconf.py
-    create_pelican_conf $STATIC_BLOG_FILE
-
-    STATIC_BLOG_FILE=$rootdir$STATIC_BLOG_INSTALL_DIR/Makefile
-    create_pelican_makefile $STATIC_BLOG_FILE
+    if [ ! -d $rootdir$STATIC_BLOG_INSTALL_DIR/content ]; then
+        mkdir -p $rootdir$STATIC_BLOG_INSTALL_DIR/content
+    fi
 
-    STATIC_BLOG_FILE=$rootdir$STATIC_BLOG_INSTALL_DIR/publishconf.py
-    create_pelican_publish_conf $STATIC_BLOG_FILE
+    create_pelican_conf $rootdir$STATIC_BLOG_INSTALL_DIR/pelicanconf.py
+    create_pelican_makefile $rootdir$STATIC_BLOG_INSTALL_DIR/Makefile
+    create_pelican_publish_conf $STATIC_BLOG_INSTALL_DIR/publishconf.py
 
     git clone --recursive $PELICAN_THEMES_REPO $rootdir$STATIC_BLOG_INSTALL_DIR/themes
     git clone --recursive $PELICAN_PLUGINS_REPO $rootdir$STATIC_BLOG_INSTALL_DIR/plugins
 
     chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME $STATIC_BLOG_INSTALL_DIR
+    chroot "$rootdir" chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/Public
 }
 
 function install_blogstatic {
@@ -222,40 +213,36 @@ function install_blogstatic {
         return
     fi
 
-    STATIC_BLOG_INSTALL_DIR=/etc/blog
-    STATIC_BLOG_PATH=/var/www/$STATIC_BLOG_DOMAIN/htdocs
-
     apt-get -y install python-pip
     pip install ipython
     pip install Markdown
     pip install typogrify
     pip install pelican
 
+    STATIC_BLOG_INSTALL_DIR=/etc/blog
+    STATIC_BLOG_PATH=/var/www/$STATIC_BLOG_DOMAIN/htdocs
+
     if [ ! -d $STATIC_BLOG_INSTALL_DIR ]; then
         mkdir -p $STATIC_BLOG_INSTALL_DIR
     fi
 
-    if [ ! -d $STATIC_BLOG_INSTALL_DIR/content ]; then
-        mkdir -p $STATIC_BLOG_INSTALL_DIR/content
-    fi
-
     if [ ! -d $STATIC_BLOG_PATH ]; then
         mkdir -p $STATIC_BLOG_PATH
     fi
 
-    STATIC_BLOG_FILE=$STATIC_BLOG_INSTALL_DIR/pelicanconf.py
-    create_pelican_conf $STATIC_BLOG_FILE
-
-    STATIC_BLOG_FILE=$STATIC_BLOG_INSTALL_DIR/Makefile
-    create_pelican_makefile $STATIC_BLOG_FILE
+    if [ ! -d $STATIC_BLOG_INSTALL_DIR/content ]; then
+        mkdir -p $STATIC_BLOG_INSTALL_DIR/content
+    fi
 
-    STATIC_BLOG_FILE=$STATIC_BLOG_INSTALL_DIR/publishconf.py
-    create_pelican_publish_conf $STATIC_BLOG_FILE
+    create_pelican_conf $STATIC_BLOG_INSTALL_DIR/pelicanconf.py
+    create_pelican_makefile $STATIC_BLOG_INSTALL_DIR/Makefile
+    create_pelican_publish_conf $STATIC_BLOG_INSTALL_DIR/publishconf.py
 
     git clone --recursive $PELICAN_THEMES_REPO $STATIC_BLOG_INSTALL_DIR/themes
     git clone --recursive $PELICAN_PLUGINS_REPO $STATIC_BLOG_INSTALL_DIR/plugins
 
     chown -R $MY_USERNAME:$MY_USERNAME $STATIC_BLOG_INSTALL_DIR
+    chown -R www-data:www-data $STATIC_BLOG_PATH
 
     echo 'install_blogstatic' >> $COMPLETION_FILE
 }
-- 
GitLab