From e71775bf17daaf93ae3073811950278bf3b39df7 Mon Sep 17 00:00:00 2001 From: gashapwn Date: Sun, 20 Dec 2020 07:39:34 +0000 Subject: [PATCH] provision.pl - wget pulls in user create because vultr --- perl-script/provision.pl | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/perl-script/provision.pl b/perl-script/provision.pl index 97882d7..7fa03a4 100644 --- a/perl-script/provision.pl +++ b/perl-script/provision.pl @@ -30,27 +30,12 @@ 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{ - printf("need a non-root user...\n"); - printf("want to create a user? Y/N\n"); - unless( eq "Y\n"){ - die "create a non-root user & set user passsword before running this script."; - } - printf("Username: "); - $admin_un = ; - chomp $admin_un; - `useradd -m $admin_un`; +unless( ($admin_un) = `tail /etc/passwd | grep -v "nobody:"` =~ /([^:\n]+):[^:]+:[0-9]{4,}/){ + `wget --quiet https://git.lain.church/gashapwn/lyadmin/raw/branch/master/perl-script/create_user.pl -O create_admin.pl`; + printf("run create_admin.pl to create an admin user\n"); + die "or add with useradd and add an ssh key to ~/.ssh/authorizedkeys\n"; } -$admin_home_dir = "/home/$admin_un"; - -# grant doas access to admin user -system("echo 'permit $admin_un' > /etc/doas.conf"); - # install git system("pkg_add git"); @@ -68,10 +53,17 @@ chdir $REPO_DIR; system("mkdir ./skel/public_html/cgi"); system("cp -r ./skel/* /etc/skel/"); -# setup admin user -system("cp -r ./skel/* /home/$admin_un/"); -system("chown -R $admin_un:$admin_un /home/$admin_un"); -system("echo $admin_un >> ./user_list.txt"); +# Check /etc/passwd for the username created during +# installation +if( ($admin_un) = `tail /etc/passwd | grep -v "nobody:"` =~ /([^:\n]+):[^:]+:[0-9]{4,}/){ + # grant doas access to admin user + system("echo 'permit $admin_un' > /etc/doas.conf"); + + # setup admin user + system("cp -r ./skel/* /home/$admin_un/"); + system("chown -R $admin_un:$admin_un /home/$admin_un"); + system("echo $admin_un >> ./user_list.txt"); +} # Setup the virtual environment system("pkg_add python3"); @@ -119,5 +111,11 @@ system("cp ./perl-script/conf/haproxy.cfg /etc/haproxy/haproxy.cfg"); system("rcctl enable haproxy"); system("rcctl start haproxy"); +printf("\n\nInstall complete\n"); +printf("==================================================\n"); + +printf("Protip: use doas instead of sudoo\n"); + +printf("dont forget\n\ncreate yourself an user with: useradd -m\n"); +printf("setup your ssh pub key at ~/.ssh/authorized_keys\n"); -printf("dont forget to setup your ssh pub key at /home/$admin_un/.ssh/authorized_keys\n");