source: trunk/klask-push-web @ 87

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