blob: b96d674dd59f640d4b76cb833b462db253c73e6c (
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
|
#!/bin/bash
set -x
source lib/_ak_ipfs
# TODO GPG/PGP setup:: possibly done
# eg gpg2 --full-key-generate and/or gpg2 --set-default key
# or just question the user if they are going to use their
# existing one if any.
ak_gpg_check_or_create(){
gpg2 --homedir $AK_GPGHOME --list-keys | grep kaos@kaos.kaos -B 1
if [ $? -ne 0 ]
then
gpg2 --homedir $AK_GPGHOME --batch --passphrase '' --quick-gen-key kaos@kaos.kaos rsa3072 sign 0
AK_FINGERPRINT="$(gpg2 --homedir $AK_GPGHOME --list-keys | grep kaos@kaos.kaos -B 1 | head -n 1 | awk '{print $1}')"
printf '%s' "$AK_FINGERPRINT" > $AK_WORKDIR/current_key
gpg2 --homedir $AK_GPGHOME --batch --passphrase '' --quick-add-key $AK_FINGERPRINT rsa3072 encrypt 0
fi
}
ipfs_zarchive_check_or_mkdir(){
printf "Checking for /zarchive in IPFS FS..."
_ak_ipfs files ls /zarchive > /dev/null 2>&1
if [ $? -ne 0 ]; then
_ak_ipfs files mkdir /zarchive > /dev/null 2>&1
if [ $? -ne 0 ]; then
printf "\tError!\n"
exit 1
else
printf "\tCreated!\n"
fi
else
printf "\tFound\n"
fi
}
ipfs_zlatest_check_or_create(){
printf "Looking for /zlatest..."
_ak_ipfs files stat /zlatest > /dev/null 2>&1
if [ $? -ne 0 ]; then
_ak_ipfs files cp /ipfs/$(cat $AK_ZGENESIS) /zlatest
if [ $? -ne 0 ]; then
printf "\tProblem copying %s to /zlatest!\n" "$AK_ZGENESIS"
exit 1
else
printf "\tSuccess!\n"
fi
else
printf "\tFound!\n"
fi
}
printf "Initialization started... \n"
ak_gpg_check_or_create
if [ -f $AK_ZGENESIS ] ; then printf "%s" "$(_ak_ipfs add -q $AK_GENESIS)" > $AK_ZGENESIS;fi
if [ ! -f $AK_ZCHAIN ]
then
_ak_ipfs key list | grep zchain
if [ $? -ne 0 ]
then
printf "%s" "$(_ak_ipfs key gen zchain)" > $AK_ZCHAIN
else
printf "%s" "$(_ak_ipfs key list -l | grep zchain | awk '{ print $1 }')" > $AK_ZCHAIN
fi
fi
if [ ! -f $AK_ZLATEST ] ; then cp $AK_ZGENESIS $AK_ZLATEST;fi
if [ ! -f $AK_ZCHAINASC ] ; then gpg2 --homedir $AK_GPGHOME -bao $AK_ZCHAINASC $AK_ZCHAIN;fi
if [ ! -f $AK_ZZCHAIN ] ; then printf "%s" "$(_ak_ipfs add -q $AK_ZCHAINASC)" > $AK_ZZCHAIN;fi
if [ ! -f $AK_GENESISASC ] ; then gpg2 --homedir $AK_GPGHOME -bao $AK_GENESISASC $AK_GENESIS;fi
if [ ! -f $AK_ZGENESISASC ] ; then printf "%s" "$(_ak_ipfs add -q $AK_GENESISASC)" > $AK_ZGENESISASC;fi
if [ ! -f $AK_ZBLOCKSFILE ] ; then printf "[]" > $AK_ZBLOCKSFILE;fi
if [ ! -f $AK_ZPAIRSFILE ] ; then printf "[]" > $AK_ZPAIRSFILE;fi
if [ ! -f $AK_ZPEERSFILE ] ; then printf "[]" > $AK_ZPEERSFILE;fi
ipfs_zarchive_check_or_mkdir
ipfs_zlatest_check_or_create
# Find scripts and create symlinks
binfiles=$(ls -1 $(pwd)/bin)
for b in $binfiles
do
if [ ! -L $AK_BINDIR/$b ]
then
printf "Creating symlink to %s..." "$b"
ln -s $(pwd)/bin/$b $AK_BINDIR/$b
if [ $? -ne 0 ]
then
if [ -L $AK_BINDIR/$b ]
then
printf "\tAlready exists!\n"
exit 1
fi
printf "\tFailed!\n"
exit 1
fi
printf "\tOK!\n"
fi
done
# Find libs and create symlinks
libfiles=$(ls -1 $(pwd)/lib)
for b in $libfiles
do
if [ ! -L $AK_LIBDIR/$b ]
then
printf "Creating symlink to %s..." "$b"
ln -s $(pwd)/lib/$b $AK_LIBDIR/$b
if [ $? -ne 0 ]
then
if [ -L $AK_LIBDIR/$b ]
then
printf "\tAlready exists!\n"
exit 1
fi
printf "\tFailed!\n"
exit 1
fi
printf "\tOK!\n"
fi
done
# Find modules and create symlinks
modfiles=$(ls -1 $(pwd)/modules)
for m in $modfiles
do
if [ ! -L $AK_MODULESDIR/$m ]
then
printf "Creating symlink to %s..." "$m"
ln -s $(pwd)/modules/$b $AK_MODULESDIR/$m
if [ $? -ne 0 ]
then
if [ -L $AK_MODULESDIR/$m ]
then
printf "\tAlready exists!\n"
exit 1
fi
printf "\tFailed!\n"
exit 1
fi
printf "\tOK!\n"
fi
done
|