2023-09-22 21:23:12 +09:00
|
|
|
#!/usr/bin/env bash
|
2023-09-23 22:32:23 +09:00
|
|
|
pushd /etc/nixos/git
|
2023-09-23 22:13:49 +09:00
|
|
|
|
2023-11-19 17:27:41 +09:00
|
|
|
# Home-Manager Setup
|
|
|
|
echo ">>> Setting up Home Manager..... "
|
|
|
|
sudo mkdir /nix/var/nix/profiles/per-user/albert
|
2024-02-19 22:43:06 +09:00
|
|
|
|
|
|
|
# For some reason the syncthing folder takes this over and makes it owned by root
|
|
|
|
sudo mkdir /home/albert/.config
|
|
|
|
sudo chown albert:albert /home/albert/.config
|
2023-12-13 15:44:57 +09:00
|
|
|
sudo chown -R albert:root /nix/var/nix/profiles/per-user/albert
|
2023-11-19 17:27:41 +09:00
|
|
|
home-manager switch -b backup --flake /etc/nixos/git
|
|
|
|
source ~/.bashrc
|
|
|
|
|
|
|
|
# Import and trust the GPG key
|
|
|
|
echo ">>> Setting up user GPG key..... "
|
2023-11-26 18:20:37 +09:00
|
|
|
drive=$(lsblk -o serial,name | grep NGN130R000980P2202 | awk {'print $2'})
|
2023-12-15 20:43:39 +09:00
|
|
|
sudo mkdir -p /tmp/drive
|
2023-11-19 17:27:41 +09:00
|
|
|
sudo cryptsetup luksOpen /dev/${drive}3 usb-luks
|
|
|
|
sudo mount /dev/mapper/usb-luks /tmp/drive
|
2024-05-01 21:12:51 +09:00
|
|
|
gpg --import /tmp/drive/gpg/albert@sysctl.io/keys.pgp
|
2023-11-19 17:27:41 +09:00
|
|
|
sudo umount /tmp/drive
|
|
|
|
sudo rmdir /tmp/drive
|
|
|
|
sudo cryptsetup luksClose /dev/mapper/usb-luks
|
|
|
|
echo -e "5\ny\n" | gpg --command-fd 0 --expert --edit-key albert@sysctl.io trust
|
|
|
|
|
2023-09-18 16:16:55 +09:00
|
|
|
# Setup SOPS
|
2023-09-23 22:13:49 +09:00
|
|
|
echo "Setting up SOPS keys..... "
|
2023-10-07 17:37:10 +09:00
|
|
|
echo ">>> !!!!!"
|
|
|
|
echo ">>> !!!!!"
|
|
|
|
echo ">>> !!!!!"
|
|
|
|
echo ">>> !!!!! Copy this signature to .sops.yaml: "
|
2023-12-26 11:31:01 +09:00
|
|
|
|
|
|
|
# Currently only RSA keys are allowed
|
2023-09-23 09:05:32 +09:00
|
|
|
sudo ssh-to-pgp \
|
2023-09-23 22:05:27 +09:00
|
|
|
-comment "Generated `date +%Y.%m.%d`" \
|
2023-09-23 09:05:32 +09:00
|
|
|
-email "root@`hostname`" \
|
|
|
|
-i /etc/ssh/ssh_host_rsa_key \
|
|
|
|
-o /etc/nixos/git/keys/hosts/$(hostname).asc
|
2023-09-18 16:16:55 +09:00
|
|
|
|
2024-05-01 21:14:55 +09:00
|
|
|
echo ">>> !!!!!"
|
|
|
|
echo ">>> !!!!!"
|
|
|
|
echo ">>> !!!!!"
|
|
|
|
|
2023-09-18 16:16:55 +09:00
|
|
|
# Set up ssh keys
|
2023-10-07 17:37:10 +09:00
|
|
|
echo ">>> Setting up SSH Keys..... "
|
2023-12-10 12:00:41 +09:00
|
|
|
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""
|
2023-09-22 21:09:37 +09:00
|
|
|
echo "" >> ./keys/ssh/keys.txt
|
2023-12-13 13:08:29 +09:00
|
|
|
echo "# (`date`) `whoami`@`hostname`" >> ./keys/ssh/keys.txt
|
2023-12-10 12:00:41 +09:00
|
|
|
cat /home/albert/.ssh/id_ed25519.pub >> ./keys/ssh/keys.txt
|
2023-09-18 16:16:55 +09:00
|
|
|
|
2023-12-26 09:39:46 +09:00
|
|
|
# echo ">>> Setting up Distributed Build SSH Keys..... "
|
|
|
|
# sudo ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N ""
|
|
|
|
# echo "" >> ./keys/ssh/builder-keys.txt
|
|
|
|
# echo "# (`date`) root@`hostname`" >> ./keys/ssh/builder-keys.txt
|
|
|
|
# sudo cat /root/.ssh/id_ed25519.pub >> ./keys/ssh/builder-keys.txt
|
2023-10-07 17:37:10 +09:00
|
|
|
|
2023-09-18 16:16:55 +09:00
|
|
|
# Add all changes to git and and push
|
2023-10-07 17:37:10 +09:00
|
|
|
echo ">>> Pushing to git..... "
|
2023-09-19 17:01:58 +09:00
|
|
|
git add keys/hosts/`hostname`.asc
|
2023-10-07 17:37:10 +09:00
|
|
|
git commit -am "Setup: `hostname`"
|
2023-09-18 16:16:55 +09:00
|
|
|
git push
|
|
|
|
|
2023-09-22 21:09:37 +09:00
|
|
|
echo
|
|
|
|
echo
|
2023-10-07 17:37:10 +09:00
|
|
|
echo ">>> Complete. Once '.sops.yaml' is updated, "
|
|
|
|
echo ">>> run 'update-secrets' and reboot."
|
2023-09-28 20:23:04 +09:00
|
|
|
echo
|
2023-09-23 22:13:49 +09:00
|
|
|
echo
|
2023-10-07 17:37:10 +09:00
|
|
|
echo ">>> Reminder: Upload these changes to git"
|
2023-09-23 09:05:32 +09:00
|
|
|
|
2023-10-10 21:59:58 +09:00
|
|
|
popd
|