summaryrefslogtreecommitdiff
path: root/old-school/common.sh
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/common.sh
parent5f41fb879ca830e5ad3345878e59072f3d6573bc (diff)
fix paths (in progress)
Diffstat (limited to 'old-school/common.sh')
-rw-r--r--old-school/common.sh143
1 files changed, 0 insertions, 143 deletions
diff --git a/old-school/common.sh b/old-school/common.sh
deleted file mode 100644
index 4aa8528..0000000
--- a/old-school/common.sh
+++ /dev/null
@@ -1,143 +0,0 @@
1#!/bin/sh
2REQUIRED_MB=250 # minimum megabytes available to offer install
3MENUFIFO=/menu.fifo
4DEBUG=y
5LOGBASE=/var/log
6
7debug_log()
8{
9 if [ -n "$DEBUG" ]; then
10 if [ -n "$1" ]; then
11 DEBUG_LOG=$LOGBASE/"$1".$$.log
12 else
13 DEBUG_LOG=$LOGBASE/$(basename $0).$$.log
14 fi
15 mkdir -p $LOGBASE
16 exec >>$DEBUG_LOG 2>&1
17 set -x
18 fi
19}
20addmenu()
21{
22 cat <<END >>$MENUFIFO # mind the tabs
23setItem "$1" "dummy" "$2" "$3"
24END
25}
26menutitle()
27{
28 printf 'setTitle "%s"\n' "$1" >>$MENUFIFO
29 printf 'setWelcomeText "%s"\n' "$2" >>$MENUFIFO
30}
31bootmenu()
32{
33 local do_trigger="$1" no_panic="$2"
34 OpenVT -f -c 7 -- dynmenu "$MENUFIFO" &&
35 chvt 7 &&
36 menutitle 'Samizdat\n\nAs the Internet develops there are\ntransitions in the management arrangements.\nThe time has come to take\na small step in one of those transitions.' 'Choose an installation target.'
37# menutitle 'Samizdat\nfreedom from surveillance\nno trusted authorities' 'Choose an installation target.'
38 addmenu "ramdisk" "[ Boot to RAM without installing anything ]" "menu-select boot-ram"
39 if [ $? != 0 -a ! "$no_panic" ]; then
40 panic "error loading boot menu! the system won't be usable :("
41 fi
42 if [ "$do_trigger" ]; then
43 udevadm trigger --subsystem-match=block --action=add
44 fi
45}
46find_squashfs_root()
47{
48 # TODO: "make" puts the correct location in $iso_squashfs_dir. Get
49 # information into this function!
50
51 bootwait samizdat-cdrom
52 for dir in /cdrom/live /cdrom/liveos /cdrom/aptosid /cdrom/*
53 do
54 [ -d "$dir" ] || continue;
55 if [ -f "$dir"/filesystem.module ]; then
56 while read fs; do
57 [ -f "$dir"/"$fs" ] && echo "$dir" "$fs"
58 done < "$dir"/filesystem.module
59 return
60 fi
61 done
62 for fs in /cdrom/live/filesystem.squashfs /cdrom/live/grml-small.squashfs /cdrom/liveos/squashfs.img /cdrom/aptosid/aptosid.* /cdrom/*/*.squashfs
63 do
64 if [ -f "$fs" ]; then
65 echo "${fs%/*}" "${fs##*/}"
66 break
67 fi
68 done
69}
70xtrace()
71{
72 case "$-" in
73 *x*) "$@" ;;
74 *) set -x; "$@"; set +x ;;
75 esac
76}
77sleepcmd() {
78 local t=$1
79 shift
80 echo "about to run '$*' (in $t)"
81 sleep $t
82 "$@"
83}
84sleep_forever_verbose() {
85 sleep 4294967295 &
86 local sleep=$!
87 warn "sleeping until you kill $sleep..."
88 wait $sleep
89}
90warn() { [ -z "$warnings" ] || echo "$@" >&2; }
91panic()
92{
93 set +x
94 exec </dev/tty1 >/dev/tty1 2>&1
95 reset
96 echo "[p$$] initramfs /init: fatal error: $@"
97 echo "[p$$] will now exec emergency shell"
98 export PS1="[p$$ \\w]# "
99 chvt 1
100 exec /bin/sh -i
101}
102bootwait()
103{
104 mkdir -p /bootwait
105 local i=$#; while [ $i -gt 0 ]; do
106 i=$((i-1))
107 local f="$1"; shift; set -- "$@" "/bootwait/$f"
108 done
109 wait_for_files "$@"
110}
111bootdone()
112{
113 mkdir -p /bootwait
114 local i=$#; while [ $i -gt 0 ]; do
115 i=$((i-1))
116 local f="$1"; shift; set -- "$@" "/bootwait/$f"
117 done
118 touch "$@"
119}
120my_openvt()
121{
122 /bin/openvt -c "$@"
123}
124
125# This runs before way before NTP and on a LiveCD we have no
126# reason to trust the system clock.
127gpg2_nobatch() { GPG_TTY=$(tty) command gpg2 --ignore-time-conflict --ignore-valid-from "$@"; }
128gpg2() { gpg2_nobatch --batch "$@"; }
129
130xcp() { if [ -f "$1" -a ! -f "$2" ]; then cp "$1" "$2"; fi; }
131
132mountsquashes()
133{
134 local name dirname basename
135 while read dirname basename && [ -d "$dirname" -a -f "$dirname/$basename" ]; do
136 name=${basename%.squashfs}
137 mkdir -p "/squashes/$name" || return 1
138 xcp "$dirname"/filesystem.module /squashes/filesystem.module || return 1
139 mountpoint -q "/squashes/$name" ||
140 mount -o ro,loop "$dirname/$basename" "/squashes/$name" || return 1
141 done
142}
143