about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-12-26 17:06:41 +0100
committerPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-12-26 17:06:41 +0100
commit223186ddd425927b5af99306b40be6ef582047ae (patch)
tree4476fe08bdda239ef38d23962a906909e719e075
downloadrecover-223186ddd425927b5af99306b40be6ef582047ae.tar.gz
recover-223186ddd425927b5af99306b40be6ef582047ae.zip
Init
-rw-r--r--.gitignore4
-rw-r--r--README.md3
-rwxr-xr-xinstall28
-rwxr-xr-xkeys38
4 files changed, 73 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..efc9663
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+id_rsa
+id_rsa.pub
+secret.gpg
+public.gpg
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0e2eaf7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,3 @@
+# recover
+
+Scripts for my recovery drive and downloading NixOS configuration. Docs are in files
diff --git a/install b/install
new file mode 100755
index 0000000..c2ec485
--- /dev/null
+++ b/install
@@ -0,0 +1,28 @@
+#!/bin/sh
+## Script for installing my nixos config. NixOS pretty much automates all the
+## process, but still you need to pass config url and rest of the commands, and
+## if it's tideous work after setting up all the disk partitions. So I made
+## this script to make less typing
+##
+## Usage: ./install {$machine}
+## this will install config from dots/machines/$machine
+
+set -eou pipefail
+
+[ "$UID" != "0" ] && echo "Run this as root!" && exit 1
+
+mkdir -p /etc/nixos/dots
+
+which nix && nix run nixos.git -c git clone https://github.com/pniedzwiedzinski/dots /etc/nixos/dots
+
+[ -z "$1" ] || cat << EOF > /etc/nixos/configuration.nix
+{
+  imports = [
+    ./dots/machines/$1
+  ];
+
+  system.stateVersion = "20.09";
+}
+EOF
+
+nixos-rebuild switch
diff --git a/keys b/keys
new file mode 100755
index 0000000..d6e7029
--- /dev/null
+++ b/keys
@@ -0,0 +1,38 @@
+#!/bin/sh
+## Script for copying my keychain
+##
+## This script is supposed to sit on a removable drive with these files:
+## - id_rsa - private ssh key
+## - id_rsa.pub - public ssh key
+## - secret.gpg - private gpg key
+## - public.gpg - public gpg key
+##
+## To setup your keys mount the drive, cd into it and run `./keys`
+
+set -euo pipefail
+
+echo "\$USER is $USER; \$HOME is $HOME"
+
+[ "$USER" != "pn" ] && echo "\nWarning: username is not 'pn'!\n"
+
+read -p "continue? [y/N]" choice
+
+case "$choice" in
+  y|Y) echo "Installing..." ;;
+  * ) echo "Mission aborted!"; exit 1 ;;
+esac
+
+echo "Copying ssh key to $HOME/.ssh/id_rsa ..."
+mkdir -p $HOME/.ssh
+cp id_rsa $HOME/.ssh
+cp id_rsa.pub $HOME/.ssh
+chmod 700 $HOME/.ssh/id_rsa
+echo "Ssh key done."
+
+echo "Importing gpg keys..."
+cp public.gpg secret.gpg $HOME
+gpg --import $HOME/public.gpg
+echo "Key $HOME/public.gpg imported"
+gpg --import $HOME/secret.gpg
+echo "Key $HOME/secret.gpg imported"
+echo "Gnupg keys done"