scripts and tools to administer the lingy.in public unix / tilde
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
966B

  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. # provision.pl
  5. # script to provision a tilde instance
  6. #
  7. # This script is intended to be run on a fresh
  8. # OpenBSD install
  9. #
  10. # gashapwn
  11. # Nov 2020
  12. my $GIT_REPO = 'https://git.lain.church/gashapwn/lyadmin.git';
  13. my $pwuid;
  14. my $admin_un;
  15. my $admin_home_dir;
  16. # Make sure we're running as root
  17. $pwuid = getpwuid( $< );
  18. if($pwuid ne "root"){
  19. die "script must be run as root";
  20. }
  21. # Check /etc/passwd for the username created during
  22. # installation
  23. if( ($admin_un) = `tail /etc/passwd | grep -v "nobody:"` =~ /([^:\n]+):[^:]+:[0-9]{4,}/){
  24. printf("admin user will be set to %s\n", $admin_un);
  25. }else{
  26. die "create a non-root user & set user passsword before running this script."
  27. }
  28. $admin_home_dir = "/home/$admin_un";
  29. # grant doas access to admin user
  30. system("echo 'permit $admin_un' > /etc/doas.conf");
  31. # install git
  32. system("pkg_add git");
  33. chdir $admin_home_dir;
  34. system("su gashapwn -c 'git clone $GIT_REPO'");