#!/bin/bash # The following creates a mixtape data message # We can extend it by calling the pack_z_block.sh mixtape/add data ZFILESDIR="$WORKDIR/files" TEMP="/tmp/aktmp" if [ ! -d $ZFILESDIR ]; then mkdir $ZFILESDIR cd $ZFILESDIR git init else logthis "error $ZFILESDIR not found" fi tempassin(){ if [ ! -z $1 ]; then TEMPASSIN="$1" else TIMESTAMP="$(date -u +%s)" TEMPASSIN="/tmp/aktmp_$TIMESTAMP" fi if [ ! -d $TEMPASSIN ]; then mkdir $TEMPASSIN fi cd $TEMPASSIN echo "$TEMPASSIN" } usage(){ title echo "$0 - file" } add(){ CRP="$(pwd)" FILENAME="$1" main $FILENAME $CRP cat $PWD/data | json_pp pack_z_block file/add $PWD/data } main(){ FILENAME="$1" CRP="$2" echo "Adding $FILENAME" tempassin cp $2/$1 $TEMPASSIN/$1 FILE="$TEMPASSIN/$1" FILE_IPFS_HASH=$(ipfs add -q $FILE) SIGN_FILE=$FILE".asc" gpg2 --detach-sign --sign-with $FINGERPRINT --armor --output $SIGN_FILE $FILE SIGNATURE=$(ipfs add -q $SIGN_FILE) cat > data <