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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
#!/usr/local/bin/bash
if [ "$#" -eq 0 ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]
then
/bin/echo "Usage:"
/bin/echo " ntcoin <path (no slash)> <bin path (no slash)> <n> <host name>: to create the tcoin directory in <path (no slash)> with the executable saved to <bin path (no slash)> and with <n> basecoins per user with the help showing the host name <host name>"
/bin/echo " ntcoin <path (no slash)> <bin path (no slash)> <host name> --def | -d: to print only the #define preprocessor directives without creating any directories"
/bin/echo " ntcoin [ --help | -h ] : to print this help"
elif [ "$4" = "--def" ] || [ "$4" = "-d" ]
then
/bin/echo "Printing tcoin.cpp (and pcoin.cpp) preprocessor directives."
/bin/echo 'Paste the following in '`/bin/realpath -q $1`'/tcoin/bin/tcoin_defs.cpp (and '`/bin/realpath -q $1`'/tcoin/bin/pcoin_defs.cpp):
'
/bin/echo '#define TCOIN_PATH "'`/bin/realpath -q $1`'/tcoin"
#define TCOIN_MSG_PATH "'`/bin/realpath -q $1`'/tcoin/messages/"
#define TCOIN_SALT_PATH "'`/bin/realpath -q $1`'/tcoin/salts/"
#define TCOIN_PASS_PATH "'`/bin/realpath -q $1`'/tcoin/passwords/"
#define TCOIN_PROG_ACT_PATH "'`/bin/realpath -q $1`'/tcoin/program_accounting/"
#define PROG_ACT_W_SLASH "program_accounting/"
#define LS_PATH "/bin/ls"
#define PCOIN_NEW_KEY_CMD "/bin/cat /dev/urandom | /usr/bin/b64encode -r . | /usr/bin/head -c 64 | /usr/bin/tr '+' '-' | /usr/bin/tr '/' '_'"
#define PIPED_WORD_COUNT_CMD " | /usr/bin/wc -c"
#define PCOIN_KEY_PATH "'`/bin/realpath -q $1`'/tcoin/secrets/pcoin_keys"
#define PCOIN_KEY_PATH_W_SLASH "'`/bin/realpath -q $1`'/tcoin/secrets/pcoin_keys/"
#define TCOIN_CODEZ_PATH "'`/bin/realpath -q $1`'/tcoin/secrets/tcoin_codez"
#define TCOIN_BIN_PATH_W_SPACE "'`/bin/realpath -q $2`'/tcoin "
#define TCOIN_PATH_W_SLASH "'`/bin/realpath -q $1`'/tcoin/"
#define TCOIN_SCRYPT_PATH "'`/bin/realpath -q $1`'/tcoin/bin/scrypt"
#define PCOIN_BIN_PATH "'`/bin/realpath -q $2`'/pcoin"
#define PCOIN_BIN_PATH_W_SPACE "'`/bin/realpath -q $2`'/pcoin "
#define TCOIN_HOST_NAME "'$3'"
#define TCOIN_ERR_CONTACT_EMAIL "login@tilde.town (town-only) or login@tilde.team (internet-wide)" )
#define TCOIN_PASS_RESET_CONTACT_EMAIL "`login@tilde.town` (tilde.town local email) or `login@tilde.team` (internet-wide email), or `/query login` on IRC"
#define KROWBAR_OFF
#define DA_OFF
#define MINERCOIN_OFF
#define TILDEGURU'
else
#see https://stackoverflow.com/a/3951175
case $3 in
''|*[!0-9]*) /bin/echo "Sorry, the number of basecoins <n> should be a positive integer."; exit 1 ;;
*) ;;
esac
if [ "$#" -ne 4 ]
then
/bin/echo "Sorry, the number of arguments must be exactly 4."
exit 1
fi
if [ -d "`/bin/realpath -q $1`/tcoin" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin' already exists."
exit 1
else
/bin/mkdir "`/bin/realpath -q $1`/tcoin"
/bin/chmod 700 "`/bin/realpath -q $1`/tcoin"
/bin/chmod u+s "`/bin/realpath -q $1`/tcoin"
fi
if [ -d "`/bin/realpath -q $1`/tcoin/salts" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/salts' already exists."
exit 1
else
/bin/mkdir "`/bin/realpath -q $1`/tcoin/salts"
/bin/chmod 700 "`/bin/realpath -q $1`/tcoin/salts"
/bin/chmod u+s "`/bin/realpath -q $1`/tcoin/salts"
fi
if [ -d "`/bin/realpath -q $1`/tcoin/passwords" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/passwords' already exists."
exit 1
else
/bin/mkdir "`/bin/realpath -q $1`/tcoin/passwords"
/bin/chmod 700 "`/bin/realpath -q $1`/tcoin/passwords"
/bin/chmod u+s "`/bin/realpath -q $1`/tcoin/passwords"
fi
if [ -d "`/bin/realpath -q $1`/tcoin/program_accounting" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/program_accounting' already exists."
exit 1
else
/bin/mkdir "`/bin/realpath -q $1`/tcoin/program_accounting"
/bin/chmod 700 "`/bin/realpath -q $1`/tcoin/program_accounting"
/bin/chmod u+s "`/bin/realpath -q $1`/tcoin/program_accounting"
fi
if [ -d "`/bin/realpath -q $1`/tcoin/messages" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/messages' already exists."
exit 1
else
/bin/mkdir "`/bin/realpath -q $1`/tcoin/messages"
/bin/chmod 700 "`/bin/realpath -q $1`/tcoin/messages"
/bin/chmod u+s "`/bin/realpath -q $1`/tcoin/messages"
fi
if [ -d "`/bin/realpath -q $1`/tcoin/base" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/base' already exists."
exit 1
else
/bin/mkdir "`/bin/realpath -q $1`/tcoin/base"
/bin/chmod 700 "`/bin/realpath -q $1`/tcoin/base"
/bin/chmod u+s "`/bin/realpath -q $1`/tcoin/base"
if [ -e "`/bin/realpath -q $1`/tcoin/base/base.txt" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/base/base.txt' already exists."
exit 1
else
/bin/echo "$3""00" > "`/bin/realpath -q $1`/tcoin/base/base.txt"
/bin/chmod 600 "`/bin/realpath -q $1`/tcoin/base/base.txt"
fi
fi
if [ -d "`/bin/realpath -q $1`/tcoin/secrets" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/secrets' already exists."
exit 1
else
/bin/mkdir "`/bin/realpath -q $1`/tcoin/secrets"
/bin/chmod 700 "`/bin/realpath -q $1`/tcoin/secrets"
/bin/chmod u+s "`/bin/realpath -q $1`/tcoin/secrets"
if [ -d "`/bin/realpath -q $1`/tcoin/secrets/pcoin_keys" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/secrets/pcoin_keys' already exists."
exit 1
else
/bin/mkdir "`/bin/realpath -q $1`/tcoin/secrets/pcoin_keys"
/bin/chmod 700 "`/bin/realpath -q $1`/tcoin/secrets/pcoin_keys"
/bin/chmod u+s "`/bin/realpath -q $1`/tcoin/secrets/pcoin_keys"
fi
if [ -e "`/bin/realpath -q $1`/tcoin/secrets/tcoin_codez" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/secrets/tcoin_codez' already exists."
exit 1
else
/bin/echo "`cat /dev/urandom | b64encode -r . | head -c 512 | tr -d '\n' | tr '+' '-' | tr '/' '_'` `cat /dev/urandom | b64encode -r . | head -c 512 | tr -d '\n' | tr '+' '-' | tr '/' '_'` `cat /dev/urandom | b64encode -r . | head -c 512 | tr -d '\n' | tr '+' '-' | tr '/' '_'`" > "`/bin/realpath -q $1`/tcoin/secrets/tcoin_codez"
/bin/chmod 400 "`/bin/realpath -q $1`/tcoin/secrets/tcoin_codez"
fi
fi
if [ -d "`/bin/realpath -q $1`/tcoin/bin" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/bin' already exists."
exit 1
else
/bin/mkdir "`/bin/realpath -q $1`/tcoin/bin"
/bin/chmod 700 "`/bin/realpath -q $1`/tcoin/bin"
/bin/chmod u+s "`/bin/realpath -q $1`/tcoin/bin"
if [ -e "`/bin/realpath -q $1`/tcoin/bin/scrypt" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/bin/scrypt' already exists."
exit 1
else
/bin/cp ./scrypt_freebsd "`/bin/realpath -q $1`/tcoin/bin/scrypt"
/bin/chmod 500 "`/bin/realpath -q $1`/tcoin/bin/scrypt"
fi
if [ -e "`/bin/realpath -q $1`/tcoin/bin/popen2.c" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/bin/popen2.c' already exists."
exit 1
else
/bin/cp ./popen2.c "`/bin/realpath -q $1`/tcoin/bin/popen2.c"
/bin/chmod 440 "`/bin/realpath -q $1`/tcoin/bin/popen2.c"
fi
if [ -e "`/bin/realpath -q $1`/tcoin/bin/popen2.h" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/bin/popen2.h' already exists."
exit 1
else
/bin/cp ./popen2.h "`/bin/realpath -q $1`/tcoin/bin/popen2.h"
/bin/chmod 440 "`/bin/realpath -q $1`/tcoin/bin/popen2.h"
fi
if [ -e "`/bin/realpath -q $1`/tcoin/bin/tcoin_defs.cpp" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/bin/tcoin_defs.cpp' already exists."
exit 1
else
/bin/echo '#define TCOIN_PATH "'`/bin/realpath -q $1`'/tcoin"
#define TCOIN_MSG_PATH "'`/bin/realpath -q $1`'/tcoin/messages/"
#define TCOIN_SALT_PATH "'`/bin/realpath -q $1`'/tcoin/salts/"
#define TCOIN_PASS_PATH "'`/bin/realpath -q $1`'/tcoin/passwords/"
#define TCOIN_PROG_ACT_PATH "'`/bin/realpath -q $1`'/tcoin/program_accounting/"
#define PROG_ACT_W_SLASH "program_accounting/"
#define LS_PATH "/bin/ls"
#define PIPED_WORD_COUNT_CMD " | /usr/bin/wc -c"
#define PCOIN_KEY_PATH "'`/bin/realpath -q $1`'/tcoin/secrets/pcoin_keys"
#define PCOIN_KEY_PATH_W_SLASH "'`/bin/realpath -q $1`'/tcoin/secrets/pcoin_keys/"
#define TCOIN_CODEZ_PATH "'`/bin/realpath -q $1`'/tcoin/secrets/tcoin_codez"
#define TCOIN_BIN_PATH_W_SPACE "'`/bin/realpath -q $2`'/tcoin "
#define TCOIN_PATH_W_SLASH "'`/bin/realpath -q $1`'/tcoin/"
#define TCOIN_SCRYPT_PATH "'`/bin/realpath -q $1`'/tcoin/bin/scrypt"
#define TCOIN_HOST_NAME "'$4'"
#define TCOIN_ERR_CONTACT_EMAIL "login@tilde.town (town-only) or login@tilde.team (internet-wide)" )
#define TCOIN_PASS_RESET_CONTACT_EMAIL "`login@tilde.town` (tilde.town local email) or `login@tilde.team` (internet-wide email), or `/query login` on IRC"
#define KROWBAR_OFF
#define DA_OFF
#define MINERCOIN_OFF
#define TILDEGURU' > "`/bin/realpath -q $1`/tcoin/bin/tcoin_defs.cpp"
/bin/chmod 640 "`/bin/realpath -q $1`/tcoin/bin/tcoin_defs.cpp"
fi
if [ -e "`/bin/realpath -q $1`/tcoin/bin/pcoin_defs.cpp" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/bin/pcoin_defs.cpp' already exists."
exit 1
else
/bin/echo '#define TCOIN_PATH "'`/bin/realpath -q $1`'/tcoin"
#define TCOIN_MSG_PATH "'`/bin/realpath -q $1`'/tcoin/messages/"
#define TCOIN_SALT_PATH "'`/bin/realpath -q $1`'/tcoin/salts/"
#define TCOIN_PASS_PATH "'`/bin/realpath -q $1`'/tcoin/passwords/"
#define TCOIN_PROG_ACT_PATH "'`/bin/realpath -q $1`'/tcoin/program_accounting/"
#define PROG_ACT_W_SLASH "program_accounting/"
#define LS_PATH "/bin/ls"
#define PCOIN_NEW_KEY_CMD "/bin/cat /dev/urandom | /usr/bin/b64encode -r . | /usr/bin/head -c 64 | /usr/bin/tr '+' '-' | /usr/bin/tr '/' '_'"
#define PIPED_WORD_COUNT_CMD " | /usr/bin/wc -c"
#define PCOIN_KEY_PATH "'`/bin/realpath -q $1`'/tcoin/secrets/pcoin_keys"
#define PCOIN_KEY_PATH_W_SLASH "'`/bin/realpath -q $1`'/tcoin/secrets/pcoin_keys/"
#define TCOIN_CODEZ_PATH "'`/bin/realpath -q $1`'/tcoin/secrets/tcoin_codez"
#define TCOIN_PATH_W_SLASH "'`/bin/realpath -q $1`'/tcoin/"
#define TCOIN_SCRYPT_PATH "'`/bin/realpath -q $1`'/tcoin/bin/scrypt"
#define PCOIN_BIN_PATH "'`/bin/realpath -q $2`'/pcoin"
#define TCOIN_BIN_PATH_W_SPACE "'`/bin/realpath -q $2`'/tcoin "
#define PCOIN_BIN_PATH_W_SPACE "'`/bin/realpath -q $2`'/pcoin "
#define TCOIN_ERR_CONTACT_EMAIL "login@tilde.town (town-only) or login@tilde.team (internet-wide)" )
#define TCOIN_PASS_RESET_CONTACT_EMAIL "`login@tilde.town` (tilde.town local email) or `login@tilde.team` (internet-wide email), or `/query login` on IRC"
#define KROWBAR_OFF
#define DA_OFF
#define MINERCOIN_OFF
#define TILDEGURU' > "`/bin/realpath -q $1`/tcoin/bin/pcoin_defs.cpp"
/bin/chmod 640 "`/bin/realpath -q $1`/tcoin/bin/pcoin_defs.cpp"
fi
if [ -e "`/bin/realpath -q $1`/tcoin/bin/tcoin" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/bin/tcoin' already exists."
exit 1
else
/bin/echo '#!/usr/local/bin/bash
(/usr/local/bin/g++ -I"'`/bin/realpath -q $1`'/tcoin/bin" "'`/bin/pwd`'/tcoin.cpp" "'`/bin/realpath -q $1`'/tcoin/bin/popen2.c" -o "'`/bin/realpath -q $1`'/tcoin/bin/tcoin" -std=c++11) \
&& (/bin/chmod 550 "'`/bin/realpath -q $1`'/tcoin/bin/tcoin") \
&& (/bin/chmod u+s "'`/bin/realpath -q $1`'/tcoin/bin/tcoin") \
&& (([ -f "'`/bin/realpath -q $2`'/tcoin" ] && (/bin/chmod u+w "'`/bin/realpath -q $2`'/tcoin")) || /usr/bin/true) \
&& (/bin/cp "'`/bin/realpath -q $1`'/tcoin/bin/tcoin" "'`/bin/realpath -q $2`'/tcoin") \
&& (/usr/bin/chgrp tilde "'`/bin/realpath -q $2`'/tcoin") \
&& (/bin/chmod 550 "'`/bin/realpath -q $2`'/tcoin") \
&& (/bin/chmod u+s "'`/bin/realpath -q $2`'/tcoin") \
&& (/bin/cp "'`/bin/realpath -q $1`'/tcoin/bin/tcoin_defs.cpp" "'`/bin/realpath -q $2`'/tcoin_defs.cpp")' > "`/bin/realpath -q $1`/tcoin/bin/compile_tcoin"
/bin/chmod 540 "`/bin/realpath -q $1`/tcoin/bin/compile_tcoin"
/bin/echo '#!/usr/local/bin/bash
'\$EDITOR' "'`/bin/pwd`'/tcoin.cpp"' > "`/bin/realpath -q $1`/tcoin/bin/edit_tcoin"
/bin/chmod 540 "`/bin/realpath -q $1`/tcoin/bin/edit_tcoin"
/usr/local/bin/bash "`/bin/realpath -q $1`/tcoin/bin/compile_tcoin"
/bin/ln -s "`/bin/realpath -q $1`/tcoin/bin/compile_tcoin" ~/"bin/compile_tcoin"
/bin/ln -s "`/bin/realpath -q $1`/tcoin/bin/edit_tcoin" ~/"bin/edit_tcoin"
fi
if [ -e "`/bin/realpath -q $1`/tcoin/bin/pcoin" ]
then
/bin/echo "Sorry, '`/bin/realpath -q $1`/tcoin/bin/pcoin' already exists."
exit 1
else
/bin/echo '#!/usr/local/bin/bash
(/usr/local/bin/g++ -I"'`/bin/realpath -q $1`'/tcoin/bin" "'`/bin/pwd`'/pcoin.cpp" "'`/bin/realpath -q $1`'/tcoin/bin/popen2.c" -o "'`/bin/realpath -q $1`'/tcoin/bin/pcoin" -std=c++11) \
&& (/bin/chmod 550 "'`/bin/realpath -q $1`'/tcoin/bin/pcoin") \
&& (/bin/chmod u+s "'`/bin/realpath -q $1`'/tcoin/bin/pcoin") \
&& (([ -f "'`/bin/realpath -q $2`'/pcoin" ] && (/bin/chmod u+w "'`/bin/realpath -q $2`'/pcoin")) || /usr/bin/true) \
&& (/bin/cp "'`/bin/realpath -q $1`'/tcoin/bin/pcoin" "'`/bin/realpath -q $2`'/pcoin") \
&& (/usr/bin/chgrp tilde "'`/bin/realpath -q $2`'/pcoin") \
&& (/bin/chmod 550 "'`/bin/realpath -q $2`'/pcoin") \
&& (/bin/chmod u+s "'`/bin/realpath -q $2`'/pcoin") \
&& (/bin/cp "'`/bin/realpath -q $1`'/tcoin/bin/pcoin_defs.cpp" "'`/bin/realpath -q $2`'/pcoin_defs.cpp")' > "`/bin/realpath -q $1`/tcoin/bin/compile_pcoin"
/bin/chmod 540 "`/bin/realpath -q $1`/tcoin/bin/compile_pcoin"
/bin/echo '#!/usr/local/bin/bash
'\$EDITOR' "'`/bin/pwd`'/pcoin.cpp"' > "`/bin/realpath -q $1`/tcoin/bin/edit_pcoin"
/bin/chmod 540 "`/bin/realpath -q $1`/tcoin/bin/edit_pcoin"
/usr/local/bin/bash "`/bin/realpath -q $1`/tcoin/bin/compile_pcoin"
/bin/ln -s "`/bin/realpath -q $1`/tcoin/bin/compile_pcoin" ~/"bin/compile_pcoin"
/bin/ln -s "`/bin/realpath -q $1`/tcoin/bin/edit_pcoin" ~/"bin/edit_pcoin"
fi
/bin/echo '#!/usr/local/bin/bash
'\$EDITOR' "'`/bin/pwd`'/pcoin.cpp" "'`/bin/pwd`'/tcoin.cpp"' > "`/bin/realpath -q $1`/tcoin/bin/edit_ptcoin"
/bin/chmod 540 "`/bin/realpath -q $1`/tcoin/bin/edit_ptcoin"
/bin/ln -s "`/bin/realpath -q $1`/tcoin/bin/edit_ptcoin" ~/"bin/edit_ptcoin"
fi
fi
|