diff --git a/README.md b/README.md index e0a37a3..c2fbfa2 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ chown www:www /var/www/run install -o www -g www -m 0400 httpd.conf /etc/ echo "permit nopass root as www" >> /etc/doas.conf curl -L https://cpanmin.us | perl - App::cpanminus -cpanm -l /var/www/perl5 FCGI Switch -perl -I /var/www/perl5/lib/perl5 -MFCGI -M5.010 -e 'say "it works"' # test perl installation +cpanm -l /var/www/perl5 FCGI Switch Template::Simple File::Slurp install -o www -g www -m 0500 tormon/* /var/www/tormon/ echo 'echo "Starting tormon" && doas -u www /var/www/tormon/tormon.fcgi &' >> /etc/rc.local sh /etc/rc.local # assuming tormon is the only thing in rc.local diff --git a/tormon/tormon.fcgi b/tormon/tormon.fcgi index e5f08a5..6b05e7b 100755 --- a/tormon/tormon.fcgi +++ b/tormon/tormon.fcgi @@ -4,6 +4,14 @@ use strict; use warnings; use FCGI; use Switch; +use File::Slurp; +use Template::Simple; +use FindBin qw($Bin); + +my $tmpl = new Template::Simple ( + pre_delim => "<%", + post_delim => "%>", +); my $sock = FCGI::OpenSocket( "/var/www/run/tormon.sock", @@ -21,14 +29,24 @@ my $request = FCGI::Request( while ($request->Accept() <= 0) { print "Content-Type: text/html\n\n"; + my $content; switch ($ENV{"REQUEST_URI"}) { case "/debug" { use Data::Dumper; - print ""; + $content = ""; } case "/" { - print "Hello, world!"; + $content = "Hello, world!"; } } + + my $tt = read_file("$Bin/wrapper.tt"); + my $html = $tmpl->render( + $tt, + { + content => $content, + }, + ); + print ${$html}; } diff --git a/tormon/wrapper.tt b/tormon/wrapper.tt new file mode 100644 index 0000000..57a8869 --- /dev/null +++ b/tormon/wrapper.tt @@ -0,0 +1,12 @@ + + + + Tor Relay/Bridge Monitor + + + + <% content %> + +