source: trunk/push-web @ 331

Last change on this file since 331 was 331, checked in by g7moreau, 6 years ago
  • Update web part with global navbar
  • Property svn:executable set to *
File size: 5.2 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<div id="navbar">
83 <ul>
84  <li id="selected"><a href="index.html">IP detected</a></li>
85  <li><a href="ip-free.html">IP free</a></li>
86  <li><a href="bad-vlan-id.html">Bad VLAN ID</a></li>
87 </ul>
88</div>
89
90<div id="content">
91<p>
92Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
93<a href="hostname-db.txt">Machines</a>,
94<a href="switch-db.txt">Commutateurs</a>,
95<a href="ipfree-db.txt">IP disponibles</a>,
96<a href="switch-map.txt">Carte</a>.
97</p>
98END
99
100$KLASK exportdb --format html >> ${TMP}/index.html
101
102$CAT <<END >> ${TMP}/index.html
103</body>
104</html>
105END
106
107
108$CAT <<END > ${TMP}/ip-free.html
109<html>
110<head>
111 <link rel="stylesheet" type="text/css" href="style-klask.css" />
112 <meta http-equiv="refresh" content="1800">
113 <script src="sorttable-klask.js"></script>
114</head>
115<body>
116<h1>
117<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask">Klask</a></b>
118- 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}
119</h1>
120
121<div id="navbar">
122 <ul>
123  <li><a href="index.html">IP detected</a></li>
124  <li id="selected"><a href="ip-free.html">IP free</a></li>
125  <li><a href="bad-vlan-id.html">Bad VLAN ID</a></li>
126 </ul>
127</div>
128
129<div id="content">
130<p>
131Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
132<a href="hostname-db.txt">Machines</a>,
133<a href="switch-db.txt">Commutateurs</a>,
134<a href="ipfree-db.txt">IP disponibles</a>,
135<a href="switch-map.txt">Carte</a>.
136</p>
137END
138
139$KLASK ip-free --format html >> ${TMP}/ip-free.html
140
141$CAT <<END >> ${TMP}/ip-free.html
142</div>
143</body>
144</html>
145END
146
147
148$CAT <<END > ${TMP}/bad-vlan-id.html
149<html>
150<head>
151 <link rel="stylesheet" type="text/css" href="style-klask.css" />
152 <meta http-equiv="refresh" content="1800">
153 <script src="sorttable-klask.js"></script>
154</head>
155<body>
156<h1>
157<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask">Klask</a></b>
158- 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}
159</h1>
160
161<div id="navbar">
162 <ul>
163  <li><a href="index.html">IP detected</a></li>
164  <li><a href="ip-free.html">IP free</a></li>
165  <li id="selected"><a href="bad-vlan-id.html">Bad VLAN ID</a></li>
166 </ul>
167</div>
168
169<div id="content">
170<p>
171Les r&eacute;sultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement sp&eacute;cifique :
172<a href="hostname-db.txt">Machines</a>,
173<a href="switch-db.txt">Commutateurs</a>,
174<a href="ipfree-db.txt">IP disponibles</a>,
175<a href="switch-map.txt">Carte</a>.
176</p>
177END
178
179$KLASK bad-vlan-id --format html >> ${TMP}/bad-vlan-id.html
180
181$CAT <<END >> ${TMP}/bad-vlan-id.html
182</body>
183</html>
184END
185
186
187if [ "${REMOTE_SERVER}" = "localhost" ]
188then
189   $RSYNC \
190      /usr/share/klask/sorttable-klask.js \
191      /usr/share/klask/style-klask.css \
192      ${TMP}/index.html \
193      ${TMP}/ip-free.html \
194      ${TMP}/bad-vlan-id.html \
195      ${TMP}/*-db.txt \
196      ${TMP}/switch-map.txt \
197      ${REMOTE_FOLDER}/
198
199   [ -x ${DOT} ] && (cd ${REMOTE_FOLDER}; ${DOT} -T svg switch-map.txt > switch-map.svg; ${DOT} -T png switch-map.txt > switch-map.png)
200
201else
202   $RSYNC \
203      /usr/share/klask/sorttable-klask.js \
204      /usr/share/klask/style-klask.css \
205      ${TMP}/index.html \
206      ${TMP}/ip-free.html \
207      ${TMP}/bad-vlan-id.html \
208      ${TMP}/*-db.txt \
209      ${TMP}/switch-map.txt \
210      ${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_FOLDER}/
211
212
213   $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)"
214fi
Note: See TracBrowser for help on using the repository browser.