Last active 1700047249

a script to touch/rm a file based on ping result, and an nginx conf

Revision b361782c77f237d3ad3169ae14507b1da31513a2

offline-check.sh Raw
1#!/bin/bash
2# offline-check [ip number of host]
3# e.g `offline-check 2` generates /var/www/html/offline.check.2
4ping -w1 -c1 10.8.0.$1 | grep "64 bytes from" 2>&1 >/dev/null && rm -f /var/www/html/offline.check.$1 2>/dev/null || touch /var/www/html/offline.check.$1
snippets-offline.conf Raw
1# server { include /etc/nginx/snippets/offline.conf; }
2error_page 502 503 @offline;
3location @offline {
4 root /var/www/html;
5 rewrite ^(.*)$ /offline.html break;
6}
snippets-offlineloc.conf Raw
1# location { include /etc/nginx/snippets/offlineloc.conf; }
2 if (-f /var/www/html/offline.check.2) {
3 return 503;
4 }