diff options
| author | Ryan Schanzenbacher <ryan@rschanz.org> | 2023-09-14 13:36:03 -0400 |
|---|---|---|
| committer | Ryan Schanzenbacher <ryan@rschanz.org> | 2023-09-14 13:36:03 -0400 |
| commit | 33a7e1524d9134dab37e1ba812e0526a7fd72435 (patch) | |
| tree | d5ba876e1638d5a2abe0a8c81076786d4a46fd13 | |
| parent | b53809f97d12725bd8afc43a010cdf16ceeefc84 (diff) | |
preparing deploy script
| -rwxr-xr-x | deploy.sh | 67 | ||||
| -rw-r--r-- | modules/ryan-config/deploy-templates/HostTemplate.scm | 19 | ||||
| -rw-r--r-- | modules/ryan-config/deploy-templates/HostTemplateEncrypted.scm | 24 |
3 files changed, 110 insertions, 0 deletions
diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..2d73d9b --- /dev/null +++ b/deploy.sh | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | |||
| 3 | gather_env() { | ||
| 4 | # Gather needed information | ||
| 5 | echo -n "Type 'e' for encrypted or 'd' for decrypted install: " | ||
| 6 | read install_type | ||
| 7 | |||
| 8 | echo -n "Type system hostname: " | ||
| 9 | read install_hostname | ||
| 10 | |||
| 11 | echo -n "Type device file for ROOT data: " | ||
| 12 | read root_dev | ||
| 13 | |||
| 14 | echo -n "Type device file for BOOT data: " | ||
| 15 | read boot_dev | ||
| 16 | |||
| 17 | echo -n "Type device file for SWAP: " | ||
| 18 | read swap_dev | ||
| 19 | |||
| 20 | } | ||
| 21 | |||
| 22 | copy_and_prepare() { | ||
| 23 | # Associate devs with uuids | ||
| 24 | root_uuid=`blkid $root_dev | awk -F\" '{print $2}'` | ||
| 25 | boot_uuid=`blkid $boot_dev | awk -F\" '{print $2}'` | ||
| 26 | swap_uuid=`blkid $swap_dev | awk -F\" '{print $2}'` | ||
| 27 | # Let's a go! | ||
| 28 | echo "Information gathered. Deploying Guix on $root_dev ($root_uuid) with boot on $boot_dev ($boot_uuid) and swap on $swap_dev ($swap_uuid)" | ||
| 29 | echo -n "Proceed? (y/n): " | ||
| 30 | read install_choice | ||
| 31 | |||
| 32 | if [ "$install_choice" != "y" ] | ||
| 33 | then | ||
| 34 | echo "Bailing!" | ||
| 35 | exit 1 | ||
| 36 | fi | ||
| 37 | |||
| 38 | # We are installing! | ||
| 39 | # Copy template to root of repo | ||
| 40 | if [ "$install_type" == "e" ] | ||
| 41 | then | ||
| 42 | cp ./modules/ryan-config/deploy-templates/HostTemplateEncrypted.scm ./$install_hostname.scm | ||
| 43 | elif [ "$install_type" == "d" ] | ||
| 44 | then | ||
| 45 | cp ./modules/ryan-config/deploy-templates/HostTemplate.scm ./$install_hostname.scm | ||
| 46 | else | ||
| 47 | echo "Invalid install type (not d or e), bailing!" | ||
| 48 | exit 1 | ||
| 49 | fi | ||
| 50 | |||
| 51 | # Correct the information | ||
| 52 | sed -i "s/ChangeMe_ROOT/$root_uuid/" ./$install_hostname.scm | ||
| 53 | sed -i "s/ChangeMe_BOOTEFI/$boot_uuid/" ./$install_hostname.scm | ||
| 54 | sed -i "s/ChangeMe_SWAP/$swap_uuid/" ./$install_hostname.scm | ||
| 55 | sed -i "s/ChangeMe_HOST/$install_hostname/" ./$install_hostname.scm | ||
| 56 | |||
| 57 | # Install! | ||
| 58 | echo "Mounting /gnu/store to destination disk..." | ||
| 59 | herd start cow-store /mnt | ||
| 60 | |||
| 61 | echo "Beginning install!" | ||
| 62 | guix time-machine -C ./channels.scm -- system -L ./modules --substitute-urls='https://bordeaux.guix.gnu.org https://ci.guix.gnu.org https://substitutes.nonguix.org' init $install_hostname.scm /mnt | ||
| 63 | |||
| 64 | } | ||
| 65 | |||
| 66 | gather_env | ||
| 67 | copy_and_prepare | ||
diff --git a/modules/ryan-config/deploy-templates/HostTemplate.scm b/modules/ryan-config/deploy-templates/HostTemplate.scm new file mode 100644 index 0000000..9718c51 --- /dev/null +++ b/modules/ryan-config/deploy-templates/HostTemplate.scm | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | (use-modules (ryan-config base-system) | ||
| 2 | (gnu)) | ||
| 3 | |||
| 4 | (operating-system | ||
| 5 | (inherit base-operating-system) | ||
| 6 | (host-name "ChangeMe_HOST") | ||
| 7 | (file-systems (cons* (file-system | ||
| 8 | (mount-point "/") | ||
| 9 | (device (uuid "ChangeMe_ROOT" | ||
| 10 | 'ext4)) | ||
| 11 | (type "ext4")) | ||
| 12 | (file-system | ||
| 13 | (mount-point "/boot/efi") | ||
| 14 | (device (uuid "ChangeMe_BOOTEFI" | ||
| 15 | 'fat32)) | ||
| 16 | (type "vfat")) %base-file-systems)) | ||
| 17 | (swap-devices | ||
| 18 | (list | ||
| 19 | (swap-space (target (uuid "ChangeMe_SWAP")))))) | ||
diff --git a/modules/ryan-config/deploy-templates/HostTemplateEncrypted.scm b/modules/ryan-config/deploy-templates/HostTemplateEncrypted.scm new file mode 100644 index 0000000..5d74aaa --- /dev/null +++ b/modules/ryan-config/deploy-templates/HostTemplateEncrypted.scm | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | (use-modules (ryan-config base-system) | ||
| 2 | (gnu)) | ||
| 3 | |||
| 4 | (operating-system | ||
| 5 | (inherit base-operating-system) | ||
| 6 | (host-name "ChangeMe_HOST") | ||
| 7 | (mapped-devices (list (mapped-device | ||
| 8 | (source (uuid | ||
| 9 | "ChangeMe_ROOT")) | ||
| 10 | (target "sysroot") | ||
| 11 | (type luks-device-mapping)))) | ||
| 12 | (file-systems (cons* (file-system | ||
| 13 | (mount-point "/") | ||
| 14 | (device "/dev/mapper/sysroot") | ||
| 15 | (type "ext4") | ||
| 16 | (dependencies mapped-devices)) | ||
| 17 | (file-system | ||
| 18 | (mount-point "/boot/efi") | ||
| 19 | (device (uuid "ChangeMe_BOOTEFI" | ||
| 20 | 'fat32)) | ||
| 21 | (type "vfat")) %base-file-systems)) | ||
| 22 | (swap-devices | ||
| 23 | (list | ||
| 24 | (swap-space (target (uuid "ChangeMe_SWAP")))))) | ||
