]> git.xolatile.top Git - gorillanest.git/commitdiff
Hide Everything, Hyde!
authorEmil Williams <emilemilemil@cock.li>
Thu, 21 Aug 2025 01:01:39 +0000 (01:01 +0000)
committerEmil Williams <emilemilemil@cock.li>
Thu, 21 Aug 2025 01:01:39 +0000 (01:01 +0000)
Makefile
README
gorillanest [new file with mode: 0755]
gorillanest.pl.cgi [deleted file]
gorillanest.pl.fcgi [deleted file]
perl/cgi.pl [new file with mode: 0755]
perl/fcgi.pl [new file with mode: 0755]
service/lighttpd-cgi.conf
service/lighttpd-fcgi.conf

index f714ac4666a3609bb6f3a6394abf5d52224576d9..1c9dae088f50bf732814fa1733b8f91c4e4dab52 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,10 @@
-serve-dev:
+serve-dev lighttpd-cgi:
        lighttpd -D -f ./service/lighttpd-cgi.conf
+
+lighttpd-fcgi:
+       lighttpd -D -f ./service/lighttpd-fcgi.conf
+
+cgi fcgi:
+       ./gorillanest -$@
+
+run: fcgi
diff --git a/README b/README
index 299885504d94205569f809763e63321dc8062447..bcf8c69c9583add913dbc678e6b67e00febdbf93 100644 (file)
--- a/README
+++ b/README
@@ -57,4 +57,15 @@ Gitea broke so I had a low wage hungarian programmer write this.
 
 Everything runs from this directory via './gorillanest'.
 
-gorillanest will provide GIT & HTTP access for all repos in /public/ unconditionally, and /private/ for authorized connections.
+---
+
+./git               -- Root (~$user/$repository)
+./marketing         -- Useless Trash
+./perl              -- Perl Source
+./service           -- lighttpd, nginx, and other service files
+./static            -- Static Served Files
+./template          -- Perl Templates
+./config.default.pl -- default configuration, don't edit this, copy it to ./config.pl
+./config.pl         -- (nonexistant) configuration overrides against ./config.default.pl
+./gorillanest       -- Runscript
+./Makefile          -- Anon's autism for starting webserver
diff --git a/gorillanest b/gorillanest
new file mode 100755 (executable)
index 0000000..5873153
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+cd "$(dirname "$(readlink -f "$0")")"
+
+CGI='./perl/cgi.pl'
+FCGI='./perl/fcgi.pl'
+
+run=$FCGI
+
+while [ ! -z $1 ]; do
+    if [ $1 = '-cgi' ]; then
+        run=$CGI
+    elif [ $1 = '-fcgi' ]; then
+        run=$FCGI
+    else break; fi
+    shift
+done
+
+$run $@
+
+# I'm a fan for linguistic redundancy in software
+# This is technically a mental disorder
diff --git a/gorillanest.pl.cgi b/gorillanest.pl.cgi
deleted file mode 100755 (executable)
index cebe11b..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env perl
-
-# XXX
-# why are we passing around root like a cheap whore?                            because root is where things are (f(x) -> y)
-# looking into it, i think we should have a global config object using
-# https://metacpan.org/pod/Readonly                                             fuck read only, constants are for faggots
-#
-# i modified the routing heavily, this is how people do it;                     very scary
-# pretty clean
-# you must also realize that not all routes are necessarily templates,          then they are routed by nginx.
-# it could be a redirect for example, so the original solution would
-# complicate beyond comprehension                                               ACK.
-
-use strict;
-use warnings;
-use CGI;
-use Template;
-use URI::Escape;
-use Cwd;
-use Data::Dumper;
-use Git::Repository;
-
-use lib '.';
-BEGIN { require 'config.default.pl'; }
-BEGIN { require 'config.pl'; }
-
-sub info {
-    warn join(' ', @_);
-}
-
-
-sub serve_template {
-    my $template = Template->new({INCLUDE_PATH => 'template'});
-    my ($template_name, $data) = @_;
-
-    $template->process($template_name, $data)
-        or info("Template: " . $template->error());
-}
-
-# significant dirs only
-sub GN::directories {
-    my $root = $_[0];
-    opendir my $dir, $root or die "$root: $!";
-    my @directories;
-    my %drop = (
-        '.'  => 0,
-        '..' => 0,
-        );
-    foreach (readdir $dir) {
-        push(@directories, $_) if (-d join('/', $_[0], $_) && ($drop{$_} // 1));
-    }
-    closedir $dir;
-    return \@directories;
-}
-
-# probably should output all repos recursively, currently just outputs list of users
-sub GN::index { # /
-    my ($root) = @_;
-    my %data;
-
-    my @directories = map { my $i = $_; map { join('/', $i, $_) } @{GN::directories(join('/', $root, $i))} } @{GN::directories($root)};
-    $data{directories} = \@directories;
-    if ($data{directories}) { $data{found} = 1; }
-
-    serve_template("index.tt", \%data);
-}
-
-sub GN::user { # /$username/
-    my ($root, $username) = @_;
-
-    my %data;
-    my @directories = @{GN::directories(join('/', $root, $data{username}))};
-    $data{directories} = \@directories;
-    if ($data{directories}) { $data{found} = 1; }
-
-    serve_template("index_user.tt", \%data);
-}
-
-sub GN::repository { # /$username/$repository
-    my ($root, $username, $repository) = @_;
-
-    die 'not implemented';
-}
-
-my $root = GIT_ROOT;
-my $dbfile = DB_FILE;
-
-my %data = (
-    found => 0,
-);
-
-my %routes = (
-    '/'                   => sub { GN::index($root); },
-    '/~([\w.]+)'          => sub { GN::user($root, @_) },
-    '/~([\w.]+)/([\w.]+)' => sub { GN::repository($root, @_) },
-);
-my %route_regex_cache = map { $_ => qr{^$_$} } keys %routes;
-
-sub master {
-       my $cgi = CGI->new;
-       my %header = (
-               -Content_Type => 'text/html',
-               -charset      => 'UTF-8',
-               );
-       my $method = $ENV{'REQUEST_METHOD'} || '';
-       my $uri = $ENV{'REQUEST_URI'} || '/';
-
-       for my $pattern (keys %routes) {
-               if ($uri =~ $route_regex_cache{$pattern}) {
-                       my $handler = $routes{$pattern};
-                       $handler->($uri, $1, $2, $3);
-            return;
-               }
-       }
-
-       serve_template("404.tt", {}); # XXX missing code
-}
-
-master() if !caller;
-
-1;
diff --git a/gorillanest.pl.fcgi b/gorillanest.pl.fcgi
deleted file mode 100755 (executable)
index afba9be..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-
-use Syntax::Keyword::Try;
-use FCGI;
-
-use lib '.';
-BEGIN { require 'gorillanest.pl.cgi'; }
-
-while (1) {
-    try {
-        open STDERR, '>', LOG_FILE or die LOG_FILE . ": $!";
-        my $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, BARE_REQUEST ? 0 : FCGI::OpenSocket(SOCKET_FILE, SOCKET_MAX_CONNECTIONS));
-        while($request->Accept() >= 0) {
-            master();
-        }
-    } catch ($error) {
-        info("Crashed: $error");
-    }
-    exit 1 unless (IMMORTAL);
-}
diff --git a/perl/cgi.pl b/perl/cgi.pl
new file mode 100755 (executable)
index 0000000..3cbed42
--- /dev/null
@@ -0,0 +1,121 @@
+#!/usr/bin/env perl
+
+# XXX
+# why are we passing around root like a cheap whore?                            because root is where things are (f(x) -> y)
+# looking into it, i think we should have a global config object using
+# https://metacpan.org/pod/Readonly                                             fuck read only, constants are for faggots
+#
+# i modified the routing heavily, this is how people do it;                     very scary
+# pretty clean
+# you must also realize that not all routes are necessarily templates,          then they are routed by nginx.
+# it could be a redirect for example, so the original solution would
+# complicate beyond comprehension                                               ACK.
+
+use strict;
+use warnings;
+use CGI;
+use Template;
+use URI::Escape;
+use Cwd;
+use Data::Dumper;
+use Git::Repository;
+
+use lib qw(. ..);
+BEGIN { require 'config.default.pl'; }
+BEGIN { require 'config.pl'; }
+
+sub info {
+    warn join(' ', @_);
+}
+
+
+sub serve_template {
+    my $template = Template->new({INCLUDE_PATH => 'template'});
+    my ($template_name, $data) = @_;
+
+    $template->process($template_name, $data)
+        or info("Template: " . $template->error());
+}
+
+# significant dirs only
+sub GN::directories {
+    my $root = $_[0];
+    opendir my $dir, $root or die "$root: $!";
+    my @directories;
+    my %drop = (
+        '.'  => 0,
+        '..' => 0,
+        );
+    foreach (readdir $dir) {
+        push(@directories, $_) if (-d join('/', $_[0], $_) && ($drop{$_} // 1));
+    }
+    closedir $dir;
+    return \@directories;
+}
+
+# probably should output all repos recursively, currently just outputs list of users
+sub GN::index { # /
+    my ($root) = @_;
+    my %data;
+
+    my @directories = map { my $i = $_; map { join('/', $i, $_) } @{GN::directories(join('/', $root, $i))} } @{GN::directories($root)};
+    $data{directories} = \@directories;
+    if ($data{directories}) { $data{found} = 1; }
+
+    serve_template("index.tt", \%data);
+}
+
+sub GN::user { # /$username/
+    my ($root, $username) = @_;
+
+    my %data;
+    my @directories = @{GN::directories(join('/', $root, $data{username}))};
+    $data{directories} = \@directories;
+    if ($data{directories}) { $data{found} = 1; }
+
+    serve_template("index_user.tt", \%data);
+}
+
+sub GN::repository { # /$username/$repository
+    my ($root, $username, $repository) = @_;
+
+    die 'not implemented';
+}
+
+my $root = GIT_ROOT;
+my $dbfile = DB_FILE;
+
+my %data = (
+    found => 0,
+);
+
+my %routes = (
+    '/'                   => sub { GN::index($root); },
+    '/~([\w.]+)'          => sub { GN::user($root, @_) },
+    '/~([\w.]+)/([\w.]+)' => sub { GN::repository($root, @_) },
+);
+my %route_regex_cache = map { $_ => qr{^$_$} } keys %routes;
+
+sub master {
+       my $cgi = CGI->new;
+       my %header = (
+               -Content_Type => 'text/html',
+               -charset      => 'UTF-8',
+               );
+       my $method = $ENV{'REQUEST_METHOD'} || '';
+       my $uri = $ENV{'REQUEST_URI'} || '/';
+
+       for my $pattern (keys %routes) {
+               if ($uri =~ $route_regex_cache{$pattern}) {
+                       my $handler = $routes{$pattern};
+                       $handler->($uri, $1, $2, $3);
+            return;
+               }
+       }
+
+       serve_template("404.tt", {}); # XXX missing code
+}
+
+master() if !caller;
+
+1;
diff --git a/perl/fcgi.pl b/perl/fcgi.pl
new file mode 100755 (executable)
index 0000000..0f3dff8
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Syntax::Keyword::Try;
+use FCGI;
+
+use lib qw(perl);
+BEGIN { require 'cgi.pl'; }
+
+while (1) {
+    try {
+        open STDERR, '>', LOG_FILE or die LOG_FILE . ": $!";
+        my $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, BARE_REQUEST ? 0 : FCGI::OpenSocket(SOCKET_FILE, SOCKET_MAX_CONNECTIONS));
+        while($request->Accept() >= 0) {
+            master();
+        }
+    } catch ($error) {
+        info("Crashed: $error");
+    }
+    exit 1 unless (IMMORTAL);
+}
index 24df494bb2f9a4bf8bcb5e767badfc1ba3691f6c..6dd7d764de1bbd81c7147a7219875d54e87b3d98 100644 (file)
@@ -8,7 +8,7 @@ server.document-root = var.CWD
 server.port = 5050
 
 url.rewrite-once = (
-    "/" => "/gorillanest.pl.cgi"
+    "/" => "/perl/cgi.pl"
 )
 
 setenv.add-environment = (
@@ -16,5 +16,5 @@ setenv.add-environment = (
 )
 
 cgi.assign = (
-    ".pl.cgi" => "/usr/bin/perl"
+    ".pl" => "/usr/bin/perl"
 )
index a9cbb25d5dab07a503f512394c7f001c12b6eeb2..c5b9fbac0283929009f1b82fc858e2ba5b8f5a60 100644 (file)
@@ -17,7 +17,7 @@ setenv.add-environment = (
 
 fastcgi.server = (
     "/gorillanest" => ((
-        "bin-path" => "gorillanest.pl.fcgi",
+        "bin-path" => "perl/fcgi.pl",
         "socket"   => "gorillanest.sock",
     ))
 )