summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2017-03-26 07:30:09 -0400
committerAndrew Cady <d@jerkface.net>2017-03-26 07:49:54 -0400
commitc470b6ca6075b33c2c696ca34070671ee32a8d76 (patch)
tree782c311be2835b60c06e3dcc9892a63ad5793a6a
parent217713edcd3a27d21577f8c4765f5b0d89981c7b (diff)
Implement booting already-installed native install
This option is only available if the partitions have been renamed to indicate finalization of the install. The code that finalizes the install by renaming the partitions is available, but not yet run after the install.
-rw-r--r--src/initrd/btrfs-create.sh22
-rwxr-xr-xsrc/initrd/grok-block22
-rwxr-xr-xsrc/initrd/menu-select10
3 files changed, 48 insertions, 6 deletions
diff --git a/src/initrd/btrfs-create.sh b/src/initrd/btrfs-create.sh
index b5cc2c5..f31b14d 100644
--- a/src/initrd/btrfs-create.sh
+++ b/src/initrd/btrfs-create.sh
@@ -184,10 +184,18 @@ partition_new_hard_drive_DESTROYING_EVERYTHING()
184 udevadm settle 184 udevadm settle
185} 185}
186 186
187mark_partitions_as_complete()
188{
189 local dev="$1"
190 # TODO: Verify existing names
191 parted "$dev" -sm \
192 name 1 samizdat-grub \
193 name 2 samizdat-plaintext \
194 name 3 samizdat-luks-encrypted
195}
196
187open_samizdat() 197open_samizdat()
188{ 198{
189 local imgfile="$1" keyfile="$2"
190 open_samizdat_blockdev "$imgfile" "$keyfile" || return
191 local blockdev=/dev/mapper/samizdatcrypt fs 199 local blockdev=/dev/mapper/samizdatcrypt fs
192 200
193 # For this part, we don't necessarily need the cdrom. 201 # For this part, we don't necessarily need the cdrom.
@@ -211,12 +219,18 @@ init_samizdat_lodev()
211 echo "$dev" 219 echo "$dev"
212} 220}
213 221
214open_samizdat_blockdev() 222open_samizdat_blockdev_from_loop()
215{ 223{
216 local imgfile="$1" keyfile="$2" dev 224 local imgfile="$1" keyfile="$2" dev
217 local cryptname=samizdatcrypt
218 dev=$(losetup -f) && losetup "$dev" "$imgfile" || return 225 dev=$(losetup -f) && losetup "$dev" "$imgfile" || return
226 open_samizdat_blockdev "$dev" "$keyfile"
227}
219 228
229open_samizdat_blockdev()
230{
231 local dev="$1" keyfile="$2"
232
233 local cryptname=samizdatcrypt
220 gpg2 --verify "$keyfile" || return 234 gpg2 --verify "$keyfile" || return
221 # The first --decrypt merely strips the signature. The option is 235 # The first --decrypt merely strips the signature. The option is
222 # poorly named for that case. 236 # poorly named for that case.
diff --git a/src/initrd/grok-block b/src/initrd/grok-block
index 01265b0..1152584 100755
--- a/src/initrd/grok-block
+++ b/src/initrd/grok-block
@@ -36,6 +36,14 @@ addmenu_chooseroot()
36 "menu-select --fs=$ID_FS_TYPE boot-luks $device ${loopfile:-$device}" 36 "menu-select --fs=$ID_FS_TYPE boot-luks $device ${loopfile:-$device}"
37} 37}
38 38
39addmenu_choose_native_root()
40{
41 local device="$1" loopfile="$2"
42 addmenu "$device//$device" \
43 "[ Boot the system on $device ]" \
44 "menu-select --fs=$ID_FS_TYPE boot-native $device"
45}
46
39addmenu_makeroot() 47addmenu_makeroot()
40{ 48{
41 local device="$1" loopfile="$2" megs="$3" copy_cdrom="$4" 49 local device="$1" loopfile="$2" megs="$3" copy_cdrom="$4"
@@ -50,7 +58,7 @@ addmenu_destroy_hard_drive()
50{ 58{
51 local device="$1" 59 local device="$1"
52 ( 60 (
53 addmenu "$device//$loopfile" \ 61 addmenu "$device//$device" \
54 "[ Install Samizdat to $device -- THIS DESTROYS ALL DATA ]" \ 62 "[ Install Samizdat to $device -- THIS DESTROYS ALL DATA ]" \
55 "menu-select boot-destroy-disk $device" 63 "menu-select boot-destroy-disk $device"
56 ) & 64 ) &
@@ -108,6 +116,13 @@ is_incomplete_samizdat_install()
108 [ "$partition_names" = 'samizdat-grub-incomplete:samizdat-plaintext-incomplete:samizdat-luks-encrypted-incomplete:' ] 116 [ "$partition_names" = 'samizdat-grub-incomplete:samizdat-plaintext-incomplete:samizdat-luks-encrypted-incomplete:' ]
109} 117}
110 118
119parent_device()
120{
121 local d="$1"
122 while [ "$d" != "${d%[0-9]}" ]; do d=${d%[0-9]}; done
123 printf '%s' "$d"
124}
125
111grok_block() 126grok_block()
112{ 127{
113 local mountpoint="/mnt/${DEVNAME##*/}" 128 local mountpoint="/mnt/${DEVNAME##*/}"
@@ -124,6 +139,11 @@ grok_block()
124 # TODO: make these names more unique 139 # TODO: make these names more unique
125 case "$ID_PART_ENTRY_NAME" in 140 case "$ID_PART_ENTRY_NAME" in
126 samizdat-grub-incomplete|samizdat-plaintext-incomplete|samizdat-luks-encrypted-incomplete) return ;; 141 samizdat-grub-incomplete|samizdat-plaintext-incomplete|samizdat-luks-encrypted-incomplete) return ;;
142 samizdat-grub|samizdat-plaintext|samizdat-luks-encrypted)
143 # TODO: Possibly only some of these are complete
144 addmenu_choose_native_root "$(parent_device "$DEVNAME")"
145 return
146 ;;
127 esac 147 esac
128 148
129 if [ "$ID_FS_TYPE" = hfsplus ] && ! fsck.hfsplus -q "$DEVNAME"; then 149 if [ "$ID_FS_TYPE" = hfsplus ] && ! fsck.hfsplus -q "$DEVNAME"; then
diff --git a/src/initrd/menu-select b/src/initrd/menu-select
index 4a141a4..625f775 100755
--- a/src/initrd/menu-select
+++ b/src/initrd/menu-select
@@ -94,6 +94,13 @@ case "$1" in
94 init_samizdat /dev/mapper/samizdatcrypt '' || error 94 init_samizdat /dev/mapper/samizdatcrypt '' || error
95 95
96 ;; 96 ;;
97 boot-native)
98 dev="$2"
99 init_gpg || error
100 mount "$dev"2 /gpg || error
101 open_samizdat_blockdev "$dev"3 /gpg/disk.key || error
102 open_samizdat || error
103 ;;
97 boot-overwrite|boot-new|boot-luks) 104 boot-overwrite|boot-new|boot-luks)
98 dev="$2" 105 dev="$2"
99 loopfile="$3" 106 loopfile="$3"
@@ -112,7 +119,8 @@ case "$1" in
112 init_gpg || error 119 init_gpg || error
113 120
114 if [ "$1" = 'boot-luks' ]; then 121 if [ "$1" = 'boot-luks' ]; then
115 open_samizdat "$loopfile" "$loopfile"k || error 122 open_samizdat_blockdev_from_loop "$loopfile" "$loopfile"k || error
123 open_samizdat || error
116 exit 124 exit
117 fi 125 fi
118 126