Skip to content

Commit 9e1c8c1

Browse files
committed
Enhance init script
and also boot script docs.
1 parent 80b2896 commit 9e1c8c1

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

boot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
# Usage:
1111
#
12-
# ./boot.sh PRESET [option] DISK ISO
12+
# ./boot.sh PRESET [option] DISK_file [ISO_file]
1313
#
1414
# See the blocks in code for options.
1515
#

init.sh

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
1+
#!/usr/bin/env zsh
12

2-
bash -n "$0" || exit 1
3+
set -xe
34

4-
set -x
5+
zsh -n "$0"
56

6-
[[ -n "$1" ]]
7+
[[ "$1" == '-n' ]] && {
8+
RM=y
9+
shift ||:
10+
:
11+
} || RM=
712

8-
[[ -r disk.raw ]] && rm disk.raw
9-
[[ -r disk.qcow2 ]] && rm disk.qcow2
13+
[[ "$1" == '-r' ]] && {
14+
RAW=y
15+
shift ||:
16+
:
17+
} || RAW=
1018

11-
[[ "$1" == "-r" ]] && {
12-
qemu-img create -f raw disk.raw 10G
13-
exit
14-
}
19+
n="${1:-}"
20+
21+
[[ -n "$n" ]]
22+
23+
[[ -n "$RAW" ]] && {
24+
f=raw
25+
:
26+
} || f=qcow2
1527

16-
[[ "$1" == "-q" ]] && {
17-
qemu-img create -f qcow2 disk.qcow2 10G
18-
exit
28+
d="disk-${n}.${f}"
29+
30+
[[ -n "$RM" ]] && {
31+
rm -f "$d" ||:
32+
:
33+
} || {
34+
35+
[[ -r "$d" ]] && exit 2
1936
}
2037

38+
qemu-img create -f "$f" "$d" 10G
39+

0 commit comments

Comments
 (0)