blob: bed6e8625d3f80bbd7d9ae4b8ab6b3bfba788edd (
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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
#!/bin/bash
clear
printf "Arching Kaos Tools Installer\n"
printf "============================\n"
printf "Welcome to our ever involving installer\n"
printf "We will be as verbose as possible, yet minimal\n"
printf "Our default behaviour is to ask the less is needed\n"
printf "\n"
printf "For minimum overall friction, we will ask sudo access only if it's\n"
printf "needed for a missing package.\n"
printf "\n"
printf "We discourage running the installer with sudo.\n"
printf "\n"
printf "Installation starts in..."
countdown=30
printf " %s" "$countdown"
countdown="$(expr $countdown - 1)"
sleep 1
while [ $countdown -gt 0 ]
do
if [ $countdown -lt 10 ]
then
printf "\b\b %s" "$countdown"
else
printf "\b\b%s" "$countdown"
fi
countdown="$(expr $countdown - 1)"
sleep 1
done
printf "\b\b starting!!!"
sleep 1
printf "\n"
packageManager=""
checkPkgManager(){
printf "Searching for package manager..."
which dnf
if [ $? == 0 ]
then
printf "\tFound DNF\n"
packageManager="$(which dnf)"
fi
which apt
if [ $? == 0 ]
then
printf "\tFound APT\n"
packageManager="$(which apt)"
fi
if [ "$packageManager" == "" ]
then
printf "Could not find package manager\n"
fi
}
checkPkgManager
# Depedencies check and install
declare -a depedencies=("curl","wget","bash","jq","node","npm","gpg","git")
for dep in "${depedencies[@]}"
do
printf "Checking for %s..." "$dep"
which $dep
if [ $? -ne 0 ]
then
printf "\t Not found!"
if [ "$packageManager" != "" ]
then
if [ "$packageManager" == "apt" ] && [ "$dep" == "node" ]
then
dep="nodejs"
fi
sudo $packageManager install -y $dep 1> /dev/null 2>&1
if [ $? -ne 0 ]
then
printf "\t Failed to install!\n"
exit 1
fi
printf "\t installed!\n"
else
printf "\t Don't know how to install!\n"
exit 1
fi
else
printf "\t Found!\n"
fi
done
# Work-around for gpg2 calls on distros that don't provide a link
which gpg2
if [ $? -ne 0 ]
then
which gpg
if [ $? == 0 ]
then
sudo ln -s /usr/bin/gpg /usr/bin/gpg2
fi
fi
source ./config.sh
printf "%s" $(pwd) > wam
WHEREAMI="$(cat wam)"
if [ ! -d $AK_WORKDIR ] ; then mkdir $AK_WORKDIR ;fi
if [ ! -d $AK_CONFIGDIR ] ; then mkdir $AK_CONFIGDIR ;fi
if [ ! -d $AK_BINDIR ]; then mkdir $AK_BINDIR ;fi
if [ ! -d $AK_ZBLOCKDIR ]; then mkdir $AK_ZBLOCKDIR ;fi
if [ ! -d $AK_BLOCKDIR ]; then mkdir $AK_BLOCKDIR ;fi
if [ ! -d $AK_DATADIR ]; then mkdir $AK_DATADIR ;fi
if [ ! -d $AK_ARCHIVESDIR ]; then mkdir $AK_ARCHIVESDIR ;fi
if [ ! -f $AK_LOGSFILE ]; then touch $AK_LOGSFILE ;fi
if [ ! -f $AK_GENESIS ]; then touch $AK_GENESIS;fi
if [ ! -d $AK_MINEDBLOCKSDIR ]; then mkdir $AK_MINEDBLOCKSDIR; fi
if [ ! -f $AK_ZBLOCKSFILE ]; then mkdir $AK_ZBLOCKSFILE; fi
if [ ! -f $AK_ZPAIRSFILE ]; then mkdir $AK_ZPAIRSFILE; fi
if [ ! -d $AK_CACHEDIR ]; then mkdir $AK_CACHEDIR; fi
if [ ! -d $AK_GPGHOME ]; then mkdir $AK_GPGHOME && chmod 700 -R $AK_GPGHOME; fi
touch $AK_WORKDIR/logs
logthis(){
echo "Install script: $1" >> $AK_WORKDIR/logs
}
HAK=".arching-kaos"
logthis "Searching for $HAK folder and files"
if [ ! -d $HOME/$HAK ]; then
mkdir $HOME/$HAK
logthis "$HAK created in $HOME";
fi
logthis "Searching for rc"
if [ ! -f $HOME/$HAK/rc ]; then
echo export PATH=$PATH:$HOME/$HAK/bin > $HOME/$HAK/rc
cat config.sh >> $HOME/$HAK/rc
logthis "New rc export to file";
fi
logthis "Searching for shell"
if [ $SHELL == "/usr/bin/zsh" ]; then
SHELLRC=".zshrc"
logthis "ZSH found";
elif [ $SHELL == "/usr/bin/bash" ]; then
SHELLRC='.bashrc'
logthis "BASH found";
else
logthis "Unknown shell... defaulting to bash"
SHELLRC='.bashrc'
fi
logthis "Searching if rc is already there"
grep "source $HOME/$HAK/rc" $HOME/$SHELLRC > /dev/null 2>&1
if [ $? == 0 ]; then
logthis "Already installed";
else
echo "source $HOME/$HAK/rc" >> $HOME/$SHELLRC
logthis "$HAK installed at $HOME and sourced it in $SHELLRC"
source $HOME/$HAK/rc;
fi
sh ipfs-check-install-setup-init-update
source ./config.sh
source $HOME/$SHELLRC
sh init.sh
|