lyadmin/perl-script/provision.pl

49 lines
1.0 KiB
Perl
Raw Normal View History

#!/usr/bin/perl
use warnings;
use strict;
# provision.pl
# script to provision a tilde instance
#
# This script is intended to be run on a fresh
# OpenBSD install
#
# gashapwn
# Nov 2020
2020-11-28 16:51:19 -05:00
my $GIT_REPO = 'https://git.lain.church/gashapwn/lyadmin.git';
my $pwuid;
my $admin_un;
2020-11-28 16:51:19 -05:00
my $admin_home_dir;
# Make sure we're running as root
$pwuid = getpwuid( $< );
if($pwuid ne "root"){
die "script must be run as root";
}
# Check /etc/passwd for the username created during
# installation
if( ($admin_un) = `tail /etc/passwd | grep -v "nobody:"` =~ /([^:\n]+):[^:]+:[0-9]{4,}/){
printf("admin user will be set to %s\n", $admin_un);
}else{
die "create a non-root user & set user passsword before running this script."
}
2020-11-28 16:51:19 -05:00
$admin_home_dir = "/home/$admin_un";
2020-11-28 15:57:25 -05:00
# grant doas access to admin user
system("echo 'permit $admin_un' > /etc/doas.conf");
2020-11-28 16:51:19 -05:00
# install git
system("pkg_add git");
2020-11-28 16:56:10 -05:00
system("pkg_add python3");
2020-11-28 16:51:19 -05:00
chdir $admin_home_dir;
system("su gashapwn -c 'git clone $GIT_REPO'");
2020-11-28 16:56:10 -05:00
system("su gashapwn -c 'python3 -m venv venv'");