From 58d3863209a27d9526e3776ed3240daa90d33a50 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Fri, 6 Nov 2015 02:44:47 +0000 Subject: [PATCH 01/28] Added blog post on Let's Encrypt, changed bash env requirement to just sh in new-post script. --- posts/20151106.onencryption.md | 100 +++++++++++++++++++++++++++++++++ scripts/new-post | 2 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 posts/20151106.onencryption.md diff --git a/posts/20151106.onencryption.md b/posts/20151106.onencryption.md new file mode 100644 index 0000000..1b40f49 --- /dev/null +++ b/posts/20151106.onencryption.md @@ -0,0 +1,100 @@ +--- +title: On encryption and jails +date: 2015-11-06 00:51 +tags: encryption,tls,freebsd,jails,ezjail +--- + +It was [reported recently][1] that [Let's Encrypt][2] had recently launched their private beta. As someone who does their best to ensure encryption is as widely-available as possible, I was excited. + +Yesterday, I got my email stating that the domain maff.scot had been whitelisted for issuance using the [letsencrypt][3] utility. Awesome! Let's see how you get it set up. To the best of my knowledge, there was no FreeBSD port or package for the utility, which meant I had to `git clone` their repo and set things up. +Depending on how your system's set up, this might be a breeze, or it might be a challenge. + +A few things to note, going in: + +* FreeBSD by default ships with `csh` as the default shell, and no `sudo`. +* I very strongly embraced the BSD way of doing things, so that was still the case. +* The `letsencrypt` utility has some questionable defaults, in that it will attempt to run its own server temporarily for use in verifying ownership of your domain. It can also futz with your Apache/nginx config files. +* It doesn't take into account what platform it's running on, and as such, flies in the face of the FreeBSD filesystem hierarchy, documented in `hier(7)`, defaulting to `/etc/letsencrypt` for configuration and storage, and `/var/lib/letsencrypt` for its working directory. +* The [documentation][4] was a bit confusing on what I actually had to do to get things up and running in the event that a binary package was not available. + +With all these in mind, I felt it might be prudent to just set it all up inside a FreeBSD Jail. This would allow all dependencies to be satisifed from the `letsencrypt` client's point of view, and would allow it to place files where it pleased, without making a mess of my main server. + +### Preparing to run Jails + +I already had a jail system set up on my server, but I'll document the process here anyway. To simplify things, I used the EzJail system to get everything set up for me, and did final configuration and such using a `flavour`. + +To start off, I ran `pkg install ezjail` to install ezjail. While the package itself is called "ezjail", the utility used to actually work with it is `ezjail-admin`. + +After installing the package, the "base system", what all jails will draw from, must be installed. This can be compiled from source, but if you're running a RELEASE version of FreeBSD, it's perfectly fine (and easier) to simply use the same distribution bundles that you installed your host FreeBSD system from. To install the base system, just run `ezjail-admin install`, adding `-m` and `-p` to include man pages and the ports tree, respectively. This will download the FreeBSD base and userland, manpages (if desired), and will invoke `portsnap` to download the ports tree, and install it all to `/usr/jails/basejail`, by default. + +After this, I set up my `flavour` for the jails I'd be running. A flavour is a set of files and configuration options that will be added to a jail you're creating, and allows for decent customisation; specific flavours can have certain packages preinstalled, services pre-enabled or pre-configured. I just set up a default flavour, which disabled services like `sendmail`, and pre-populated `/etc/resolv.conf`. This can be easily done by copying the example flavour bundled with ezjail, and editing the name and files where appropriate. + +Since the machine I'm running on only has one IPv4 address, I needed to NAT traffic from my jails, by adding the following rules to my `pf.conf`: + +``` +jails="10.0.1.0/24" +wan="re0" +wan_ip="0.0.0.0" # replaced with your real IP, obviously + +nat pass on $wan from $jails to any -> $wan_ip +pass in from $jails to $jails # to allow inter-jail traffic +``` + +It's also a good idea to give jails their own loopback interface, separate from the host's, by adding `cloned_interfaces="lo1"` to your `rc.conf`, and restart networking. + +### Setting up the Let's Encrypt jail + +Now, finally, we're ready to create the jail itself, by running `ezjail-admin create -f yourflavour letsencrypt 're0|10.0.1.10,lo1|127.0.1.10'`, which will create a jail named 'letsencrypt' using the flavour 'yourflavour', and will give it a private IP of 10.0.1.10 and a loopback IP of 127.0.1.10. These IPs haven't been pre-configured on your machine, but will be added on-the-fly when the jail is started; hence why the interface names `re0` and `lo1` are specified. + +I then ran `ezjail-admin start letsencrypt` to actually start the jail. At this point, you may receive a warning about using `jail.conf` instead of `JAIL_` variables if you're running FreeBSD 10; this is a fault in ezjail, but has no impact on the operation of the actual jail, as it's converted on-the-fly. + +Now you're able to enter into the jail using `ezjail-admin console letsencrypt`, but before doing that, we need to install packages for the jail. To prepare it for running `letsencrypt`, install base dependencies using `pkg -j letsencrypt install pkg git sudo bash` on the host. This will install git and pkg inside the jail, so that `letsencrypt-auto` can install all packages it needs to operate. It will also install bash, necessary for running `letsencrypt-auto`, and sudo, necessary because `letsencrypt` expects to be run as an unprivileged user with sudo access. + +### Entering the jail, installing Let's Encrypt + +Now we can enter the jail with `ezjail-admin console letsencrypt`. This'll give you a root shell inside your jail, from which we can create our unprivileged user with `pw user add -n leuser -m -s /usr/local/bin/bash -G wheel`, followed by `passwd leuser` to set the password you'll enter when sudo prompts for one. Then, set up sudo by running `visudo` and adding `%wheel ALL=(ALL) ALL`. You'll also need to run `mkdir -p /etc/letsencrypt/www` to create the directory which will be used for proving to the Let's Encrypt systems that you own the domain you're requesting a certificate for. + +Drop down to the unprivileged user with `su - leuser`, which gives us a clean login environment as the user, then pull down the Let's Encrypt client with `git clone https://github.com/letsencrypt/letsencrypt`, and cd into the directory. From here, just run `./letsencrypt-auto`, which will install all necessary packages, python modules, and finally sort out the `letsencrypt` binary itself. + +The documentation then dictates that you swap out all instances of the `letsencrypt` command with `./letsencrypt-auto`, but this isn't necessary every time, as `letsencrypt-auto` will check each and every time for updates to packages and python modules before actually doing anything, which can be very irritating to wait on. After running it once, you can simply make a symbolic link to the actual `letsencrypt` program by running `ln -s $HOME/.local/share/letsencrypt/bin/letsencrypt $HOME/letsenc`. From then on, you can simply run `sudo ./letsenc ...` from the unprivileged user's home directory. + +### Getting the host system ready for Let's Encrypt + +As I mentioned, I wasn't comfortable with letting the `letsencrypt` client run its own server for domain validation. Thankfully, an alternate authentication method was made available to me: webroot. Using this, the `letsencrypt` client will simply create a file in the webroot directory, which will then be requested by the validation service, at `http://your-domain/.well-known/acme/`. It will also expect the webroot path to remain the same, irrespective of whether you're requesting a certificate for multiple domains. + +Thankfully, since I know it expects the file to be served at `/.well-known/acme/`, and I run nginx, I was able to set up a redirect across all vhosts in the same manner that a standard 404 page is served in nginx: Adding a root `location` directive, beneath nginx's standard `location 403.html, 404.html, 50x.html` directive. + +``` +location ~^/\.well-known\/acme-challenge\/.*$ { + root /usr/local/www/jail_symlinks/letsencrypt; +} +``` + +Followed by creating the symbolic link nginx would look for, via `ln -s /usr/jails/letsencrypt/etc/letsencrypt/www /usr/local/www/jail_symlinks/letsencrypt`. As I was using jails for serving web applications, I had a separate folder specifically for access to jails, but you can change this to any path you desire, of course. + +### Using Let's Encrypt to get a certificate + +Now that all setup is out of the way, we can finally get our certificate. To do this, I ran `sudo ./letsenc --agree-dev-preview --server https://acme-v01.api.letsencrypt.org/directory certonly -a webroot --webroot-path /etc/letsencrypt/www`. This presented me with a few dialogs, prompting me for an email address and list of domains to request certificates for. Once this was done, it performed validation that I owned the domains in question. This succeeded, and the certificates were issued and stored into `/etc/letsencrypt/live`. From here, you can simply use symlinks to provide nginx with your `fullchain.pem` and `privkey.pem` files, which contain the certificate and chain, and private key, respectively. + +At this point, I've successfully got Let's Encrypt set-up, and a certificate issued. After adding `ssl_certificate /path/to/fullchain.pem` and `ssl_certificate_key /path/to/privkey.pem` to my site's `server` block in nginx, I was up and running. You can also use the `chain.pem` file provided by `letsencrypt` to easily set up OCSP stapling. After doing this, your `server` block should contain something like the following (providing you also run `ln -s /usr/jails/letsencrypt/etc/letsencrypt/live /etc/ssl/letsencrypt`): + +``` +ssl_certificate /etc/ssl/letsencrypt/maff.scot/fullchain.pem; +ssl_certificate_key /etc/ssl/letsencrypt/maff.scot/privkey.pem; +ssl_trusted_certificate /etc/ssl/letsencrypt/maff.scot/chain.pem; +ssl_stapling on; +ssl_stapling_verify on; +resolver 8.8.8.8 valid=300; +resolver_timeout 10s; +``` + +### A few notes on the resulting setup + +Having gone through all this, setting up new domains with a Let's Encrypt certificate should be quite painless, as is renewing certificates. Let's Encrypt issues certificates with a 90-day validity period, and they recommend renewing within 60 days of issuing, such that if something goes wrong, you have a month's time to notice and fix it. + +While looking at how renewal works, I noticed there was a `letsencrypt-renewer` program included with `letsencrypt`. I'm not sure if this is fully-functioning as of yet, as the documentation states that an automated renewal system is not yet in-place. + +[1]: https://www.eff.org/deeplinks/2015/10/lets-encrypt-enters-private-beta +[2]: https://letsencrypt.org +[3]: https://github.com/letsencrypt/letsencrypt +[4]: http://letsencrypt.readthedocs.com/en/stable/using.html \ No newline at end of file diff --git a/scripts/new-post b/scripts/new-post index 89a16ec..2ec36ea 100755 --- a/scripts/new-post +++ b/scripts/new-post @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh read -ep 'Title of new post: ' TITLE read -ep 'Tags for new post, comma-separated: ' TAGS DATE=`date '+%Y-%m-%d %H:%M'` From bb1887dd9326527453b6c4474c3a4fe50a6f8d46 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Fri, 6 Nov 2015 02:50:54 +0000 Subject: [PATCH 02/28] It's readthedocs.org, not .com. --- posts/20151106.onencryption.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posts/20151106.onencryption.md b/posts/20151106.onencryption.md index 1b40f49..fa27860 100644 --- a/posts/20151106.onencryption.md +++ b/posts/20151106.onencryption.md @@ -97,4 +97,4 @@ While looking at how renewal works, I noticed there was a `letsencrypt-renewer` [1]: https://www.eff.org/deeplinks/2015/10/lets-encrypt-enters-private-beta [2]: https://letsencrypt.org [3]: https://github.com/letsencrypt/letsencrypt -[4]: http://letsencrypt.readthedocs.com/en/stable/using.html \ No newline at end of file +[4]: http://letsencrypt.readthedocs.org/en/stable/using.html \ No newline at end of file From b196675924c7a51146910c1f7647f26dc3142afe Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Fri, 6 Nov 2015 16:31:38 +0000 Subject: [PATCH 03/28] Fixed a really stupid bug that resulted in blogalba's internal number of posts (and as a result, all pagination) would grow exponentially over time. --- blogalba | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blogalba b/blogalba index 109d9af..0c854b1 100755 --- a/blogalba +++ b/blogalba @@ -154,7 +154,7 @@ sub generate_feed { sub do_cache { return if $lastcache > (time - 3600); $lastcache = time;my $st=[gettimeofday]; - undef @posts;undef @pages; + undef @posts;undef @pages;$nposts=0; opendir POSTS, "$basedir/posts/" or die "Couldn't open posts directory $basedir/posts/"; while(readdir POSTS) { next unless /\.md$/; From 973a18ebdf719d18855cbc0fc950bc9943f3f756 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Fri, 6 Nov 2015 16:40:44 +0000 Subject: [PATCH 04/28] updated the startup script because it was outdated and not what I was using --- scripts/start | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/start b/scripts/start index 9810f85..aaa3372 100755 --- a/scripts/start +++ b/scripts/start @@ -1,3 +1,19 @@ -#!/usr/bin/env sh +#!/bin/tcsh +#p5env setup +if ! $?PATH setenv PATH ''; +if "${PATH}" != '' setenv PATH "/usr/home/sites/perl5/bin:${PATH}"; +if "${PATH}" == '' setenv PATH "/usr/home/sites/perl5/bin"; +if ! $?PERL5LIB setenv PERL5LIB ''; +if "${PERL5LIB}" != '' setenv PERL5LIB "/usr/home/sites/perl5/lib/perl5:${PERL5LIB}"; +if "${PERL5LIB}" == '' setenv PERL5LIB "/usr/home/sites/perl5/lib/perl5"; +if ! $?PERL_LOCAL_LIB_ROOT setenv PERL_LOCAL_LIB_ROOT ''; +if "${PERL_LOCAL_LIB_ROOT}" != '' setenv PERL_LOCAL_LIB_ROOT "/usr/home/sites/perl5:${PERL_LOCAL_LIB_ROOT}"; +if "${PERL_LOCAL_LIB_ROOT}" == '' setenv PERL_LOCAL_LIB_ROOT "/usr/home/sites/perl5"; +if ! $?PERL_MB_OPT setenv PERL_MB_OPT ''; +setenv PERL_MB_OPT "--install_base "\""/usr/home/sites/perl5"\"""; +if ! $?PERL_MM_OPT setenv PERL_MM_OPT ''; +setenv PERL_MM_OPT "INSTALL_BASE=/usr/home/sites/perl5"; + pkill -F /home/sites/blogalba.pid 2>/dev/null -BLOGALBA_DIR="/home/sites/blogalba/" plackup -s Starman -D -p 42069 /home/sites/blogalba/blogalba --pid /home/sites/blogalba.pid +setenv BLOGALBA_DIR "/home/sites/blogalba/" +plackup -s Starman -D -p 42069 /home/sites/blogalba/blogalba --pid /home/sites/blogalba.pid --workers 1 From 9b88fc2cbf67f67caa8f6d17a7ed70c9a6704659 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Sun, 15 Nov 2015 21:34:13 +0000 Subject: [PATCH 05/28] Edited some pages and posts to reflect the new github username --- config | 2 +- layout/foot.inc | 2 +- pages/about.md | 8 ++++---- posts/20150310.newsitefantasticallyperlybecausewhynot.md | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config b/config index 6d4b3b5..985d588 100644 --- a/config +++ b/config @@ -15,4 +15,4 @@ config: date_format: "%H:%M on %A, %d/%m/%y" links: Twitter: https://twitter.com/maffsie - Github: https://github.com/MaffC + Github: https://github.com/Maffsie diff --git a/layout/foot.inc b/layout/foot.inc index 7754eba..bb67dab 100644 --- a/layout/foot.inc +++ b/layout/foot.inc @@ -7,7 +7,7 @@ diff --git a/pages/about.md b/pages/about.md index fbe27f8..d7fc7b3 100644 --- a/pages/about.md +++ b/pages/about.md @@ -17,11 +17,11 @@ Contact information: - irc: Maff @ [Freenode][7] and [EntropyNet][8] [1]: https://www.ipxcore.com/ -[2]: https://github.com/MaffC/ +[2]: https://github.com/Maffsie/ [3]: http://munin-monitoring.org/ -[4]: https://github.com/MaffC/openwrt-munin-node/ -[5]: https://github.com/MaffC/ayudante-lobo/ -[6]: https://github.com/MaffC/BlogAlba/ +[4]: https://github.com/Maffsie/openwrt-munin-node/ +[5]: https://github.com/Maffsie/ayudante-lobo/ +[6]: https://github.com/Maffsie/BlogAlba/ [7]: https://freenode.net/ [8]: https://entropynet.net/ [9]: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7B8A457D282B7CB6 diff --git a/posts/20150310.newsitefantasticallyperlybecausewhynot.md b/posts/20150310.newsitefantasticallyperlybecausewhynot.md index 57a4145..9766026 100644 --- a/posts/20150310.newsitefantasticallyperlybecausewhynot.md +++ b/posts/20150310.newsitefantasticallyperlybecausewhynot.md @@ -16,7 +16,7 @@ Hopefully now that it's a lot easier for me to write up posts, and everything's [1]: http://gandi.net/ [2]: https://daringfireball.net/projects/markdown/syntax -[3]: https://github.com/MaffC/BlogAlba/ +[3]: https://github.com/Maffsie/BlogAlba/ [4]: http://getbootstrap.com/ [5]: http://www.bootply.com/69873 [6]: http://bootstrapzero.com/bootstrap-template/flathood From f3d9040c5ec53150ea205c4c9363398d6118d7ba Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Sun, 15 Nov 2015 22:23:12 +0000 Subject: [PATCH 06/28] moderate refactor, switched out in-app YAML handling for dancer2's own config because really why was i doing it myself. also made it a "proper" app --- app.psgi | 9 +++++ config | 18 --------- config.yml | 29 ++++++++++++++ cpanfile | 10 +++++ blogalba => lib/App/BlogAlba.pm | 69 ++++++++++++++------------------- 5 files changed, 78 insertions(+), 57 deletions(-) create mode 100644 app.psgi delete mode 100644 config create mode 100644 config.yml create mode 100644 cpanfile rename blogalba => lib/App/BlogAlba.pm (71%) mode change 100755 => 100644 diff --git a/app.psgi b/app.psgi new file mode 100644 index 0000000..6e04368 --- /dev/null +++ b/app.psgi @@ -0,0 +1,9 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use FindBin; +use lib "$FindBin::Bin/../lib"; + +use App::BlogAlba; + +App::BlogAlba->start; diff --git a/config b/config deleted file mode 100644 index 985d588..0000000 --- a/config +++ /dev/null @@ -1,18 +0,0 @@ -# vim: set syntax=yaml : -url: https://maff.scot/ -name: colourful words and phrases -tagline: techy tangents and general life chatter from a tired sysadmin. -author: Maff -about: A dorky dude who spends too much time with perl. -keywords: sysadmin,unix,bsd,freebsd,linux,software,web,developer,perl,bash,shell,gentoo,maff,matthew,connelly,dundee,scotland,furry,blog -posturlprepend: wrote/ -config: - indexable: 1 - per_page: 6 - recent_posts: 8 - rss_publish: 1 - rss_excerpt: 1 - date_format: "%H:%M on %A, %d/%m/%y" -links: - Twitter: https://twitter.com/maffsie - Github: https://github.com/Maffsie diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..0d02948 --- /dev/null +++ b/config.yml @@ -0,0 +1,29 @@ +appname: "BlogAlba" +charset: "UTF-8" +tz: "Europe/London" +locale: "en_GB" + +logger: "console" +log: "debug" + +# Uncomment for debugging +#show_errors: 1 + +#Blog configuration +url: https://maff.scot/ +name: colourful words and phrases +tagline: techy tangents and general life chatter from a tired sysadmin. +author: Maff +about: A dorky dude who spends too much time with perl. +keywords: "sysadmin,unix,bsd,freebsd,linux,software,web,developer,perl,bash,shell,gentoo,maff,matthew,connelly,dundee,scotland,furry,blog" +posturlprepend: wrote/ +conf: + indexable: 1 + per_page: 6 + recent_posts: 8 + rss_publish: 1 + rss_excerpt: 1 + date_format: "%H:%M on %A, %d/%m/%y" +links: + Twitter: https://twitter.com/maffsie + Github: https://github.com/Maffsie diff --git a/cpanfile b/cpanfile new file mode 100644 index 0000000..697b2e8 --- /dev/null +++ b/cpanfile @@ -0,0 +1,10 @@ +requires 'HTML::Template'; +requires 'Text::Markdown::Hoedown'; +requires 'XML::RSS'; + +requires 'Unicode::Normalise'; + +requires 'Date::Parse'; +requires 'Time::HiRes'; + +requires 'Dancer2'; \ No newline at end of file diff --git a/blogalba b/lib/App/BlogAlba.pm old mode 100755 new mode 100644 similarity index 71% rename from blogalba rename to lib/App/BlogAlba.pm index 0c854b1..f605d9f --- a/blogalba +++ b/lib/App/BlogAlba.pm @@ -1,6 +1,3 @@ -#!/usr/bin/env perl -# BlogAlba - no-frills markdown blogging system - package App::BlogAlba; use strict; @@ -9,7 +6,6 @@ use warnings; use Cwd; use HTML::Template; use Text::Markdown::Hoedown; -use YAML; use POSIX qw/strftime/; use Date::Parse qw/str2time/; #Required for converting the date field in posts to something strftime can work with @@ -22,9 +18,7 @@ use Dancer2; my $HOST = `hostname -s`; chomp $HOST; my $basedir=$ENV{BLOGALBA_DIR} || cwd(); -my $cfg="$basedir/config"; -my $blog=YAML::LoadFile($cfg) or die "Couldn't load $cfg!"; -$blog->{url} .= '/' unless $blog->{url} =~ /\/$/; +config->{url} .= '/' unless config->{url} =~ /\/$/; my ($page,@posts,@pages,%defparams); my $nposts=0;my $npages=1;my $lastcache=0; @@ -62,7 +56,7 @@ sub readpost { $postm{time} = str2time($postm{date}); $postm{fancy} = timefmt($postm{time},'fancydate'); $postm{datetime} = timefmt($postm{date},'datetime'); - $postm{permaurl} = $blog->{url}.$blog->{posturlprepend}.timefmt($postm{time},'permalink').$postm{slug}; + $postm{permaurl} = config->{url}.config->{posturlprepend}.timefmt($postm{time},'permalink').$postm{slug}; } push @posts,{%postm} if $psh==1; push @pages,{%postm} if $psh==2;return %postm; } @@ -84,23 +78,23 @@ sub timefmt { return strftime "%Y-%m",localtime $epoch if $context eq 'writepost'; return strftime "%Y/%m/",localtime $epoch if $context eq 'permalink'; return strftime $context, localtime $epoch if $context; - return strftime $blog->{config}->{date_format},localtime $epoch; + return strftime config->{conf}->{date_format},localtime $epoch; } sub pagination_calc { - my $rem=$nposts % $blog->{config}->{per_page}; - $npages=($nposts-$rem)/$blog->{config}->{per_page}; + my $rem=$nposts % config->{conf}->{per_page}; + $npages=($nposts-$rem)/config->{conf}->{per_page}; $npages++ if $rem>0 or $npages<1; } sub get_index { my @iposts = @_; - $page->param(pagetitle => $blog->{name}, INDEX => 1, POSTS => [@iposts]); + $page->param(pagetitle => config->{name}, INDEX => 1, POSTS => [@iposts]); return $page->output; } sub paginate { - my $pagenum = shift; my $offset = ($pagenum-1)*$blog->{config}->{per_page}; - my $offset_to = $offset+($blog->{config}->{per_page}-1); $offset_to = $#posts if $offset_to > $#posts; + my $pagenum = shift; my $offset = ($pagenum-1)*config->{conf}->{per_page}; + my $offset_to = $offset+(config->{conf}->{per_page}-1); $offset_to = $#posts if $offset_to > $#posts; $page->param(PAGINATED => 1, prevlink => ($pagenum>1? 1 : 0), prevpage => $pagenum-1, nextlink => ($pagenum<$npages? 1 : 0), nextpage => $pagenum+1); - return get_index @posts[$offset..(($offset+$blog->{config}->{per_page})>$#posts? $#posts : ($offset+($blog->{config}->{per_page}-1)))]; + return get_index @posts[$offset..(($offset+config->{conf}->{per_page})>$#posts? $#posts : ($offset+(config->{conf}->{per_page}-1)))]; } sub page_init { $page = HTML::Template->new(filename => "$basedir/layout/base.html",die_on_bad_params => 0,utf8 => 1,global_vars => 1); @@ -111,7 +105,7 @@ sub get_post { for my $r (@posts) { my %post = %$r; next unless $post{slug} eq $slug and timefmt($post{time},'writepost') eq "$y-$m"; - $page->param(pagetitle => "$post{title} - $blog->{name}",%post); + $page->param(pagetitle => $post{title}." - ".config->{name},%post); return 1; } return undef; @@ -121,21 +115,21 @@ sub get_page { for my $r (@pages) { my %cpage = %$r; next unless $cpage{filename} eq $pname; - $page->param(pagetitle => "$cpage{title} - $blog->{name}",%cpage); + $page->param(pagetitle => $cpage{title}" - ".config->{name},%cpage); return 1; } return undef; } sub generate_feed { - return unless $blog->{config}->{rss_publish}; + return unless config->{conf}->{rss_publish}; my $feed = new XML::RSS(version => '2.0'); $feed->channel ( - title => $blog->{name}, - link => $blog->{url}, - description => $blog->{tagline}, + title => config->{name}, + link => config->{url}, + description => config->{tagline}, dc => { - creator => $blog->{author}, - language => "en-gb", + creator => config->{author}, + language => config->{locale}, }, syn => { updatePeriod => "daily", @@ -146,9 +140,9 @@ sub generate_feed { $feed->add_item ( title => $_->{title}, link => $_->{permaurl}, - description => ($blog->{config}->{rss_excerpt}? $_->{excerpt} : $_->{body}), - dc => { creator => $blog->{author}, }, - ) for @posts[0 .. ($#posts > ($blog->{config}->{recent_posts}-1)? ($blog->{config}->{recent_posts}-1) : $#posts)]; + description => (config->{conf}->{rss_excerpt}? $_->{excerpt} : $_->{body}), + dc => { creator => config->{author}, }, + ) for @posts[0 .. ($#posts > (config->{conf}->{recent_posts}-1)? (config->{conf}->{recent_posts}-1) : $#posts)]; $feed->save("$basedir/public/feed-rss2.xml"); } sub do_cache { @@ -172,21 +166,18 @@ sub do_cache { closedir PAGES; my @nav; - push @nav, {navname => $_->{title}, navurl => "$blog->{url}$_->{filename}",} for @pages; - push @nav, {navname => $_, navurl => $blog->{links}->{$_},} for sort { $b cmp $a } keys $blog->{links}; + push @nav, {navname => $_->{title}, navurl => config->{url}.$_->{filename},} for @pages; + push @nav, {navname => $_, navurl => config->{links}->{$_},} for sort { $b cmp $a } keys config->{links}; generate_feed; %defparams = ( - INDEX => 0, NAV => [@nav], url => $blog->{url}, recent => [@posts[0 .. ($#posts > ($blog->{config}->{recent_posts}-1)? ($blog->{config}->{recent_posts}-1) : $#posts)]], - gentime => timefmt($lastcache, '%H:%M %e/%-m/%y %Z'), genworktime => sprintf("%.2f ms", tv_interval($st)*100), host => $HOST, rss_enabled => $blog->{rss_publish}, - about => $blog->{about}, author => $blog->{author}, name => $blog->{name}, tagline => $blog->{tagline}, keywords => $blog->{keywords}, - robots => $blog->{config}->{indexable}? '' : '', + INDEX => 0, NAV => [@nav], url => config->{url}, recent => [@posts[0 .. ($#posts > (config->{conf}->{recent_posts}-1)? (config->{conf}->{recent_posts}-1) : $#posts)]], + gentime => timefmt($lastcache, '%H:%M %e/%-m/%y %Z'), genworktime => sprintf("%.2f ms", tv_interval($st)*100), host => $HOST, rss_enabled => config->{rss_publish}, + about => config->{about}, author => config->{author}, name => config->{name}, tagline => config->{tagline}, keywords => config->{keywords}, + robots => config->{conf}->{indexable}? '' : '', ); pagination_calc; } -set server => '127.0.0.1'; -set port => 42069; - hook 'before' => sub { do_cache; page_init; @@ -216,10 +207,10 @@ get '/:extpage' => sub { return $page->output; }; # 404 -any qr{.*} => sub { +any qr/.*/ => sub { return redirect '/' if request->path =~ /index(?:\.(?:html?|pl)?)?$/; - status 'not_found'; - #return redirect '/404.html'; # this doesn't actually work, need to find a better way of 404ing using nginx's 404 page + return send_error('The page you seek cannot be found.', 404); }; -start; +1; +__END__ From 6eb967dfc0172f1c444cfe9bac3c3481208ddff7 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Sun, 15 Nov 2015 23:22:16 +0000 Subject: [PATCH 07/28] Fancy new start script that is less weird --- cpanfile | 3 ++- scripts/start | 19 ------------------- start | 12 ++++++++++++ 3 files changed, 14 insertions(+), 20 deletions(-) delete mode 100755 scripts/start create mode 100644 start diff --git a/cpanfile b/cpanfile index 697b2e8..0c9260b 100644 --- a/cpanfile +++ b/cpanfile @@ -7,4 +7,5 @@ requires 'Unicode::Normalise'; requires 'Date::Parse'; requires 'Time::HiRes'; -requires 'Dancer2'; \ No newline at end of file +requires 'Dancer2'; +requires 'Starman'; \ No newline at end of file diff --git a/scripts/start b/scripts/start deleted file mode 100755 index aaa3372..0000000 --- a/scripts/start +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/tcsh -#p5env setup -if ! $?PATH setenv PATH ''; -if "${PATH}" != '' setenv PATH "/usr/home/sites/perl5/bin:${PATH}"; -if "${PATH}" == '' setenv PATH "/usr/home/sites/perl5/bin"; -if ! $?PERL5LIB setenv PERL5LIB ''; -if "${PERL5LIB}" != '' setenv PERL5LIB "/usr/home/sites/perl5/lib/perl5:${PERL5LIB}"; -if "${PERL5LIB}" == '' setenv PERL5LIB "/usr/home/sites/perl5/lib/perl5"; -if ! $?PERL_LOCAL_LIB_ROOT setenv PERL_LOCAL_LIB_ROOT ''; -if "${PERL_LOCAL_LIB_ROOT}" != '' setenv PERL_LOCAL_LIB_ROOT "/usr/home/sites/perl5:${PERL_LOCAL_LIB_ROOT}"; -if "${PERL_LOCAL_LIB_ROOT}" == '' setenv PERL_LOCAL_LIB_ROOT "/usr/home/sites/perl5"; -if ! $?PERL_MB_OPT setenv PERL_MB_OPT ''; -setenv PERL_MB_OPT "--install_base "\""/usr/home/sites/perl5"\"""; -if ! $?PERL_MM_OPT setenv PERL_MM_OPT ''; -setenv PERL_MM_OPT "INSTALL_BASE=/usr/home/sites/perl5"; - -pkill -F /home/sites/blogalba.pid 2>/dev/null -setenv BLOGALBA_DIR "/home/sites/blogalba/" -plackup -s Starman -D -p 42069 /home/sites/blogalba/blogalba --pid /home/sites/blogalba.pid --workers 1 diff --git a/start b/start new file mode 100644 index 0000000..3338410 --- /dev/null +++ b/start @@ -0,0 +1,12 @@ +#!/bin/sh +[ -z "$BASE" ] && BASE=/usr/home/sites +#p5env setup +PATH="$BASE/perl5/bin${PATH+:}${PATH}"; export PATH; +PERL5LIB="$BASE/perl5/lib/perl5${PERL5LIB+:}${PERL5LIB}"; export PERL5LIB; +PERL_LOCAL_LIB_ROOT="$BASE/perl5${PERL_LOCAL_LIB_ROOT+:}${PERL_LOCAL_LIB_ROOT}"; export PERL_LOCAL_LIB_ROOT; +PERL_MB_OPT="--install_base \"$BASE/perl5\""; export PERL_MB_OPT; +PERL_MM_OPT="INSTALL_BASE=$BASE/perl5"; export PERL_MM_OPT; + +pkill -F $BASE/${APP}.pid 2>/dev/null +for((;;));do pkill -0 -F $BASE/${APP}.pid 2>/dev/null || break; sleep 1; done +plackup -s Starman -D -S $BASE/$APP/.sock $BASE/$APP/app.psgi --pid $BASE/${APP}.pid --workers 1 From ee204b6686de77ad273d7098800a72cff1928b3c Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Sun, 15 Nov 2015 23:32:35 +0000 Subject: [PATCH 08/28] more start script and hook refactoring --- .githooks/post-receive | 9 +++++++-- start | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.githooks/post-receive b/.githooks/post-receive index 61db082..67d0205 100755 --- a/.githooks/post-receive +++ b/.githooks/post-receive @@ -1,4 +1,9 @@ #!/bin/sh cat > /dev/null -git --git-dir /home/sites/blogalba/.git --work-tree /home/sites/blogalba pull -[ ! -z "$(find /home/sites/blogalba -type d -name .git -prune -o -type f -mmin -1 -print|egrep '(p(ost|age)s/|blogalba$)')" ] && echo "Restarting blogalba" && /home/sites/blogalba/scripts/start +BASE=/usr/home/sites; export BASE; APP=blogalba; export APP +START_OPTS="--workers 1"; export START_OPTS +cd $BASE/$APP; git pull; cd - +cd $BASE/$APP.mirror.git; git pull; git push; cd - +#git --git-dir $BASE/$APP/.git --work-tree $BASE/$APP pull +[ ! -z "$(find $BASE/$APP -type d -name .git -prune -o -type f -mmin -1 -print|egrep '(p(ost|age)s/|lib$)')" ] || exit +echo "Restarting $APP"; $BASE/$APP/start \ No newline at end of file diff --git a/start b/start index 3338410..f080ca0 100644 --- a/start +++ b/start @@ -1,5 +1,5 @@ #!/bin/sh -[ -z "$BASE" ] && BASE=/usr/home/sites +[ -z "$BASE$APP" ] && exit 1 #p5env setup PATH="$BASE/perl5/bin${PATH+:}${PATH}"; export PATH; PERL5LIB="$BASE/perl5/lib/perl5${PERL5LIB+:}${PERL5LIB}"; export PERL5LIB; @@ -9,4 +9,4 @@ PERL_MM_OPT="INSTALL_BASE=$BASE/perl5"; export PERL_MM_OPT; pkill -F $BASE/${APP}.pid 2>/dev/null for((;;));do pkill -0 -F $BASE/${APP}.pid 2>/dev/null || break; sleep 1; done -plackup -s Starman -D -S $BASE/$APP/.sock $BASE/$APP/app.psgi --pid $BASE/${APP}.pid --workers 1 +plackup -s Starman -D -S $BASE/$APP/.sock $BASE/$APP/app.psgi --pid $BASE/${APP}.pid $START_OPTS From 52972a677fd042a114cbdb676a358c06e808c04a Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Sun, 15 Nov 2015 23:36:18 +0000 Subject: [PATCH 09/28] fix app.psgi pointing to an incorrect location for the app's lib --- app.psgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.psgi b/app.psgi index 6e04368..7ac60f5 100644 --- a/app.psgi +++ b/app.psgi @@ -2,7 +2,7 @@ use strict; use warnings; use FindBin; -use lib "$FindBin::Bin/../lib"; +use lib "$FindBin::Bin/lib"; use App::BlogAlba; From 0748405cbd48a618268eca1968c8378024a91e6c Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Sun, 15 Nov 2015 23:38:03 +0000 Subject: [PATCH 10/28] whitespace is bad --- app.psgi | 1 - 1 file changed, 1 deletion(-) diff --git a/app.psgi b/app.psgi index 7ac60f5..6e323af 100644 --- a/app.psgi +++ b/app.psgi @@ -5,5 +5,4 @@ use FindBin; use lib "$FindBin::Bin/lib"; use App::BlogAlba; - App::BlogAlba->start; From 37e695415c522b9bcb3dc1dafa241d7b778512d8 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Sun, 15 Nov 2015 23:41:26 +0000 Subject: [PATCH 11/28] fixed the use of deprecated env var BLOGALBA_DIR --- lib/App/BlogAlba.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/App/BlogAlba.pm b/lib/App/BlogAlba.pm index f605d9f..f2ac4cb 100644 --- a/lib/App/BlogAlba.pm +++ b/lib/App/BlogAlba.pm @@ -17,7 +17,7 @@ use Dancer2; my $HOST = `hostname -s`; chomp $HOST; -my $basedir=$ENV{BLOGALBA_DIR} || cwd(); +my $basedir=$ENV{BASE}."/".$ENV{APP} || cwd(); config->{url} .= '/' unless config->{url} =~ /\/$/; my ($page,@posts,@pages,%defparams); From 7fd895fe51cc3e3e73d9073c9efdebcbc9bbbda5 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Sun, 15 Nov 2015 23:49:45 +0000 Subject: [PATCH 12/28] fix dodgy post-receive hook for the umpteenth time --- .githooks/post-receive | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.githooks/post-receive b/.githooks/post-receive index 67d0205..1a690a8 100755 --- a/.githooks/post-receive +++ b/.githooks/post-receive @@ -2,8 +2,8 @@ cat > /dev/null BASE=/usr/home/sites; export BASE; APP=blogalba; export APP START_OPTS="--workers 1"; export START_OPTS -cd $BASE/$APP; git pull; cd - -cd $BASE/$APP.mirror.git; git pull; git push; cd - -#git --git-dir $BASE/$APP/.git --work-tree $BASE/$APP pull +git --git-dir $BASE/$APP/.git --work-tree $BASE/$APP pull +git --git-dir $BASE/$APP.mirror.git/.git --work-tree $BASE/$APP.mirror.git fetch +git --git-dir $BASE/$APP.mirror.git/.git --work-tree $BASE/$APP.mirror.git push [ ! -z "$(find $BASE/$APP -type d -name .git -prune -o -type f -mmin -1 -print|egrep '(p(ost|age)s/|lib$)')" ] || exit echo "Restarting $APP"; $BASE/$APP/start \ No newline at end of file From 8e1c4a8e896dcae4dab0247ad3615f8cb5a26565 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Sun, 15 Nov 2015 23:56:19 +0000 Subject: [PATCH 13/28] trying to make better use of config.yml --- config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config.yml b/config.yml index 0d02948..2bc85aa 100644 --- a/config.yml +++ b/config.yml @@ -5,6 +5,7 @@ locale: "en_GB" logger: "console" log: "debug" +startup_info: 1 # Uncomment for debugging #show_errors: 1 From 690f95944883484431b133c5f23519759e51f374 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Sun, 15 Nov 2015 23:57:22 +0000 Subject: [PATCH 14/28] .git repos do not have a working tree --- .githooks/post-receive | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.githooks/post-receive b/.githooks/post-receive index 1a690a8..6bce1b0 100755 --- a/.githooks/post-receive +++ b/.githooks/post-receive @@ -3,7 +3,7 @@ cat > /dev/null BASE=/usr/home/sites; export BASE; APP=blogalba; export APP START_OPTS="--workers 1"; export START_OPTS git --git-dir $BASE/$APP/.git --work-tree $BASE/$APP pull -git --git-dir $BASE/$APP.mirror.git/.git --work-tree $BASE/$APP.mirror.git fetch -git --git-dir $BASE/$APP.mirror.git/.git --work-tree $BASE/$APP.mirror.git push +git --git-dir $BASE/$APP.mirror.git fetch +git --git-dir $BASE/$APP.mirror.git push [ ! -z "$(find $BASE/$APP -type d -name .git -prune -o -type f -mmin -1 -print|egrep '(p(ost|age)s/|lib$)')" ] || exit echo "Restarting $APP"; $BASE/$APP/start \ No newline at end of file From 4b6a3757e3b7b4efb7e2ec1fbd38f97d8d7b8d55 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:04:25 +0000 Subject: [PATCH 15/28] comments --- lib/App/BlogAlba.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/App/BlogAlba.pm b/lib/App/BlogAlba.pm index f2ac4cb..2820129 100644 --- a/lib/App/BlogAlba.pm +++ b/lib/App/BlogAlba.pm @@ -4,6 +4,7 @@ use strict; use warnings; use Cwd; +# TODO: maybe swap this out for templating stuff through dancer, would be cleaner. use HTML::Template; use Text::Markdown::Hoedown; From 326f36778616e249aa8e37c42dc9a1d0569aaba0 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:05:39 +0000 Subject: [PATCH 16/28] remove the "start only if modified" check in post-receive hook, the times where i don't want it to restart are very few --- .githooks/post-receive | 1 - 1 file changed, 1 deletion(-) diff --git a/.githooks/post-receive b/.githooks/post-receive index 6bce1b0..f9fda83 100755 --- a/.githooks/post-receive +++ b/.githooks/post-receive @@ -5,5 +5,4 @@ START_OPTS="--workers 1"; export START_OPTS git --git-dir $BASE/$APP/.git --work-tree $BASE/$APP pull git --git-dir $BASE/$APP.mirror.git fetch git --git-dir $BASE/$APP.mirror.git push -[ ! -z "$(find $BASE/$APP -type d -name .git -prune -o -type f -mmin -1 -print|egrep '(p(ost|age)s/|lib$)')" ] || exit echo "Restarting $APP"; $BASE/$APP/start \ No newline at end of file From 3f40ada741035d600178db5d98bfa016a9f8fd6b Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:11:18 +0000 Subject: [PATCH 17/28] disambiguate the plackup command --- start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start b/start index f080ca0..e98cfd5 100644 --- a/start +++ b/start @@ -9,4 +9,4 @@ PERL_MM_OPT="INSTALL_BASE=$BASE/perl5"; export PERL_MM_OPT; pkill -F $BASE/${APP}.pid 2>/dev/null for((;;));do pkill -0 -F $BASE/${APP}.pid 2>/dev/null || break; sleep 1; done -plackup -s Starman -D -S $BASE/$APP/.sock $BASE/$APP/app.psgi --pid $BASE/${APP}.pid $START_OPTS +plackup -s Starman -D -S $BASE/$APP/.sock -a $BASE/$APP/app.psgi --pid $BASE/${APP}.pid $START_OPTS From c30af1e75f9e87944b849a2190af0c7ed3b2ef51 Mon Sep 17 00:00:00 2001 From: maff Date: Mon, 16 Nov 2015 00:12:50 +0000 Subject: [PATCH 18/28] Fix permissions on start script, oops --- start | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 start diff --git a/start b/start old mode 100644 new mode 100755 From 52d0459b2d44d4fa9815cd75b2ba3f2d52931988 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:15:28 +0000 Subject: [PATCH 19/28] my for loop sucks --- start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start b/start index e98cfd5..bad79b3 100755 --- a/start +++ b/start @@ -8,5 +8,5 @@ PERL_MB_OPT="--install_base \"$BASE/perl5\""; export PERL_MB_OPT; PERL_MM_OPT="INSTALL_BASE=$BASE/perl5"; export PERL_MM_OPT; pkill -F $BASE/${APP}.pid 2>/dev/null -for((;;));do pkill -0 -F $BASE/${APP}.pid 2>/dev/null || break; sleep 1; done +while true;do pkill -0 -F $BASE/${APP}.pid 2>/dev/null || break; sleep 1; done plackup -s Starman -D -S $BASE/$APP/.sock -a $BASE/$APP/app.psgi --pid $BASE/${APP}.pid $START_OPTS From 25e707a3f9a9284616d864a3ad12219c1a16fd3c Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:16:32 +0000 Subject: [PATCH 20/28] fixed an absent dot which broke everything --- lib/App/BlogAlba.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/App/BlogAlba.pm b/lib/App/BlogAlba.pm index 2820129..019c397 100644 --- a/lib/App/BlogAlba.pm +++ b/lib/App/BlogAlba.pm @@ -116,7 +116,7 @@ sub get_page { for my $r (@pages) { my %cpage = %$r; next unless $cpage{filename} eq $pname; - $page->param(pagetitle => $cpage{title}" - ".config->{name},%cpage); + $page->param(pagetitle => $cpage{title}." - ".config->{name},%cpage); return 1; } return undef; From d7f48af8d241b2e9f836383d157fa6dba0c47c86 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:25:28 +0000 Subject: [PATCH 21/28] mysteriously, the config is gone --- start | 1 + 1 file changed, 1 insertion(+) diff --git a/start b/start index bad79b3..d5f1097 100755 --- a/start +++ b/start @@ -9,4 +9,5 @@ PERL_MM_OPT="INSTALL_BASE=$BASE/perl5"; export PERL_MM_OPT; pkill -F $BASE/${APP}.pid 2>/dev/null while true;do pkill -0 -F $BASE/${APP}.pid 2>/dev/null || break; sleep 1; done +cd $BASE/$APP plackup -s Starman -D -S $BASE/$APP/.sock -a $BASE/$APP/app.psgi --pid $BASE/${APP}.pid $START_OPTS From 21ef050c692a65aca651d5f5453a9f90f3bcbbe4 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:34:08 +0000 Subject: [PATCH 22/28] enable logging --- config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yml b/config.yml index 2bc85aa..2d8cf0d 100644 --- a/config.yml +++ b/config.yml @@ -3,7 +3,7 @@ charset: "UTF-8" tz: "Europe/London" locale: "en_GB" -logger: "console" +logger: "file" log: "debug" startup_info: 1 From 023d0cc866488d72f5b6e866b2e6806807e2f0c6 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:36:51 +0000 Subject: [PATCH 23/28] why --- config.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/config.yml b/config.yml index 2d8cf0d..a934f49 100644 --- a/config.yml +++ b/config.yml @@ -5,19 +5,18 @@ locale: "en_GB" logger: "file" log: "debug" -startup_info: 1 # Uncomment for debugging #show_errors: 1 #Blog configuration -url: https://maff.scot/ -name: colourful words and phrases -tagline: techy tangents and general life chatter from a tired sysadmin. -author: Maff -about: A dorky dude who spends too much time with perl. +url: "https://maff.scot/" +name: "colourful words and phrases" +tagline: "techy tangents and general life chatter from a tired sysadmin." +author: "Maff" +about: "A dorky dude who spends too much time with perl." keywords: "sysadmin,unix,bsd,freebsd,linux,software,web,developer,perl,bash,shell,gentoo,maff,matthew,connelly,dundee,scotland,furry,blog" -posturlprepend: wrote/ +posturlprepend: "wrote/" conf: indexable: 1 per_page: 6 @@ -26,5 +25,5 @@ conf: rss_excerpt: 1 date_format: "%H:%M on %A, %d/%m/%y" links: - Twitter: https://twitter.com/maffsie - Github: https://github.com/Maffsie + Twitter: "https://twitter.com/maffsie" + Github: "https://github.com/Maffsie" From 54ce9f71ff15b90d569ece5eaaebf7cac2667d13 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:40:26 +0000 Subject: [PATCH 24/28] fuck it i need debugging --- config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yml b/config.yml index a934f49..7d6efe3 100644 --- a/config.yml +++ b/config.yml @@ -7,7 +7,7 @@ logger: "file" log: "debug" # Uncomment for debugging -#show_errors: 1 +show_errors: 1 #Blog configuration url: "https://maff.scot/" From abdbdfdbf309d61d8989df61fc9c1acf4b9daa4b Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:45:17 +0000 Subject: [PATCH 25/28] honestly this is gonna be the death of me --- app.psgi => bin/app.pl | 3 ++- config.yml | 20 ++++++++++---------- start | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) rename app.psgi => bin/app.pl (75%) diff --git a/app.psgi b/bin/app.pl similarity index 75% rename from app.psgi rename to bin/app.pl index 6e323af..6e04368 100644 --- a/app.psgi +++ b/bin/app.pl @@ -2,7 +2,8 @@ use strict; use warnings; use FindBin; -use lib "$FindBin::Bin/lib"; +use lib "$FindBin::Bin/../lib"; use App::BlogAlba; + App::BlogAlba->start; diff --git a/config.yml b/config.yml index 7d6efe3..0d02948 100644 --- a/config.yml +++ b/config.yml @@ -3,20 +3,20 @@ charset: "UTF-8" tz: "Europe/London" locale: "en_GB" -logger: "file" +logger: "console" log: "debug" # Uncomment for debugging -show_errors: 1 +#show_errors: 1 #Blog configuration -url: "https://maff.scot/" -name: "colourful words and phrases" -tagline: "techy tangents and general life chatter from a tired sysadmin." -author: "Maff" -about: "A dorky dude who spends too much time with perl." +url: https://maff.scot/ +name: colourful words and phrases +tagline: techy tangents and general life chatter from a tired sysadmin. +author: Maff +about: A dorky dude who spends too much time with perl. keywords: "sysadmin,unix,bsd,freebsd,linux,software,web,developer,perl,bash,shell,gentoo,maff,matthew,connelly,dundee,scotland,furry,blog" -posturlprepend: "wrote/" +posturlprepend: wrote/ conf: indexable: 1 per_page: 6 @@ -25,5 +25,5 @@ conf: rss_excerpt: 1 date_format: "%H:%M on %A, %d/%m/%y" links: - Twitter: "https://twitter.com/maffsie" - Github: "https://github.com/Maffsie" + Twitter: https://twitter.com/maffsie + Github: https://github.com/Maffsie diff --git a/start b/start index d5f1097..eb7b3be 100755 --- a/start +++ b/start @@ -10,4 +10,4 @@ PERL_MM_OPT="INSTALL_BASE=$BASE/perl5"; export PERL_MM_OPT; pkill -F $BASE/${APP}.pid 2>/dev/null while true;do pkill -0 -F $BASE/${APP}.pid 2>/dev/null || break; sleep 1; done cd $BASE/$APP -plackup -s Starman -D -S $BASE/$APP/.sock -a $BASE/$APP/app.psgi --pid $BASE/${APP}.pid $START_OPTS +plackup -s Starman -D -S $BASE/$APP/.sock $BASE/$APP/bin/app.pl --pid $BASE/${APP}.pid $START_OPTS From 11408b985839e4675a26f7113f120fa323ccac20 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Mon, 16 Nov 2015 00:54:21 +0000 Subject: [PATCH 26/28] using START_OPTS as an env var was dumb --- .githooks/post-receive | 1 - start | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.githooks/post-receive b/.githooks/post-receive index f9fda83..032232a 100755 --- a/.githooks/post-receive +++ b/.githooks/post-receive @@ -1,7 +1,6 @@ #!/bin/sh cat > /dev/null BASE=/usr/home/sites; export BASE; APP=blogalba; export APP -START_OPTS="--workers 1"; export START_OPTS git --git-dir $BASE/$APP/.git --work-tree $BASE/$APP pull git --git-dir $BASE/$APP.mirror.git fetch git --git-dir $BASE/$APP.mirror.git push diff --git a/start b/start index eb7b3be..f1e578d 100755 --- a/start +++ b/start @@ -1,4 +1,8 @@ #!/bin/sh +#Application options +START_OPTS="--workers 1" + +#Standard startup script [ -z "$BASE$APP" ] && exit 1 #p5env setup PATH="$BASE/perl5/bin${PATH+:}${PATH}"; export PATH; From 25301614cbb032c5d5df37d0cf1c8020276cb0ad Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Thu, 19 Nov 2015 18:07:04 +0000 Subject: [PATCH 27/28] pls --- posts/{post16.md => .post16.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename posts/{post16.md => .post16.md} (100%) diff --git a/posts/post16.md b/posts/.post16.md similarity index 100% rename from posts/post16.md rename to posts/.post16.md From b80397d3768cefe2cf2d410ce9b68f2b030b8b48 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Thu, 19 Nov 2015 18:27:32 +0000 Subject: [PATCH 28/28] unpublish properly --- posts/{.post16.md => .post16.md.unpublished} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename posts/{.post16.md => .post16.md.unpublished} (100%) diff --git a/posts/.post16.md b/posts/.post16.md.unpublished similarity index 100% rename from posts/.post16.md rename to posts/.post16.md.unpublished