[85] | 1 | #!/bin/bash |
---|
| 2 | # |
---|
| 3 | # 2007/10/23 gabriel |
---|
| 4 | # 2010/11/03 gabriel |
---|
| 5 | # 2011/03/30 gabriel - make it generic |
---|
| 6 | |
---|
| 7 | TMP='/tmp/klask-push-web' |
---|
| 8 | |
---|
| 9 | SITE_NAME='' |
---|
| 10 | REMOTE_SERVER=localhost |
---|
| 11 | REMOTE_USER='' |
---|
| 12 | REMOTE_FOLDER=/var/www/klask/ |
---|
| 13 | |
---|
| 14 | if test -f /etc/klask/push-web.conf |
---|
| 15 | then |
---|
| 16 | . /etc/klask/push-web.conf |
---|
| 17 | fi |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | MKDIR=/bin/mkdir |
---|
| 21 | DATE=/bin/date |
---|
| 22 | CAT=/bin/cat |
---|
| 23 | TAIL=/usr/bin/tail |
---|
| 24 | HEAD=/usr/bin/head |
---|
| 25 | SSH=/usr/bin/ssh |
---|
| 26 | SCP=/usr/bin/scp |
---|
| 27 | KLASK=/usr/sbin/klask |
---|
| 28 | RSYNC=/usr/bin/rsync |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | $MKDIR -p $TMP |
---|
| 32 | if test ! -d ${TMP} |
---|
| 33 | then |
---|
| 34 | echo "Error: Folder ${TMP} do not exist !" |
---|
| 35 | exit 1 |
---|
| 36 | fi |
---|
| 37 | cd ${TMP} |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | LOCALTIME=$($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> |
---|
| 60 | function delayedRefresh() { |
---|
| 61 | setTimeout( "refresh()", 1800*1000 ); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | function 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éseau [${LOCALTIME}] - site ${SITE_NAME} |
---|
| 73 | </h1> |
---|
| 74 | |
---|
| 75 | <p> |
---|
| 76 | Ce portail présente la liste de toutes les IP détectées par Klask. |
---|
| 77 | La liste des <a href="ip-free.html">IP non détectées</a> par Klask depuis plus de deux années est aussi disponible. |
---|
| 78 | </p> |
---|
| 79 | |
---|
| 80 | <p> |
---|
| 81 | Les résultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement spé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> |
---|
| 87 | END |
---|
| 88 | |
---|
| 89 | $KLASK exportdb --format html >> ${TMP}/index.html |
---|
| 90 | |
---|
| 91 | $CAT <<END >> ${TMP}/index.html |
---|
| 92 | </body> |
---|
| 93 | </html> |
---|
| 94 | END |
---|
| 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éseau [${LOCALTIME}] - site ${SITE_NAME} |
---|
| 107 | </h1> |
---|
| 108 | |
---|
| 109 | <p> |
---|
| 110 | Cette page présente la liste des IP non détectées par Klask depuis plus de deux années. |
---|
| 111 | Le portail contient la liste de toutes les <a href="index.html">IP détectées</a> par Klask. |
---|
| 112 | </p> |
---|
| 113 | |
---|
| 114 | <p> |
---|
| 115 | Les résultats brut de Klask sont accessibles directement via wget ou curl, par exemple, pour un traitement spé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> |
---|
| 121 | END |
---|
| 122 | |
---|
| 123 | $KLASK ip-free --format html >> ${TMP}/ip-free.html |
---|
| 124 | |
---|
| 125 | $CAT <<END >> ${TMP}/ip-free.html |
---|
| 126 | </body> |
---|
| 127 | </html> |
---|
| 128 | END |
---|
| 129 | |
---|
| 130 | if test ${REMOTE_SERVER} = 'localhost' |
---|
| 131 | then |
---|
| 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 | |
---|
| 143 | else |
---|
| 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)" |
---|
| 155 | fi |
---|