scripts and tools to administer the lingy.in public unix / tilde
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

52 lines
1.2KB

  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 ($REPO_DIR) = $GIT_REPO =~ /\/([^\/]*)\.git$/;
  14. my $pwuid;
  15. my $admin_un;
  16. my $admin_home_dir;
  17. # Make sure we're running as root
  18. $pwuid = getpwuid( $< );
  19. if($pwuid ne "root"){
  20. die "script must be run as root";
  21. }
  22. # Check /etc/passwd for the username created during
  23. # installation
  24. if( ($admin_un) = `tail /etc/passwd | grep -v "nobody:"` =~ /([^:\n]+):[^:]+:[0-9]{4,}/){
  25. printf("admin user will be set to %s\n", $admin_un);
  26. }else{
  27. die "create a non-root user & set user passsword before running this script."
  28. }
  29. $admin_home_dir = "/home/$admin_un";
  30. # grant doas access to admin user
  31. system("echo 'permit $admin_un' > /etc/doas.conf");
  32. # install git
  33. system("pkg_add git");
  34. system("pkg_add python3");
  35. chdir $admin_home_dir;
  36. system("su gashapwn -c 'git clone $GIT_REPO'");
  37. chdir $REPO_DIR;
  38. system("su gashapwn -c 'python3 -m venv venv'");
  39. # system("su gashapwn -c '. ./venv/bin/activate && pip3 install -r ");