#!/usr/bin/perl
use warnings;
use strict;
use feature qw(say);
use Cwd qw(abs_path getcwd);

safety_checks();

sub safety_checks {
    die "Refusing to run as root\n" if $< == 0 || $> == 0;

    my $required = 'rostrum_tools';
    my $cwd = abs_path(getcwd()) || getcwd();

    unless ($cwd =~ m{/\Q$required\E(/|$)}) {
        die "Script must be called from inside a directory named '$required'\n"
          . "  (current directory: $cwd)\n";
    }
}
