source: trunk/klask-push-web @ 85

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