Changeset 412 for trunk/push-web
- Timestamp:
- Jan 28, 2020, 4:56:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/push-web
r411 r412 20 20 GRAPH_SHIFT=1 21 21 22 CACHE_TIMEOUT=50 23 CACHE_FOLDER='/tmp/klask-push-web' 24 22 25 if [ -f /etc/klask/push-web.conf ] 23 26 then … … 25 28 fi 26 29 27 TMP='/tmp/klask-push-web'28 29 30 30 31 # remote command 31 32 DOT=/usr/bin/dot 32 33 33 34 mkdir -p ${TMP} 35 if [ ! -d ${TMP} ] 34 mkdir -p ${CACHE_FOLDER} 35 if [ ! -d ${CACHE_FOLDER} ] 36 36 then 37 echo "Error: Folder ${ TMP} do not exist !"37 echo "Error: Folder ${CACHE_FOLDER} do not exist !" 38 38 exit 1 39 39 fi 40 cd ${TMP} 41 40 cd ${CACHE_FOLDER} 42 41 43 42 LOCALTIME=$(date "+%Y-%m-%d %H:%M") 44 43 TIMEFILE=$(date "+%Y-%m-%d.%H-%M") 45 44 46 CACHE_TIMEOUT=50 47 find ${TMP}/ -type f -a -mtime +${CACHE_TIMEOUT} -delete 48 49 klask exportsw --format dot --modulo ${GRAPH_MODULO} --shift ${GRAPH_SHIFT} > ${TMP}/switch-map.txt.new50 klask exportsw > ${TMP}/switch-db.txt.new 51 52 klask exportdb > ${TMP}/hostname-db.txt53 klask ip-free > ${TMP}/ipfree-db.txt54 klask bad-vlan-id > ${TMP}/badvlan-db.txt 55 56 cmp --silent ${TMP}/switch-db.txt.new ${TMP}/switch-db.txt || { 57 mv -f ${TMP}/switch-db.txt.new ${TMP}/switch-db.${TIMEFILE}.txt;58 ln -sf ${TMP}/switch-db.${TIMEFILE}.txt ${TMP}/switch-db.txt59 } 60 61 cmp --silent ${TMP}/switch-map.txt.new ${TMP}/switch-map.txt || { 62 mv -f ${TMP}/switch-map.txt.new ${TMP}/switch-map.${TIMEFILE}.txt;63 ln -sf ${TMP}/switch-map.${TIMEFILE}.txt ${TMP}/switch-map.txt64 } 65 45 find ${CACHE_FOLDER}/ -type f -a -mtime +${CACHE_TIMEOUT} -delete 46 47 klask exportsw --format dot --modulo ${GRAPH_MODULO} --shift ${GRAPH_SHIFT} > ${CACHE_FOLDER}/switch-map.txt.new 48 klask exportsw > ${CACHE_FOLDER}/switch-db.txt.new 49 50 klask exportdb > ${CACHE_FOLDER}/hostname-db.txt 51 klask ip-free > ${CACHE_FOLDER}/ipfree-db.txt 52 klask bad-vlan-id > ${CACHE_FOLDER}/badvlan-db.txt 53 54 cmp --silent ${CACHE_FOLDER}/switch-db.txt.new ${CACHE_FOLDER}/switch-db.txt || { 55 mv -f ${CACHE_FOLDER}/switch-db.txt.new ${CACHE_FOLDER}/switch-db.${TIMEFILE}.txt; 56 ln -sf ${CACHE_FOLDER}/switch-db.${TIMEFILE}.txt ${CACHE_FOLDER}/switch-db.txt 57 } 58 59 cmp --silent ${CACHE_FOLDER}/switch-map.txt.new ${CACHE_FOLDER}/switch-map.txt || { 60 mv -f ${CACHE_FOLDER}/switch-map.txt.new ${CACHE_FOLDER}/switch-map.${TIMEFILE}.txt; 61 ln -sf ${CACHE_FOLDER}/switch-map.${TIMEFILE}.txt ${CACHE_FOLDER}/switch-map.txt 62 } 63 64 # keep trace of old switch map 66 65 old_switch_db=$((echo 'command <tt>klask exportsw --format txt</tt>'; 67 (cd ${ TMP}/; ls -1 switch-db.20[0-9][0-9]-[0-9][0-9]-[0-9][0-9].[0-9][0-9]-[0-9][0-9].txt;) \66 (cd ${CACHE_FOLDER}/; ls -1 switch-db.20[0-9][0-9]-[0-9][0-9]-[0-9][0-9].[0-9][0-9]-[0-9][0-9].txt;) \ 68 67 | sed -e 's/^switch-db\.//; s/\.txt$//;' \ 69 | xargs -r -I {} printf " <a href=\"switch-db.%s.txt\">%s</a>\n" '{}' '{}' \68 | xargs -r -I {} printf " <a href=\"switch-db.%s.txt\">%s</a>\n" '{}' '{}' \ 70 69 ) \ 71 70 | paste -sd ',' -) 72 71 73 72 old_switch_map=$((echo 'graphviz';\ 74 (cd ${ TMP}/; ls -1 switch-map.20[0-9][0-9]-[0-9][0-9]-[0-9][0-9].[0-9][0-9]-[0-9][0-9].txt;) \73 (cd ${CACHE_FOLDER}/; ls -1 switch-map.20[0-9][0-9]-[0-9][0-9]-[0-9][0-9].[0-9][0-9]-[0-9][0-9].txt;) \ 75 74 | sed -e 's/^switch-map\.//; s/\.txt$//;' \ 76 | xargs -r -I {} printf " <a href=\"switch-map.%s.txt\">%s</a>\n" '{}' '{}' \75 | xargs -r -I {} printf " <a href=\"switch-map.%s.txt\">%s</a>\n" '{}' '{}' \ 77 76 )\ 78 77 | paste -sd ',' -) 79 78 80 cat <<END > ${TMP}/index.html 79 80 cat <<END > ${CACHE_FOLDER}/index.html 81 81 <!DOCTYPE html> 82 82 <html lang="en"> … … 205 205 END 206 206 207 klask exportdb --format html >> ${ TMP}/index.html208 209 cat <<END >> ${ TMP}/index.html207 klask exportdb --format html >> ${CACHE_FOLDER}/index.html 208 209 cat <<END >> ${CACHE_FOLDER}/index.html 210 210 </div> 211 211 … … 217 217 END 218 218 219 klask ip-free --format html >> ${ TMP}/index.html220 221 cat <<END >> ${ TMP}/index.html219 klask ip-free --format html >> ${CACHE_FOLDER}/index.html 220 221 cat <<END >> ${CACHE_FOLDER}/index.html 222 222 </div> 223 223 … … 229 229 END 230 230 231 klask bad-vlan-id --format html >> ${ TMP}/index.html232 233 cat <<END >> ${ TMP}/index.html231 klask bad-vlan-id --format html >> ${CACHE_FOLDER}/index.html 232 233 cat <<END >> ${CACHE_FOLDER}/index.html 234 234 </div> 235 235 … … 283 283 /usr/share/klask/svg-pan-zoom-klask.js \ 284 284 /usr/share/klask/style-klask.css \ 285 ${ TMP}/index.html \286 ${ TMP}/*-db.txt \287 ${ TMP}/switch-map.txt \288 ${ TMP}/*.20[0-9][0-9]-[0-9][0-9]-[0-9][0-9].[0-9][0-9]-[0-9][0-9].txt \285 ${CACHE_FOLDER}/index.html \ 286 ${CACHE_FOLDER}/*-db.txt \ 287 ${CACHE_FOLDER}/switch-map.txt \ 288 ${CACHE_FOLDER}/*.20[0-9][0-9]-[0-9][0-9]-[0-9][0-9].[0-9][0-9]-[0-9][0-9].txt \ 289 289 ${REMOTE_FOLDER}/ 290 290 … … 298 298 /usr/share/klask/svg-pan-zoom-klask.js \ 299 299 /usr/share/klask/style-klask.css \ 300 ${ TMP}/index.html \301 ${ TMP}/*-db.txt \302 ${ TMP}/switch-map.txt \303 ${ TMP}/*.20[0-9][0-9]-[0-9][0-9]-[0-9][0-9].[0-9][0-9]-[0-9][0-9].txt \300 ${CACHE_FOLDER}/index.html \ 301 ${CACHE_FOLDER}/*-db.txt \ 302 ${CACHE_FOLDER}/switch-map.txt \ 303 ${CACHE_FOLDER}/*.20[0-9][0-9]-[0-9][0-9]-[0-9][0-9].[0-9][0-9]-[0-9][0-9].txt \ 304 304 ${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_FOLDER}/ 305 305
Note: See TracChangeset
for help on using the changeset viewer.