Publish to ipfs after mesh blog changes

This commit is contained in:
Bob Mottram 2016-09-09 10:03:47 +01:00
parent 2cb7b2aa74
commit 63ba1c993a
No known key found for this signature in database
GPG Key ID: 0452CC7CEA982E38
1 changed files with 25 additions and 5 deletions

View File

@ -31,22 +31,41 @@ PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-mesh-blog export TEXTDOMAIN=${PROJECT_NAME}-mesh-blog
export TEXTDOMAINDIR="/usr/share/locale" export TEXTDOMAINDIR="/usr/share/locale"
IPFS_PATH=/usr/bin
IPFS_COMMAND=$IPFS_PATH/ipfs
IPFS_PUBLIC=/home/$USER/.ipfs-public
BLOG_PATH=~/CreateBlog BLOG_PATH=~/CreateBlog
BLOG_CONTENT_PATH=$BLOG_PATH/content BLOG_CONTENT_PATH=$BLOG_PATH/content
CURRENT_BLOG_INDEX=/home/$USER/.blog-index CURRENT_BLOG_INDEX=/home/$USER/.blog-index
BLOG_EDITOR='pluma' BLOG_EDITOR='pluma'
DEFAULT_BLOG_TITLE=$"Freedombone Blog" 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 { function regenerate_blog {
clear clear
echo '' echo ''
echo $'Regenerating blog...' 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 cd $BLOG_PATH
if grep -q "SITENAME=u'${DEFAULT_BLOG_TITLE}'" $BLOG_PATH/pelicanconf.py; then if grep -q "SITENAME=u'${DEFAULT_BLOG_TITLE}'" $BLOG_PATH/pelicanconf.py; then
TOX_NICK=$(toxid --showuser) TOX_NICK=$(toxid --showuser)
@ -54,6 +73,7 @@ function regenerate_blog {
sed -i "s|SITENAME=.*|SITENAME=u\"${BLOG_TITLE}\"|g" $BLOG_PATH/pelicanconf.py sed -i "s|SITENAME=.*|SITENAME=u\"${BLOG_TITLE}\"|g" $BLOG_PATH/pelicanconf.py
fi fi
make html make html
ipfs_publish
} }
function view_blog { function view_blog {