aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-files
blob: f830e17869f58c207b51696b3e4b3a769b8ae4a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# The following creates a mixtape data message
# We can extend it by calling the pack_z_block.sh mixtape/add data

usage(){
	title
	echo "$0 - file"
}

main(){
    echo "Adding $FILE"

    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 <<EOF
{
    "timestamp":"$(date -u +%s)",
    "filename":"$FILE",
    "ipfs":"$FILE_IPFS_HASH",
    "detach":"$SIGNATURE"
}
EOF

}

title(){
    echo "File block creator"
    echo "=================="
}


if [ ! -z $1 ];
then
    PWD="$(pwd)"
    FILE="$PWD/$1"
    main
    cat $PWD/data | json_pp
    pack_z_block file/add $PWD/data
else usage
fi