From 63ba1c993a1202d11740c3710c2cb6d3606d7912 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 9 Sep 2016 10:03:47 +0100 Subject: [PATCH] Publish to ipfs after mesh blog changes --- src/freedombone-mesh-blog | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/freedombone-mesh-blog b/src/freedombone-mesh-blog index 4927e349..7ebf621b 100755 --- a/src/freedombone-mesh-blog +++ b/src/freedombone-mesh-blog @@ -31,22 +31,41 @@ PROJECT_NAME='freedombone' export TEXTDOMAIN=${PROJECT_NAME}-mesh-blog export TEXTDOMAINDIR="/usr/share/locale" +IPFS_PATH=/usr/bin +IPFS_COMMAND=$IPFS_PATH/ipfs +IPFS_PUBLIC=/home/$USER/.ipfs-public + BLOG_PATH=~/CreateBlog BLOG_CONTENT_PATH=$BLOG_PATH/content CURRENT_BLOG_INDEX=/home/$USER/.blog-index BLOG_EDITOR='pluma' DEFAULT_BLOG_TITLE=$"Freedombone Blog" +function ipfs_publish { + DIR_TO_CHECK=/home/$USER/Public + if [ ! -d $DIR_TO_CHECK ]; then + return + fi + + echo '' + echo $'Publishing to IPFS...' + + OLD_STAT_FILE=/home/$MY_USERNAME/.old_stat.txt + NEW_STAT=$(stat -t $DIR_TO_CHECK) + echo $($IPFS_COMMAND add -rq /home/$USER/Public | tail -n 1) > $IPFS_PUBLIC + echo "$NEW_STAT" > $OLD_STAT_FILE + + if [ -f $IPFS_PUBLIC ]; then + IPFS_PUBLIC_ID=$(cat $IPFS_PUBLIC) + $IPFS_COMMAND name publish /ipfs/$IPFS_PUBLIC_ID + fi +} + function regenerate_blog { clear echo '' echo $'Regenerating blog...' - OLD_STAT_FILE=/home/$USER/.old_stat.txt - if [ -f $OLD_STAT_FILE ]; then - rm -f $OLD_STAT_FILE - fi - cd $BLOG_PATH if grep -q "SITENAME=u'${DEFAULT_BLOG_TITLE}'" $BLOG_PATH/pelicanconf.py; then TOX_NICK=$(toxid --showuser) @@ -54,6 +73,7 @@ function regenerate_blog { sed -i "s|SITENAME=.*|SITENAME=u\"${BLOG_TITLE}\"|g" $BLOG_PATH/pelicanconf.py fi make html + ipfs_publish } function view_blog {