source: trunk/push-web @ 327

Last change on this file since 327 was 292, checked in by g7moreau, 7 years ago
  • Add GRAPH_MODULO and GRAPH_SHIFT variable
  • Property svn:executable set to *
File size: 4.0 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 la liste de toutes les IP d&eacute;tect&eacute;es par Klask.
84La liste des <a href="ip-free.html">IP non d&eacute;tect&eacute;es</a> par Klask depuis plus de deux ann&eacute;es est aussi disponible.
85</p>
86
87<p>
88Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
89<a href="hostname-db.txt">Machines</a>,
90<a href="switch-db.txt">Commutateurs</a>,
91<a href="ipfree-db.txt">IP disponibles</a>,
92<a href="switch-map.txt">Carte</a>.
93</p>
94END
95
96$KLASK exportdb --format html >> ${TMP}/index.html
97
98$CAT <<END >> ${TMP}/index.html
99</body>
100</html>
101END
102
103
104$CAT <<END > ${TMP}/ip-free.html
105<html>
106<head>
107 <link rel="stylesheet" type="text/css" href="style-klask.css" />
108 <meta http-equiv="refresh" content="1800">
109 <script src="sorttable-klask.js"></script>
110</head>
111<body>
112<h1>
113<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask">Klask</a></b>
114- 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}
115</h1>
116
117<p>
118Cette page pr&eacute;sente la liste des IP non d&eacute;tect&eacute;es par Klask depuis plus de deux ann&eacute;es.
119Le portail contient la liste de toutes les <a href="index.html">IP d&eacute;tect&eacute;es</a> par Klask.
120</p>
121
122<p>
123Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
124<a href="hostname-db.txt">Machines</a>,
125<a href="switch-db.txt">Commutateurs</a>,
126<a href="ipfree-db.txt">IP disponibles</a>,
127<a href="switch-map.txt">Carte</a>.
128</p>
129END
130
131$KLASK ip-free --format html >> ${TMP}/ip-free.html
132
133$CAT <<END >> ${TMP}/ip-free.html
134</body>
135</html>
136END
137
138if [ "${REMOTE_SERVER}" = "localhost" ]
139then
140   $RSYNC \
141      /usr/share/klask/sorttable-klask.js \
142      /usr/share/klask/style-klask.css \
143      ${TMP}/index.html \
144      ${TMP}/ip-free.html \
145      ${TMP}/*-db.txt \
146      ${TMP}/switch-map.txt \
147      ${REMOTE_FOLDER}/
148
149   [ -x ${DOT} ] && (cd ${REMOTE_FOLDER}; ${DOT} -T svg switch-map.txt > switch-map.svg; ${DOT} -T png switch-map.txt > switch-map.png)
150
151else
152   $RSYNC \
153      /usr/share/klask/sorttable-klask.js \
154      /usr/share/klask/style-klask.css \
155      ${TMP}/index.html \
156      ${TMP}/ip-free.html \
157      ${TMP}/*-db.txt \
158      ${TMP}/switch-map.txt \
159      ${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_FOLDER}/
160
161
162   $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)"
163fi
Note: See TracBrowser for help on using the repository browser.