Browse Source

provision.pl - wget pulls in user create because vultr

master
gashapwn 3 years ago
parent
commit
e71775bf17
1 changed files with 22 additions and 24 deletions
  1. +22
    -24
      perl-script/provision.pl

+ 22
- 24
perl-script/provision.pl View File

@@ -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(<STDIN> eq "Y\n"){
die "create a non-root user & set user passsword before running this script.";
}
printf("Username: ");
$admin_un = <STDIN>;
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");

Loading…
Cancel
Save