scripts and tools to administer the lingy.in public unix / tilde
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

56 рядки
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. chdir $admin_home_dir;
  35. # clone repo
  36. system("su $admin_un -c 'git clone $GIT_REPO'");
  37. chdir $REPO_DIR;
  38. # Setup the virtual environment
  39. system("pkg_add python3");
  40. system("su $admin_un -c 'python3 -m venv venv'");
  41. system("su $admin_un -c '. ./venv/bin/activate && pip3 install -r ");
  42. system("pkg_add p5-JSON");