summaryrefslogtreecommitdiff
path: root/old-school/menu-select
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2016-04-29 14:36:26 -0400
committerAndrew Cady <d@jerkface.net>2016-04-29 14:36:30 -0400
commit153d299a41b9be4e15dab1ca29bb93a74bd2445d (patch)
tree96fbfbe7c64f0b3f02f3d755e2b129917785bb98 /old-school/menu-select
parent5f41fb879ca830e5ad3345878e59072f3d6573bc (diff)
fix paths (in progress)
Diffstat (limited to 'old-school/menu-select')
-rwxr-xr-xold-school/menu-select123
1 files changed, 0 insertions, 123 deletions
diff --git a/old-school/menu-select b/old-school/menu-select
deleted file mode 100755
index f059052..0000000
--- a/old-school/menu-select
+++ /dev/null
@@ -1,123 +0,0 @@
1#!/bin/sh
2# usage:
3# $0 boot-ram - use memory-only overlay
4# $0 boot-new [dev name] [loop file] [megabytes] - create new luks-encrypted overlay
5# $0 boot-overwrite [dev name] [loop file] [megabytes] - overwrite with new luks overlay
6# $0 boot-luks [dev name] [loop file] - boot existing luks-encrypted overlay
7# $0 boot-gpg [key id] [gnupg homedir] [???] - boot any device signed with the key
8
9. lvm-create.sh
10. common.sh
11exec 4>&1
12debug_log
13
14error()
15{
16 local sleep=3
17
18 clear >&4
19 echo "error -- ${*:-:(}" >&4
20
21 if [ $sleep -gt 0 ]; then
22 echo "will try again in $sleep seconds..." >&4
23 sleep $sleep
24 fi
25 bootmenu do_trigger no_panic
26 exit
27}
28
29badopts=
30fs=
31while [ $# -ge 1 ]; do
32 case $1 in
33 --fs=*) fs="${1#--fs=}"; shift; continue ;;
34 --*) echo "error: unknown option $1"; badopts=true; shift; continue ;;
35 esac
36 break
37done
38[ -z "$badopts" ] || error 'usage error'
39
40[ $# -ge 2 -o "$1" = 'boot-ram' ] || error 'usage error'
41
42remountrw()
43{
44 local fs="$1" dev="$2" loopfile="$3"
45 if [ "$fs" = hfsplus ]; then
46 mountpoint="/mnt/${dev##*/}"
47 umount "$dev" || error
48 fsck.hfsplus -q "$dev" || error
49 mount -o force "$dev" "$mountpoint" || error
50 else
51 mount -o remount,rw "$dev" || error
52 fi
53}
54
55hwclock_to_system()
56{
57 local fs="$1" UTC=UTC
58 case "$fs" in ntfs|vfat) UTC=LOCAL ;; esac
59 printf '0.0 0 0.0\n0\n%s' $UTC > /etc/adjtime
60 hwclock --hctosys
61}
62
63case "$1" in
64 boot-ram)
65 read _ memtotal_kb _ < /proc/meminfo
66 # This doesn't make sense to me, but setting rd_size _lower_ than total
67 # memory seems to be what breaks things ('btrfs device add' hangs forever).
68 # Somehow you can fill up the filesystem and there's still space for
69 # programs and btrfs does not complain. I don't know what is going on here.
70
71 # BTW, I verified with blockdev that the device size really is being
72 # specified in KB here. I did not really believe it.
73 modprobe brd rd_nr=1 rd_size=$memtotal_kb
74
75 init_gpg || error
76 init_samizdat /dev/ram0 '' || {
77 umount /root/cdrom
78 umount /root/outerfs
79 umount /root
80 error
81 }
82 ;;
83 boot-overwrite|boot-new|boot-luks)
84 dev="$2"
85 loopfile="$3"
86 megs="$4"
87
88 [ "$1" != 'boot-new' -o ! -e "$loopfile" ] || error
89
90 remountrw "$fs" "$dev" "$loopfile" || error
91
92 hwclock_to_system "$fs"
93
94 if [ "$1" = 'boot-overwrite' ]; then
95 rm "$loopfile" "$loopfile"k
96 fi
97
98 init_gpg || error
99
100 if [ "$1" = 'boot-luks' ]; then
101 open_samizdat "$loopfile" "$loopfile"k || error
102 exit
103 fi
104
105 start_meter "Allocating ${megs}MB in '$loopfile' on $dev..."
106
107 if init_samizdat_blockdev "$loopfile" "$megs" "$loopfile"k &&
108 init_samizdat /dev/mapper/samizdatcrypt "$loopfile"; then
109 stop_meter done.
110 else
111 stop_meter error!
112 rm "$loopfile" "$loopfile"k
113 dmsetup remove samizdatcrypt
114 # TODO: more teardown
115 error
116 fi
117 ;;
118 *)
119 error "Unimplemented boot command: $*"
120 ;;
121esac
122
123# vim:ts=2 sw=2 et