-
Notifications
You must be signed in to change notification settings - Fork 1
/
web3updater
executable file
·124 lines (108 loc) · 4.86 KB
/
web3updater
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
nm="Web3Updater"
vs="v2"
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
if [ "$1" = "" ]; then
if [ -f /usr/lib/web3updater/update.json ]; then
web3updaterversion="""
\e[1;42m $nm \e[0m\e[100m version $vs - Patch: $(jq -r '.patch_at' /usr/lib/web3updater/update.json) \e[0m
\e[100m Created in 02-05-2021 by Daniella Mesquita \e[0m
"""
echo "$web3updaterversion"
echo "Type 'web3updater --help' (without quotes) to see a list of available commands."
echo "NOTE: this program isn't fully ready, yet."
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo " \e[1;42m $nm $vs \e[0m"
echo "Use these commands after/together with 'web3updater' command."
echo "Available commands:"
echo "Information:"
echo " --help, -h Shows all available commands"
echo " --version, -v Shows the version of $nm"
echo " init Initiates $nm into a project"
fi
if [ "$1" = "--version" ] || [ "$1" = "-v" ]; then
echo "$web3updaterversion"
fi
fi
fi
if [ ! -f /usr/lib/web3updater/update.json ]; then
echo ""
echo "It looks like its your first time using $nm..."
echo ""
echo "The web3 (that came from Ethereum and IPFS) is replacing the web 2.0, and $nm will put it also on OS/app updates!"
echo ""
echo "Never more depend on centralized servers to get updates."
echo ""
echo "As $nm can be used in any product to manage updates (such as Electron apps), it uses itself to update itself (meta-language)."
echo ""
echo "Initializing..."
cat > /usr/lib/web3updater/update.json <<EOF
{
"patch_at": 0
}
EOF
mkdir /usr/lib/web3updater/tmp-remote && cd /usr/lib/web3updater && git remote add web3updater tmp-remote && cd "$SCRIPTPATH"
echo "Done!"
fi
checkupdate () {
if [ ! -f new_patch_at.json ]; then
cd /usr/lib/web3updater
updtmsg="Updating $nm"
else
updtmsg="Working on updates"
fi
echo ""
echo "Checking for new updates..."
sh /usr/lib/web3updater/./sample_updates_3-5.sh apply4
sh /usr/lib/web3updater/./sample_updates_3-5.sh apply3
# Check if new_patch_at.json is telling us of an new update (similar of how web worker does on PWAs)
if [ "$(jq -r '.new_patch_at' new_patch_at.json)" -gt "$(jq -r '.patch_at' update.json)" ]; then # if new_patch_at.json contains a bigger number than what update.json have registered: BINGO! fire new update :)
echo "$updtmsg..."
sh ./updates.sh
sh /usr/lib/web3updater/./sample_updates_3-5.sh apply4 recordrecently
else
echo "UP-TO-DATE like a breeze! No new updates to install, yet."
sh /usr/lib/web3updater/./sample_updates_3-5.sh apply4 displayrecently
fi
}
if [ "$1" = "" ]; then
echo ""
echo "Welcome to $nm!"
echo "Made in a day where my mom couln't sleep because of an Hare Krishna that lives with my uncle, and the whole day she yelled at us and I became confused. Half day building this piece of art+utility, half day reasoning poorly and thinking to burn all my crypto because money != peace in some cases. But I won't burn my tokens because there are my mom, my uncle and my sister counting on me, and I hope I can change the life of more people, if I even can change the life of my mom and myself; which is being hard. My brain bugged now to think more so I'll try to focus back on outbursting by building this heresy that no one of these machist transphobe beared professional programmers have thought of. I know Im writing like in 2019 and this is a backstep, but my brain really bugged today, my rare peace of mind from a whole month has been partly broken today. My mom is bipolar, and about Hare I don't want to judge while irritated."
echo "Made in Itajai, Santa Catarina; but IMPORTANT: this is not a Brazilian funk music remix."
echo ""
echo "Web3Updater Version: $vs / Patch: $(jq -r '.patch_at' /usr/lib/web3updater/update.json)"
checkupdate
fi
if [ "$1" = "init" ]; then
echo "Initializing Web3Updater in this project..."
cat > update.json <<EOF
{
"patch_at": 0,
"cid_at": "",
"recently_checked_at": "",
"recently_updated_at": "",
"ens": ""
}
EOF
echo "Created update.json. Please don't forget to fill its ENS domain in that file."
cat > new_patch_at.json <<EOF
{
"new_patch_at": 0
}
EOF
echo "Created new_patch_at.json. Please don't forget to increase its number when adding an new update."
cp /usr/lib/web3updater/templates/updates.sh updates.sh
echo "Created updates.sh. Here is where you place the updates!"
fi
# "web3updater update" updates in the directory it currently is. if no valid, tell and updates itself
if [ "$1" = "check" ] || [ "$1" = "update" ]; then
checkupdate
# if [ -f new_patch_at.json ]; then
# echo "check and updates a project"
# else
# echo "check and updates itself"
# cd /usr/lib/web3updater
# web3updater check
#fi
fi