source: trunk/push-web @ 340

Last change on this file since 340 was 338, checked in by g7moreau, 6 years ago
  • Very small CSS details
  • Property svn:executable set to *
File size: 5.4 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$KLASK bad-vlan-id > ${TMP}/badvlan-db.txt
57
58
59$CAT <<END > ${TMP}/index.html
60<html>
61<head>
62 <link rel="stylesheet" type="text/css" href="style-klask.css" />
63 <meta http-equiv="refresh" content="1800">
64 <noscript>
65 </noscript>
66 <script src="sorttable-klask.js"></script>
67 <script>
68function delayedRefresh() {
69 setTimeout( "refresh()", 1800*1000 );
70 }
71
72function refresh() {
73 history.go(0);
74 }
75 </script>
76</head>
77<body onload="delayedRefresh">
78<h1>
79<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask" class="circle">Klask</a></b>
80Tool for <a href="switch-map.png">mapping</a> (<a href="switch-map.png">png</a>|<a href="switch-map.svg">svg</a>)
81the local network [${LOCALTIME}] - site ${SITE_NAME}
82</h1>
83
84<div id="navbar">
85 <ul>
86  <li id="selected"><a href="index.html">IP detected</a></li>
87  <li><a href="ip-free.html">IP available</a></li>
88  <li><a href="bad-vlan-id.html">Bad VLAN ID</a></li>
89 </ul>
90</div>
91
92<div id="content">
93<p>
94The main raw results of Klask are accessible directly, via wget or curl for example, for a specific treatment:
95<a href="hostname-db.txt">Computers</a>,
96<a href="switch-db.txt">Switches</a>,
97<a href="ipfree-db.txt">IP available</a>,
98<a href="badvlan-db.txt">Bad VLAN ID</a>,
99<a href="switch-map.txt">Map</a>.
100</p>
101END
102
103$KLASK exportdb --format html >> ${TMP}/index.html
104
105$CAT <<END >> ${TMP}/index.html
106</body>
107</html>
108END
109
110
111$CAT <<END > ${TMP}/ip-free.html
112<html>
113<head>
114 <link rel="stylesheet" type="text/css" href="style-klask.css" />
115 <meta http-equiv="refresh" content="1800">
116 <script src="sorttable-klask.js"></script>
117</head>
118<body>
119<h1>
120<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask" class="circle">Klask</a></b>
121Tool for <a href="switch-map.png">mapping</a> (<a href="switch-map.png">png</a>|<a href="switch-map.svg">svg</a>)
122the local network [${LOCALTIME}] - site ${SITE_NAME}
123</h1>
124
125<div id="navbar">
126 <ul>
127  <li><a href="index.html">IP detected</a></li>
128  <li id="selected"><a href="ip-free.html">IP available</a></li>
129  <li><a href="bad-vlan-id.html">Bad VLAN ID</a></li>
130 </ul>
131</div>
132
133<div id="content">
134<p>
135The main raw results of Klask are accessible directly, via wget or curl for example, for a specific treatment:
136<a href="hostname-db.txt">Computers</a>,
137<a href="switch-db.txt">Switches</a>,
138<a href="ipfree-db.txt">IP available</a>,
139<a href="bad-vlan-id-db.txt">Bad VLAN ID</a>,
140<a href="switch-map.txt">Map</a>.
141</p>
142END
143
144$KLASK ip-free --format html >> ${TMP}/ip-free.html
145
146$CAT <<END >> ${TMP}/ip-free.html
147</div>
148</body>
149</html>
150END
151
152
153$CAT <<END > ${TMP}/bad-vlan-id.html
154<html>
155<head>
156 <link rel="stylesheet" type="text/css" href="style-klask.css" />
157 <meta http-equiv="refresh" content="1800">
158 <script src="sorttable-klask.js"></script>
159</head>
160<body>
161<h1>
162<b><a href="http://servforge.legi.grenoble-inp.fr/projects/klask" class="circle">Klask</a></b>
163Tool for <a href="switch-map.png">mapping</a> (<a href="switch-map.png">png</a>|<a href="switch-map.svg">svg</a>)
164the local network [${LOCALTIME}] - site ${SITE_NAME}
165</h1>
166
167<div id="navbar">
168 <ul>
169  <li><a href="index.html">IP detected</a></li>
170  <li><a href="ip-free.html">IP available</a></li>
171  <li id="selected"><a href="bad-vlan-id.html">Bad VLAN ID</a></li>
172 </ul>
173</div>
174
175<div id="content">
176<p>
177The main raw results of Klask are accessible directly, via wget or curl for example, for a specific treatment:
178<a href="hostname-db.txt">Computers</a>,
179<a href="switch-db.txt">Switches</a>,
180<a href="ipfree-db.txt">IP available</a>,
181<a href="bad-vlan-id-db.txt">Bad VLAN ID</a>,
182<a href="switch-map.txt">Map</a>.
183</p>
184END
185
186$KLASK bad-vlan-id --format html >> ${TMP}/bad-vlan-id.html
187
188$CAT <<END >> ${TMP}/bad-vlan-id.html
189</body>
190</html>
191END
192
193
194if [ "${REMOTE_SERVER}" = "localhost" ]
195then
196   $RSYNC \
197      /usr/share/klask/sorttable-klask.js \
198      /usr/share/klask/style-klask.css \
199      ${TMP}/index.html \
200      ${TMP}/ip-free.html \
201      ${TMP}/bad-vlan-id.html \
202      ${TMP}/*-db.txt \
203      ${TMP}/switch-map.txt \
204      ${REMOTE_FOLDER}/
205
206   [ -x ${DOT} ] && (cd ${REMOTE_FOLDER}; ${DOT} -T svg switch-map.txt > switch-map.svg; ${DOT} -T png switch-map.txt > switch-map.png)
207
208else
209   $RSYNC \
210      /usr/share/klask/sorttable-klask.js \
211      /usr/share/klask/style-klask.css \
212      ${TMP}/index.html \
213      ${TMP}/ip-free.html \
214      ${TMP}/bad-vlan-id.html \
215      ${TMP}/*-db.txt \
216      ${TMP}/switch-map.txt \
217      ${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_FOLDER}/
218
219
220   $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)"
221fi
Note: See TracBrowser for help on using the repository browser.