-
Notifications
You must be signed in to change notification settings - Fork 42
/
microledger.me.sh
executable file
·55 lines (44 loc) · 1.81 KB
/
microledger.me.sh
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
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.2
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
echo '
############################################################### ipfs
## __ __ ___ ____ ____ ___ _ _____ ____ ____ _____ ____
## | \/ |_ _/ ___| _ \ / _ \ | | | ____| _ \ / ___| ____| _ \
## | |\/| || | | | |_) | | | | | | | _| | | | | | _| _| | |_) |
## | | | || | |___| _ <| |_| | | |___| |___| |_| | |_| | |___| _ <
## |_| |_|___\____|_| \_\\___/ |_____|_____|____/ \____|_____|_| \_\ me
'
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
OLD=$(cat ${MY_PATH}/.chain)
[[ -z ${OLD} ]] \
&& GENESYS=$(ipfs add -rwq ${MY_PATH}/* | tail -n 1) \
&& echo ${GENESYS} > ${MY_PATH}/.chain \
&& echo "### - (^‿‿^) - " >> ${MY_PATH}/README.md \
&& echo /ipfs/${GENESYS} >> ${MY_PATH}/README.md \
&& echo "CHAIN BLOC ZERO : ${GENESYS}" \
ts=$(cat ${MY_PATH}/.moats 2>/dev/null)
[[ -z $ts ]] && ts=${MOATS}
## TIMESTAMP CHAIN SHIFTING
cp ${MY_PATH}/.chain \
${MY_PATH}/.chain.$ts
IPFSME=$(ipfs add -rwHq --ignore=.git --ignore-rules-path=.gitignore ${MY_PATH}/* | tail -n 1)
[[ ${IPFSME} == ${OLD} ]] && echo "No change." && exit 0
## CHAIN UPGRADE
echo ${IPFSME} > ${MY_PATH}/.chain
echo ${MOATS} > ${MY_PATH}/.moats
## README UPGRADE
ipfs pin rm ${OLD}
sed -i "s~${OLD}~${IPFSME}~g" ${MY_PATH}/README.md
## AUTO GIT
echo '# ENTER COMMENT FOR YOUR COMMIT :'
git add .
read COMMENT \
&& git commit -m "$COMMENT : https://ipfs.copylaradio.com/ipfs/${IPFSME}" \
&& git push
exit 0