-
Notifications
You must be signed in to change notification settings - Fork 0
/
figWeb.sh
364 lines (236 loc) · 7.73 KB
/
figWeb.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
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
#figNET Web frontend
#Written by: Tristan B. Kildaire (Deavmi) - ([email protected])
#License: GNU GPL v3
#Crowbar Development
function serveFigWeb #Start the figWeb web-server
{
webfsd -i $figWebIP -p $figWebPort -f figWeb/index.html
}
function generateDedicationsPage #Generate the dedications page
{
page="<html>
<head>
<title>Dedications</title>
</head>
<body bgcolor=\"53c69b\"><center><font face=\"Liberation Sans\">
<h1>✞</h1>
<h1>Dedications</h1>
<p>A few words to who I dedicate this software to...</p>
<blockquote>
$dedicationMessage
</bockquote>
</font></center></body>
</html>"
echo "$page" > figWeb/dedications.html
}
function generateServicesListPage #Generate the list of services page
{
while [ 1 = 1 ]
do
page="<html>
<head>
<title>Services | figWeb</title>
</head>
<body><center><font face=\"Liberation Sans\">
<h1>$nodeName</h1>
<h3>Running on figNET v$(getSuiteVersion) <i>\"$(getSuiteRelease)</i>\"</h3>
<hr>
<h2><u>Services</u></h2>
<p>There are $(countServices) services running on this node.</p>
<ol>
$(generateServicesList)
</ol>
</font></center></body>
<br>
<hr>
<br>
<footer><center><font face=\"Liberation Sans\">
<code>Page last generated: $(date)</code>
<br>
<br>
<a href=\"http://$figWebPublicIP:$figWebPublicPort/figWeb/dedications.html\"><code>Built avec <3.</code></a>
<p>fig<b>NET</b> is <a href=\"https://gnu.org/philosophy/free-sw.html\">Free Software</a> and is licensed under the GNU GPL v3. <a href=\"https://github.com/figNET/figNET\">Source Code available</a></p>
<p>This is a project created and maintained by <a href=\"https://deavmi.github.io\">Tristan B. Kildaire (Deavmi)</a>. It is part of Crowbar Developments.</p>
</font></center></footer>
</html>
"
echo "$page" > figWeb/services.html
sleep $figWebServicesRefresh
done
}
function generateNodesListPage #Generate the list of nodes page
{
while [ 1 = 1 ]
do
page="<html>
<head>
<title>Nodes | figWeb</title>
</head>
<body><center><font face=\"Liberation Sans\">
<h1>$nodeName</h1>
<h3>Running on figNET v$(getSuiteVersion) <i>\"$(getSuiteRelease)</i>\"</h3>
<hr>
<h2><u>Nodes</u></h2>
<p>This node is connected to $(getNodesCount) nodes.</p>
<ol>
$(generateNodesList)
</ol>
</font></center></body>
<br>
<hr>
<br>
<footer><center><font face=\"Liberation Sans\">
<code>Page last generated: $(date)</code>
<br>
<br>
<a href=\"http://$figWebPublicIP:$figWebPublicPort/figWeb/dedications.html\"><code>Built avec <3.</code></a>
<p>fig<b>NET</b> is <a href=\"https://gnu.org/philosophy/free-sw.html\">Free Software</a> and is licensed under the GNU GPL v3. <a href=\"https://github.com/figNET/figNET\">Source Code available</a></p>
<p>This is a project created and maintained by <a href=\"https://deavmi.github.io\">Tristan B. Kildaire (Deavmi)</a>. It is part of Crowbar Developments.</p>
</font></center></footer>
</html>
"
echo "$page" > figWeb/nodes.html
sleep $figWebNodesRefresh
done
}
function generateInfoPage #Generate infoPage for a specified service
{
serviceName=$1
serviceFriendlyName=$2
serviceDescription=$3
page="<html>
<head>
<title>Information for $serviceName | figWeb</title>
</head>
<body><center><font face=\"Liberation Sans\">
<h1>$nodeName</h1>
<h3>Running on figNET v$(getSuiteVersion) <i>\"$(getSuiteRelease)</i>\"</h3>
<hr>
<h2><u>Information for service: $serviceName</u></h2>
<p><b>Service name: </b>$serviceName</p>
<p><b>Service friendly name: </b>$serviceFriendlyName</p>
<p><b>Description of service:</b></p>
<code>
$serviceDescription
</code>
</font></center></body>
<br>
<hr>
<br>
<footer><center><font face=\"Liberation Sans\">
<code>Page last generated: $(date)</code>
<br>
<br>
<a href=\"http://$figWebPublicIP:$figWebPublicPort/figWeb/dedications.html\"><code>Built avec <3.</code></a>
<p>fig<b>NET</b> is <a href=\"https://gnu.org/philosophy/free-sw.html\">Free Software</a> and is licensed under the GNU GPL v3. <a href=\"https://github.com/figNET/figNET\">Source Code available</a></p>
<p>This is a project created and maintained by <a href=\"https://deavmi.github.io\">Tristan B. Kildaire (Deavmi)</a>. It is part of Crowbar Developments.</p>
</font></center></footer>
</html>
"
echo "$page" #Return the infoPage's HTML code
}
function generateInfoPageLoop #Generate pages for all services that want it
{
while [ 1 = 1 ]
do
for service in $(getServices)
do
source "data/$service/.info"
if [ $(isInfoPageEnabled "$service") = "true" ] #Generate an infoPage for this service
then
generateInfoPage "$service" "$friendlyName" "$description" > "figWeb/$service.html"
fi
done
sleep $figWebServicesInfoPagesRefresh
done
}
function generateServicesList #Generate a service list item
{
for service in $(getServices)
do
echo "<li><a href=\"http://$figWebPublicIP:$figWebPublicPort/figWeb/$service.html\">$service</a></li>"
done
}
function generateNodesList #Generate a node list item
{
for node in $(getNodes)
do
echo "<li><a href=\"http://$node\">$node</a></li>"
done
}
###BEEEEETAAAAAAAAAAAA
function generateServicesList5 #Generate a service list item (fist 5)
{
count=0
for service in $(getServices)
do
echo "<li><a href=\"http://$figWebPublicIP:$figWebPublicPort/figWeb/$service.html\">$service</a></li>"
count=$(($count+1))
if [ $count = 5 ]
then
break
fi
done
}
function generateNodesList5 #Generate a node list item (first 5)
{
count=0
for node in $(getNodes)
do
echo "<li><a href=\"http://$node\">$node</a></li>"
count=$(($count+1))
if [ $count = 5 ]
then
break
fi
done
}
###END BETTTTATATTATATATATA
function generateHomeLoop #Generate index.html file
{
while [ 1 = 1 ]
do
page="<html>
<head>
<meta charset="utf-8">
<title>$nodeName | figWeb</title>
</head>
<body><center><font face=\"Liberation Sans\">
<h1>$nodeName</h1>
<h3>Running on figNET v$(getSuiteVersion) <i>\"$(getSuiteRelease)\"</i></h3>
<hr>
<a href=\"figWeb/services.html\"><h2><u>Services</u></h2></a>
<p>There are $(countServices) services running on this node.</p>
<ol>
$(generateServicesList5)
</ol>
<a href=\"figWeb/nodes.html\"><h2><u>Nodes</u></h2></a>
<p>This node is connected to $(getNodesCount) nodes.</p>
<ol>
$(generateNodesList5)
</ol>
<h2><u>Node information</u></h2>
<p><b>Node name: </b>$nodeName</p>
<p><b>Node Sync Server: </b><a href=\"http://$publicIP:$publicPort\">$publicIP:$publicPort</a></p>
<p><b>Node hostname: </b>$HOSTNAME</p>
<p><b>Node OS: </b>$(uname --operating-system)</p>
<p><b>Node location: </b>$nodeLocation</p>
<p><b>SysOp: </b>$nodeOperator</p>
<p><b>SysOp email address: </b><a href=\"mailto:$nodeOperatorMail\">$nodeOperatorMail</a></p>
</font></center></body>
<br>
<hr>
<br>
<footer><center><font face=\"Liberation Sans\">
<code>Page last generated: $(date)</code>
<br>
<br>
<a href=\"figWeb/dedications.html\"><code>Built avec <3.</code></a>
<p>fig<b>NET</b> is <a href=\"https://gnu.org/philosophy/free-sw.html\">Free Software</a> and is licensed under the GNU GPL v3. <a href=\"https://github.com/figNET/figNET\">Source Code available</a></p>
<p>This is a project created and maintained by <a href=\"https://deavmi.github.io\">Tristan B. Kildaire (Deavmi)</a>. It is part of Crowbar Developments.</p>
</font></center></footer>
</html>"
echo "$page" > figWeb/index.html
sleep $figWebHomeRefresh #Wait gievn amount of seconds before re-generating a fresh figWeb `index.html` file (in infoPage/index.html)
done
}