source: trunk/push-web @ 330

Last change on this file since 330 was 330, checked in by g7moreau, 6 years ago
  • Better doc and link
  • Property svn:executable set to *
File size: 5.3 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
7SITE_NAME=''
8REMOTE_SERVER=localhost
9REMOTE_USER=''
10REMOTE_FOLDER=/var/www/klask/
11
12GRAPH_MODULO=9
13GRAPH_SHIFT=1
14
15if [ -f /etc/klask/push-web.conf ]
16then
17   . /etc/klask/push-web.conf
18fi
19
20TMP='/tmp/klask-push-web'
21
22
23# local command
24MKDIR=/bin/mkdir
25DATE=/bin/date
26CAT=/bin/cat
27TAIL=/usr/bin/tail
28HEAD=/usr/bin/head
29SSH=/usr/bin/ssh
30SCP=/usr/bin/scp
31KLASK=/usr/sbin/klask
32RSYNC=/usr/bin/rsync
33
34# remote command
35DOT=/usr/bin/dot
36
37
38$MKDIR -p ${TMP}
39if [ ! -d ${TMP} ]
40then
41   echo "Error: Folder ${TMP} do not exist !"
42   exit 1
43fi
44cd ${TMP}
45
46
47LOCALTIME=$($DATE "+%Y-%m-%d %H:%M")
48
49
50$KLASK exportsw --format dot --modulo ${GRAPH_MODULO} --shift ${GRAPH_SHIFT} > ${TMP}/switch-map.txt
51
52
53$KLASK exportdb > ${TMP}/hostname-db.txt
54$KLASK exportsw > ${TMP}/switch-db.txt
55$KLASK ip-free  > ${TMP}/ipfree-db.txt
56
57
58$CAT <<END > ${TMP}/index.html
59<html>
60<head>
61 <link rel="stylesheet" type="text/css" href="style-klask.css" />
62 <meta http-equiv="refresh" content="1800">
63 <noscript>
64 </noscript>
65 <script src="sorttable-klask.js"></script>
66 <script>
67function delayedRefresh() {
68 setTimeout( "refresh()", 1800*1000 );
69 }
70
71function refresh() {
72 history.go(0);
73 }
74 </script>
75</head>
76<body onload="delayedRefresh">
77<h1>
78<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask">Klask</a></b>
79- Un outil pour <a href="switch-map.png">cartographier</a> (<a href="switch-map.svg">svg</a>) le r&eacute;seau [${LOCALTIME}] - site ${SITE_NAME}
80</h1>
81
82<p>
83Ce portail pr&eacute;sente&nbsp;:
84toutes les <b>IP d&eacute;tect&eacute;es</b>,
85les <a href="ip-free.html">IP non d&eacute;tect&eacute;es</a> depuis plus de deux ann&eacute;es,
86les <a href="bad-vlan-id.html">machines configur&eacute;es dans un mauvais VLAN</a>.
87</p>
88
89<p>
90Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
91<a href="hostname-db.txt">Machines</a>,
92<a href="switch-db.txt">Commutateurs</a>,
93<a href="ipfree-db.txt">IP disponibles</a>,
94<a href="switch-map.txt">Carte</a>.
95</p>
96END
97
98$KLASK exportdb --format html >> ${TMP}/index.html
99
100$CAT <<END >> ${TMP}/index.html
101</body>
102</html>
103END
104
105
106$CAT <<END > ${TMP}/ip-free.html
107<html>
108<head>
109 <link rel="stylesheet" type="text/css" href="style-klask.css" />
110 <meta http-equiv="refresh" content="1800">
111 <script src="sorttable-klask.js"></script>
112</head>
113<body>
114<h1>
115<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask">Klask</a></b>
116- Un outil pour <a href="switch-map.png">cartographier</a> (<a href="switch-map.svg">svg</a>) le r&eacute;seau [${LOCALTIME}] - site ${SITE_NAME}
117</h1>
118
119<p>
120Ce portail pr&eacute;sente&nbsp;:
121toutes les <a href="index.html">IP d&eacute;tect&eacute;es</a>,
122les <b>IP non d&eacute;tect&eacute;es</b> depuis plus de deux ann&eacute;es,
123les <a href="bad-vlan-id.html">machines configur&eacute;es dans un mauvais VLAN</a>.
124</p>
125
126<p>
127Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
128<a href="hostname-db.txt">Machines</a>,
129<a href="switch-db.txt">Commutateurs</a>,
130<a href="ipfree-db.txt">IP disponibles</a>,
131<a href="switch-map.txt">Carte</a>.
132</p>
133END
134
135$KLASK ip-free --format html >> ${TMP}/ip-free.html
136
137$CAT <<END >> ${TMP}/ip-free.html
138</body>
139</html>
140END
141
142
143$CAT <<END > ${TMP}/bad-vlan-id.html
144<html>
145<head>
146 <link rel="stylesheet" type="text/css" href="style-klask.css" />
147 <meta http-equiv="refresh" content="1800">
148 <script src="sorttable-klask.js"></script>
149</head>
150<body>
151<h1>
152<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask">Klask</a></b>
153- Un outil pour <a href="switch-map.png">cartographier</a> (<a href="switch-map.svg">svg</a>) le r&eacute;seau [${LOCALTIME}] - site ${SITE_NAME}
154</h1>
155
156<p>
157Ce portail pr&eacute;sente&nbsp;:
158toutes les <a href="index.html">IP d&eacute;tect&eacute;es</a>,
159les <a href="ip-free.html">IP non d&eacute;tect&eacute;es</a> depuis plus de deux ann&eacute;es,
160les <b>machines configur&eacute;es dans un mauvais VLAN</b>.
161</p>
162
163<p>
164Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
165<a href="hostname-db.txt">Machines</a>,
166<a href="switch-db.txt">Commutateurs</a>,
167<a href="ipfree-db.txt">IP disponibles</a>,
168<a href="switch-map.txt">Carte</a>.
169</p>
170END
171
172$KLASK bad-vlan-id --format html >> ${TMP}/bad-vlan-id.html
173
174$CAT <<END >> ${TMP}/bad-vlan-id.html
175</body>
176</html>
177END
178
179
180if [ "${REMOTE_SERVER}" = "localhost" ]
181then
182   $RSYNC \
183      /usr/share/klask/sorttable-klask.js \
184      /usr/share/klask/style-klask.css \
185      ${TMP}/index.html \
186      ${TMP}/ip-free.html \
187      ${TMP}/bad-vlan-id.html \
188      ${TMP}/*-db.txt \
189      ${TMP}/switch-map.txt \
190      ${REMOTE_FOLDER}/
191
192   [ -x ${DOT} ] && (cd ${REMOTE_FOLDER}; ${DOT} -T svg switch-map.txt > switch-map.svg; ${DOT} -T png switch-map.txt > switch-map.png)
193
194else
195   $RSYNC \
196      /usr/share/klask/sorttable-klask.js \
197      /usr/share/klask/style-klask.css \
198      ${TMP}/index.html \
199      ${TMP}/ip-free.html \
200      ${TMP}/bad-vlan-id.html \
201      ${TMP}/*-db.txt \
202      ${TMP}/switch-map.txt \
203      ${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_FOLDER}/
204
205
206   $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)"
207fi
Note: See TracBrowser for help on using the repository browser.