aboutsummaryrefslogtreecommitdiffstats
path: root/web/etc
diff options
context:
space:
mode:
Diffstat (limited to 'web/etc')
-rw-r--r--web/etc/cron/einstein.cron39
-rw-r--r--web/etc/cron/update-public-nms3
-rw-r--r--web/etc/varnish/default.vcl133
3 files changed, 172 insertions, 3 deletions
diff --git a/web/etc/cron/einstein.cron b/web/etc/cron/einstein.cron
new file mode 100644
index 0000000..616867f
--- /dev/null
+++ b/web/etc/cron/einstein.cron
@@ -0,0 +1,39 @@
+# Edit this file to introduce tasks to be run by cron.
+#
+# Each task to run has to be defined through a single line
+# indicating with different fields when the task will be run
+# and what command to run for the task
+#
+# To define the time you can provide concrete values for
+# minute (m), hour (h), day of month (dom), month (mon),
+# and day of week (dow) or use '*' in these fields (for 'any').#
+# Notice that tasks will be started based on the cron's system
+# daemon's notion of time and timezones.
+#
+# Output of the crontab jobs (including errors) is sent through
+# email to the user the crontab file belongs to (unless redirected).
+#
+# For example, you can run a backup of all your user accounts
+# at 5 a.m every week with:
+# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
+#
+# For more information see the manual pages of crontab(5) and cron(8)
+#
+# m h dom mon dow command
+
+# hver dag kl 18:00
+0 18 * * * /bin/bash /root/tgmanage/clients/fetch-cubemap-munin.sh
+
+# søndag kl 06:00
+0 6 05 04 * /bin/bash /root/tgmanage/clients/fetch-cubemap-munin.sh
+
+*/1 * * * * wget -qO/root/tgmanage/web/nms-public.gathering.org/nettkart-trafikk.png http://tg:REMOVED@nms.tg15.gathering.org/nettkart.pl
+*/1 * * * * wget -qO/root/tgmanage/web/nms-public.gathering.org/nettkart-dhcp.png http://tg:REMOVED@nms.tg15.gathering.org/dhcpkart.pl
+*/1 * * * * wget -qO/root/tgmanage/web/nms-public.gathering.org/tempkart.png http://tg:REMOVED@nms.tg15.gathering.org/stempmap.pl
+*/1 * * * * wget -qO/root/tgmanage/web/nms-public.gathering.org/switches.json http://tg:REMOVED@nms.tg15.gathering.org/switches-json.pl
+*/1 * * * * wget -qO/root/tgmanage/web/nms-public.gathering.org/nettkart.json 'http://tg:REMOVED@nms.tg15.gathering.org/nettkart-json.pl?secret=frosk&secret2=fisk&noise=0.0000000001&phase=3&period=86400'
+*/5 * * * * wget -qO/root/tgmanage/web/nms-public.gathering.org/weathermap.png http://185.12.59.23/cacti/plugins/weathermap/output/962ddeea4b2d7ad5bd02.png
+
+24 12 * * * /bin/bash /root/backup/tg15backup.sh
+13 07 05 04 * /bin/bash /root/backup/tg15backup.sh
+45 08 05 04 * /bin/bash /root/backup/tg15backup.sh
diff --git a/web/etc/cron/update-public-nms b/web/etc/cron/update-public-nms
deleted file mode 100644
index 3018042..0000000
--- a/web/etc/cron/update-public-nms
+++ /dev/null
@@ -1,3 +0,0 @@
-# Update public nms
-
-* * * * * root /root/tgmanage/clients/update-public-nms.sh
diff --git a/web/etc/varnish/default.vcl b/web/etc/varnish/default.vcl
new file mode 100644
index 0000000..8462e01
--- /dev/null
+++ b/web/etc/varnish/default.vcl
@@ -0,0 +1,133 @@
+#
+# This is an example VCL file for Varnish.
+#
+# It does not do anything by default, delegating control to the
+# builtin VCL. The builtin VCL is called when there is no explicit
+# return statement.
+#
+# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
+# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples.
+
+# Marker to tell the VCL compiler that this VCL has been adapted to the
+# new 4.0 format.
+vcl 4.0;
+
+# Default backend definition. Set this to point to your content server.
+backend default {
+ .host = "127.0.0.1";
+ .port = "8080";
+}
+
+acl einstein {
+ "localhost"; # myself
+ "185.12.59.12"; # and everyone on the local network
+ "2a02:ed02:1337::12";
+}
+
+sub vcl_recv {
+ if (req.url ~ "nightMode") {
+ set req.url = regsub(req.url, "nightMode","");
+ set req.url = req.url + "?nightMode";
+ }
+ # Happens before we check if we have this in cache already.
+ #
+ # Typically you clean up the request here, removing cookies you don't need,
+ # rewriting the request, etc.
+if (req.restarts == 0) {
+ if (req.http.X-Forwarded-For) {
+ set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
+ } else {
+ set req.http.X-Forwarded-For = client.ip;
+ }
+}
+
+ if (client.ip ~ einstein){
+ set req.http.x-einstein = "true";
+ } else {
+ set req.http.x-einstein = "false";
+ }
+
+ if (req.http.host ~ "stream") {
+ return (pass);
+ }
+
+ if (req.http.host ~ "nms-public"){
+ return (pass);
+ }
+
+ if (req.method != "GET" &&
+ req.method != "HEAD" &&
+ req.method != "PUT" &&
+ req.method != "POST" &&
+ req.method != "TRACE" &&
+ req.method != "OPTIONS" &&
+ req.method != "DELETE") {
+ /* Non-RFC2616 or CONNECT which is weird. */
+ return (pipe);
+ }
+
+ if (req.method != "GET" && req.method != "HEAD") {
+ /* We only deal with GET and HEAD by default */
+ return (pass);
+ }
+
+ unset req.http.Cookie;
+ if (req.http.Cookie) {
+ /* Not cacheable by default */
+ return (pass);
+ }
+
+ return (hash);
+ }
+sub vcl_hash {
+ hash_data(req.http.x-einstein);
+ hash_data(req.http.authorization);
+}
+sub vcl_backend_response {
+ # Happens after we have read the response headers from the backend.
+ #
+ # Here you clean the response headers, removing silly Set-Cookie headers
+ # and other mistakes your backend does.
+ if (!(bereq.http.host ~ "stream")) {
+ if (beresp.status == 200) {
+ set beresp.ttl = 2s;
+ } else {
+ set beresp.ttl = 0s;
+ }
+ if(bereq.url ~ "port-state.pl" && beresp.status == 200) {
+ set beresp.ttl = 30s;
+ }
+ if (beresp.status == 500) {
+ return (retry);
+ }
+ }
+
+}
+
+sub vcl_deliver {
+ # Happens when we have all the pieces we need, and are about to send the
+ # response to the client.
+ #
+ # You can do accounting or modifying the final object here.
+}
+sub vcl_backend_error {
+ set beresp.http.Content-Type = "text/html; charset=utf-8";
+ set beresp.http.Retry-After = "5";
+ synthetic( {"<!DOCTYPE html>
+ <html>
+ <head>
+ <title>"} + beresp.status + " " + beresp.reason + {"</title>
+ <meta http-equiv="refresh" content="1">
+ </head>
+ <body>
+ <h1>Error "} + beresp.status + " " + beresp.reason + {"</h1>
+ <p>"} + beresp.reason + {"</p>
+ <h3>Guru Meditation:</h3>
+ <p>XID: "} + bereq.xid + {"</p>
+ <hr>
+ <p>Totally not a Varnish cache server errror</p>
+ </body>
+ </html>
+ "} );
+ return (deliver);
+ }