blob: 013a1287fbc2a1630855e4daafb1e67ea87789e4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/bin/sh
# shellcheck disable=SC2086
# shellcheck source=/dev/null
. ~/.local/lib/shell/lib
#After partitioning /dev/vda1 as efi and /dev/vda2 as btrfs, installation is as simple as:
available_disks="$(mktmp)";
lsblk -J | jq '.[] | map(.name) | [foreach .[] as $item ({item: null, index: -1}; {$item, index: (.index + 1)})]' > $available_disks;
#"$(lsblk -J | jq '.[]| .[]| {name: .name, children: (.children | map(.name))} | .name')"
[ "$(jq '.[]' "$available_disks" | wc -l)" -eq 0 ] && die "No disks found"
msg "Select a disk to format:\n"
i=9999; # nobody will have so many disks attached
while ! jq -e --argjson i "$i" '.[$i]' "$available_disks" > /dev/null ; do
for disk in $(jq -c '.[]' "$available_disks" ); do
printf "%4s) %s \n" "$(echo "$disk" | jq '.index')" "$(echo "$disk" | jq '.item' | tr -d "\"")";
done
printf "%4s) Exit\n" "q"
readp "Enter a option: " disk
if [ $disk = "q" ];then
exit 1
else
i="$disk"
fi
jq -e --argjson i "$i" '.[$i]' "$available_disks" || warning "\nNo disk selected. Select a disk to continue.\n"
done
exit 0;
#disk=$((disk-1))
#read -p "Do you want to delete all in ${Disk_Array[$disk]}? [N/y]" -n 1 -r result
#[[ $result =~ ^[Yy]$ ]] && echo || exit 1
#sgdisk -Z "${Disk_Array[$disk]}" > /dev/null || dien "Zapping"
#sgdisk -n 1:0:+300M -n 2:0:"$ENDSECTOR" -t 1:ef00 -t 2:8300 "${Disk_Array[$disk]}" > /dev/null || dien "Partitioning"
#
#if [[ ${Disk_Array[$disk]} == *"nvme"* ]];then
# export DISK_EFI=${Disk_Array[$disk]}p1 && echo "${Disk_Array[$disk]}p1" > /root/efi-disk
# export DISK_ROOT=${Disk_Array[$disk]}p2 && echo "${Disk_Array[$disk]}p2" > /root/root-disk
#else
# export DISK_EFI=${Disk_Array[$disk]}1 && echo "${Disk_Array[$disk]}1" > /root/efi-disk
# export DISK_ROOT=${Disk_Array[$disk]}2 && echo "${Disk_Array[$disk]}2" > /root/root-disk
#fi
#
#
#mount -t btrfs /dev/vda2 /mnt
#btrfs subvolume create /mnt/{nix,storage}
#btrfs subvolume create /mnt/storage/{networkmanager,nixos-server}
#umount /mnt
#mount -t tmpfs none /mnt
#mkdir -p /mnt/{nix,etc/nixos,etc/NetworkManager,srv,boot}
#mount /dev/vda1 /mnt/boot
#mount -t btrfs -o subvol=nix /dev/vda2 /mnt/nix
#mount -t btrfs -o subvol=storage /dev/vda2 /mnt/srv
#mount -o bind /mnt/srv/nixos-server /mnt/etc/nixos
#mount -o bind /mnt/srv/networkmanager /mnt/etc/NetworkManager
#nixos-generate-config --root /mnt
#nixos-install --no-root-passwd
#reboot
#
#
#if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi
|