source: trunk/push-web @ 349

Last change on this file since 349 was 349, checked in by g7moreau, 6 years ago
  • validate w3c html. Move tfoot, remove attribute summary for table and add doctype and title to the page...
  • Property svn:executable set to *
File size: 5.8 KB
Line 
1#!/bin/bash
2#
3# 2007/10/23 gabriel
4# 2010/11/03 gabriel
5# 2011/03/30 gabriel - make it generic
6
7export PATH=/bin:/sbin:/usr/bin:/usr/sbin
8export LANG=C
9
10SITE_NAME=''
11REMOTE_SERVER=localhost
12REMOTE_USER=''
13REMOTE_FOLDER=/var/www/klask/
14
15GRAPH_MODULO=9
16GRAPH_SHIFT=1
17
18if [ -f /etc/klask/push-web.conf ]
19then
20   . /etc/klask/push-web.conf
21fi
22
23TMP='/tmp/klask-push-web'
24
25
26# remote command
27DOT=/usr/bin/dot
28
29
30mkdir -p ${TMP}
31if [ ! -d ${TMP} ]
32then
33   echo "Error: Folder ${TMP} do not exist !"
34   exit 1
35fi
36cd ${TMP}
37
38
39LOCALTIME=$(date "+%Y-%m-%d %H:%M")
40
41
42klask exportsw --format dot --modulo ${GRAPH_MODULO} --shift ${GRAPH_SHIFT} > ${TMP}/switch-map.txt
43
44
45klask exportdb    > ${TMP}/hostname-db.txt
46klask exportsw    > ${TMP}/switch-db.txt
47klask ip-free     > ${TMP}/ipfree-db.txt
48klask bad-vlan-id > ${TMP}/badvlan-db.txt
49
50
51cat <<END > ${TMP}/index.html
52<!DOCTYPE html>
53<html>
54<head>
55 <link rel="stylesheet" type="text/css" href="style-klask.css" />
56 <meta http-equiv="refresh" content="1800">
57 <title>Klask mapping net-tools</title>
58 <noscript>
59 </noscript>
60 <script src="sorttable-klask.js"></script>
61 <script>
62function delayedRefresh() {
63 setTimeout( "refresh()", 1800*1000 );
64 }
65
66function refresh() {
67 history.go(0);
68 }
69 </script>
70</head>
71<body onload="delayedRefresh">
72<h1>
73<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask" class="circle">Klask</a></b>
74Tool for <a href="switch-map.png">mapping</a> (<a href="switch-map.png">png</a>|<a href="switch-map.svg">svg</a>)
75the local network [${LOCALTIME}] - site ${SITE_NAME}
76</h1>
77
78<div id="navbar">
79 <ul>
80  <li id="selected"><a href="index.html">IP detected</a></li>
81  <li><a href="ip-free.html">IP available</a></li>
82  <li><a href="bad-vlan-id.html">VLAN mismatch</a></li>
83 </ul>
84</div>
85
86<div id="content">
87<p>
88The main raw results of Klask are accessible directly, via wget or curl for example, for a specific treatment:
89<a href="hostname-db.txt">Computers DB</a>,
90<a href="switch-db.txt">Switches DB</a>,
91<a href="ipfree-db.txt">IP available</a>,
92<a href="badvlan-db.txt">VLAN mismatch</a>,
93<a href="switch-map.txt">Map dot source</a>.
94</p>
95END
96
97klask exportdb --format html >> ${TMP}/index.html
98
99cat <<END >> ${TMP}/index.html
100</div>
101<p class="copyright">
102Klask (version $(klask version | grep ^Version | cut -f 2 -d ' ')) - $(klask version | grep ^Copyright | cut -f 1 -d '<')
103</p>
104</body>
105</html>
106END
107
108
109cat <<END > ${TMP}/ip-free.html
110<html>
111<head>
112 <link rel="stylesheet" type="text/css" href="style-klask.css" />
113 <meta http-equiv="refresh" content="1800">
114 <script src="sorttable-klask.js"></script>
115</head>
116<body>
117<h1>
118<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask" class="circle">Klask</a></b>
119Tool for <a href="switch-map.png">mapping</a> (<a href="switch-map.png">png</a>|<a href="switch-map.svg">svg</a>)
120the local network [${LOCALTIME}] - site ${SITE_NAME}
121</h1>
122
123<div id="navbar">
124 <ul>
125  <li><a href="index.html">IP detected</a></li>
126  <li id="selected"><a href="ip-free.html">IP available</a></li>
127  <li><a href="bad-vlan-id.html">VLAN mismatch</a></li>
128 </ul>
129</div>
130
131<div id="content">
132<p>
133The main raw results of Klask are accessible directly, via wget or curl for example, for a specific treatment:
134<a href="hostname-db.txt">Computers DB</a>,
135<a href="switch-db.txt">Switches DB</a>,
136<a href="ipfree-db.txt">IP available</a>,
137<a href="bad-vlan-id-db.txt">VLAN mismatch</a>,
138<a href="switch-map.txt">Map dot source</a>.
139</p>
140END
141
142klask ip-free --format html >> ${TMP}/ip-free.html
143
144cat <<END >> ${TMP}/ip-free.html
145</div>
146<p class="copyright">
147Klask (version $(klask version | grep ^Version | cut -f 2 -d ' ')) - $(klask version | grep ^Copyright | cut -f 1 -d '<')
148</p>
149</body>
150</html>
151END
152
153
154cat <<END > ${TMP}/bad-vlan-id.html
155<html>
156<head>
157 <link rel="stylesheet" type="text/css" href="style-klask.css" />
158 <meta http-equiv="refresh" content="1800">
159 <script src="sorttable-klask.js"></script>
160</head>
161<body>
162<h1>
163<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask" class="circle">Klask</a></b>
164Tool for <a href="switch-map.png">mapping</a> (<a href="switch-map.png">png</a>|<a href="switch-map.svg">svg</a>)
165the local network [${LOCALTIME}] - site ${SITE_NAME}
166</h1>
167
168<div id="navbar">
169 <ul>
170  <li><a href="index.html">IP detected</a></li>
171  <li><a href="ip-free.html">IP available</a></li>
172  <li id="selected"><a href="bad-vlan-id.html">VLAN mismatch</a></li>
173 </ul>
174</div>
175
176<div id="content">
177<p>
178The main raw results of Klask are accessible directly, via wget or curl for example, for a specific treatment:
179<a href="hostname-db.txt">Computers DB</a>,
180<a href="switch-db.txt">Switches DB</a>,
181<a href="ipfree-db.txt">IP available</a>,
182<a href="bad-vlan-id-db.txt">VLAN mismatch</a>,
183<a href="switch-map.txt">Map dot source</a>.
184</p>
185END
186
187klask bad-vlan-id --format html >> ${TMP}/bad-vlan-id.html
188
189cat <<END >> ${TMP}/bad-vlan-id.html
190</div>
191<p class="copyright">
192Klask (version $(klask version | grep ^Version | cut -f 2 -d ' ')) - $(klask version | grep ^Copyright | cut -f 1 -d '<')
193</p>
194</body>
195</html>
196END
197
198
199if [ "${REMOTE_SERVER}" = "localhost" ]
200then
201   rsync \
202      /usr/share/klask/sorttable-klask.js \
203      /usr/share/klask/style-klask.css \
204      ${TMP}/index.html \
205      ${TMP}/ip-free.html \
206      ${TMP}/bad-vlan-id.html \
207      ${TMP}/*-db.txt \
208      ${TMP}/switch-map.txt \
209      ${REMOTE_FOLDER}/
210
211   [ -x ${DOT} ] && (cd ${REMOTE_FOLDER}; ${DOT} -T svg switch-map.txt > switch-map.svg; ${DOT} -T png switch-map.txt > switch-map.png)
212
213else
214   rsync \
215      /usr/share/klask/sorttable-klask.js \
216      /usr/share/klask/style-klask.css \
217      ${TMP}/index.html \
218      ${TMP}/ip-free.html \
219      ${TMP}/bad-vlan-id.html \
220      ${TMP}/*-db.txt \
221      ${TMP}/switch-map.txt \
222      ${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_FOLDER}/
223
224
225   ssh ${REMOTE_USER}@${REMOTE_SERVER} "(cd ${REMOTE_FOLDER}; ${DOT} -T svg switch-map.txt > switch-map.svg; ${DOT} -T png switch-map.txt > switch-map.png)"
226fi
Note: See TracBrowser for help on using the repository browser.