offline-check.sh
· 325 B · Bash
Raw
#!/bin/bash
# offline-check [ip number of host]
# e.g `offline-check 2` generates /var/www/html/offline.check.2
# example crontab: * * * * * $HOME/.local/bin/offline-check
ping -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
| 1 | #!/bin/bash |
| 2 | # offline-check [ip number of host] |
| 3 | # e.g `offline-check 2` generates /var/www/html/offline.check.2 |
| 4 | # example crontab: * * * * * $HOME/.local/bin/offline-check |
| 5 | ping -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 |
offline.html
· 1.9 KiB · HTML
Raw
<!-- /var/www/html/offline.html -->
<!doctype html>
<html>
<head>
<title>Site Maintenance</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet"/>
<meta content="width=device-width, initial-scale=1" name="viewport" />
<style>
body {
text-align: center;
font-family: "Poppins", sans-serif;
color: #0C1231;
}
.logo {
margin-top: 3rem;
max-height: 35px;
width: auto;
}
.content {
margin: 0 auto;
max-width: 1000px;
width: 90%;
}
.info {
margin: 0 auto;
margin-top: 3rem;
max-width: 500px;
}
h1 {
font-weight: 600;
font-size: 1.8rem;
}
.image-main {
margin-top: 3rem;
max-width: 90%;
}
hr {
border: 1px solid rgba(0, 0, 0, 0.08);
margin: 0 auto;
margin-top: 2rem;
margin-bottom: 1rem;
max-width: 90%;
}
a {
text-decoration: none;
color: #535353
}
a:hover {
color: #0C1231;
}
@media (min-width: 968px) {
.logo {
max-height: 45px;
}
h1 {
font-size: 2.5rem;
}
.info {
margin-top: 6rem;
}
hr {
margin-top: 6rem;
margin-bottom: 3rem;
}
}
</style>
</head>
<body>
<div class="content">
<div class="info">
<h1>Down for maintenance</h1>
<p>Nothing here right now. Check back later!</p>
</div>
<img class="image-main" src="https://sfiles.aly.pet/0uJkCM8.png" alt="Maintenance image">
</div>
</body>
</html>
| 1 | <!-- /var/www/html/offline.html --> |
| 2 | <!doctype html> |
| 3 | <html> |
| 4 | <head> |
| 5 | <title>Site Maintenance</title> |
| 6 | |
| 7 | <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet"/> |
| 8 | <meta content="width=device-width, initial-scale=1" name="viewport" /> |
| 9 | <style> |
| 10 | body { |
| 11 | text-align: center; |
| 12 | font-family: "Poppins", sans-serif; |
| 13 | color: #0C1231; |
| 14 | } |
| 15 | |
| 16 | .logo { |
| 17 | margin-top: 3rem; |
| 18 | max-height: 35px; |
| 19 | width: auto; |
| 20 | } |
| 21 | |
| 22 | .content { |
| 23 | margin: 0 auto; |
| 24 | max-width: 1000px; |
| 25 | width: 90%; |
| 26 | } |
| 27 | |
| 28 | .info { |
| 29 | margin: 0 auto; |
| 30 | margin-top: 3rem; |
| 31 | max-width: 500px; |
| 32 | } |
| 33 | |
| 34 | h1 { |
| 35 | font-weight: 600; |
| 36 | font-size: 1.8rem; |
| 37 | } |
| 38 | |
| 39 | .image-main { |
| 40 | margin-top: 3rem; |
| 41 | max-width: 90%; |
| 42 | } |
| 43 | |
| 44 | hr { |
| 45 | border: 1px solid rgba(0, 0, 0, 0.08); |
| 46 | |
| 47 | margin: 0 auto; |
| 48 | margin-top: 2rem; |
| 49 | margin-bottom: 1rem; |
| 50 | max-width: 90%; |
| 51 | } |
| 52 | |
| 53 | a { |
| 54 | text-decoration: none; |
| 55 | color: #535353 |
| 56 | } |
| 57 | |
| 58 | a:hover { |
| 59 | color: #0C1231; |
| 60 | } |
| 61 | |
| 62 | @media (min-width: 968px) { |
| 63 | .logo { |
| 64 | max-height: 45px; |
| 65 | } |
| 66 | |
| 67 | h1 { |
| 68 | font-size: 2.5rem; |
| 69 | } |
| 70 | |
| 71 | .info { |
| 72 | margin-top: 6rem; |
| 73 | } |
| 74 | |
| 75 | hr { |
| 76 | margin-top: 6rem; |
| 77 | margin-bottom: 3rem; |
| 78 | } |
| 79 | } |
| 80 | </style> |
| 81 | </head> |
| 82 | |
| 83 | <body> |
| 84 | <div class="content"> |
| 85 | <div class="info"> |
| 86 | <h1>Down for maintenance</h1> |
| 87 | <p>Nothing here right now. Check back later!</p> |
| 88 | </div> |
| 89 | <img class="image-main" src="https://sfiles.aly.pet/0uJkCM8.png" alt="Maintenance image"> |
| 90 | </div> |
| 91 | </body> |
| 92 | </html> |
| 93 |
snippets-offline.nginxconf
· 169 B · Text
Raw
# server { include /etc/nginx/snippets/offline.conf; }
error_page 502 503 @offline;
location @offline {
root /var/www/html;
rewrite ^(.*)$ /offline.html break;
}
| 1 | # server { include /etc/nginx/snippets/offline.conf; } |
| 2 | error_page 502 503 @offline; |
| 3 | location @offline { |
| 4 | root /var/www/html; |
| 5 | rewrite ^(.*)$ /offline.html break; |
| 6 | } |
snippets-offlineloc.nginxconf
· 271 B · Text
Raw
# location { include /etc/nginx/snippets/offlineloc.conf; }
# change the number after offline.check. to the ip number of the dest server on the vpn
if (-f /var/www/html/offline.check.2) {
return 503;
}
# proxy_pass http://10.8.0.2:1234/;
| 1 | # location { include /etc/nginx/snippets/offlineloc.conf; } |
| 2 | # change the number after offline.check. to the ip number of the dest server on the vpn |
| 3 | if (-f /var/www/html/offline.check.2) { |
| 4 | return 503; |
| 5 | } |
| 6 | # proxy_pass http://10.8.0.2:1234/; |