Repository navigation
Expand file tree
/
Copy pathclientctl
More file actions
executable file
·113 lines (97 loc) · 2.45 KB
/
Copy pathclientctl
File metadata and controls
executable file
·113 lines (97 loc) · 2.45 KB
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
<
8000
div data-line-number="27" class="react-line-number react-code-text" style="padding-right:16px">2728
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
set -o errexit
mode=$1
shift || mode="no_action"
ROOT=../..
MYPWD=$( pwd )
IMAGE=$( readlink -f $ROOT/minix_x86.img )
DISK=$( readlink -f $ROOT/minix_x86.disk )
RC=$( readlink -f $ROOT/minix_x86.rc )
MKFS=$( readlink -f $ROOT/../obj.i386/tooldir*/bin/nbmkfs.mfs )
HYPER=${HYPER:-}
DISK_SIZE=${DISK_SIZE:-1024}
DISK_MNT=${DISK_MNT:-/media/minix-disk}
SERIALOUT=${SERIALOUT:-0}
function rc_create {
cat <<EOF
#!/bin/sh
set -o errexit
[ -d /ext ] || mkdir /ext
mount /dev/c0d1 /ext
if [ -f /ext/etc/rc ]; then
sh /ext/etc/rc
fi
EOF
}
function rc_ext_default_create {
cat <<EOF
#!/bin/sh
echo "/ext/etc/rc: /ext mounted correctly."
EOF
}
function disk_mount {
local mnt=$1
echo "* Mounting ${DISK} to $mnt..."
[ -d $mnt ] || sudo mkdir -p $mnt
umountdisk &> /dev/null || true
sudo mount -o loop $DISK $mnt
}
function disk_umount {
echo "* Unmounting ${DISK}..."
sudo umount $DISK
}
function disk_build {
local size=$1
local tmp_mnt=$( mktemp -d /tmp/clientctl-XXXXX )
echo "* Building ${size} MB disk image..."
dd if=/dev/zero of=$DISK bs=1M count=$size
$MKFS $DISK
echo "* Setting up /ext/etc/rc file executed at startup..."
rc_create > $RC
disk_mount $tmp_mnt
[ -d $tmp_mnt/etc ] || mkdir -p $tmp_mnt/etc
rc_ext_default_create > $tmp_mnt/etc/rc
disk_umount
rm -rf $tmp_mnt
}
case "$mode" in
'buildimage')
(cd $ROOT && CREATE_IMAGE_ONLY=1 releasetools/x86_hdimage.sh)
;;
'builddisk')
rm -f $DISK
disk_build $DISK_SIZE
;;
'mountdisk')
disk_mount $DISK_MNT
;;
'umountdisk')
disk_umount
;;
'run')
if [ "$HYPER" == "" ]; then
if which kvm2 > /dev/null; then
HYPER=kvm
elif [ -e /dev/kvm ]; then
HYPER="qemu-system-i386 --enable-kvm"
else
HYPER=qemu-system-i386
fi
fi
opts="-hda $IMAGE"
append="rootdevname=c0d0p1"
[ ! -f $DISK ] || opts="$opts -hdb $DISK"
if [ $SERIALOUT -eq 1 ]; then
opts="$opts -curses -serial file:$MYPWD/serial.out"
append="$append cttyline=0"
else
opts="$opts -nographic"
append="$append console=tty00"
fi
(cd ../../../obj.i386/destdir.i386/boot/minix/.temp && $HYPER -kernel kernel -append "$append" $opts -initrd "mod01_ds,mod02_rs,mod03_pm,mod04_sched,mod05_vfs,mod06_memory,mod07_tty,mod08_mfs,mod09_vm,mod10_pfs,mod11_init")
;;
*)
echo "Invalid action: $mode"
exit 1
;;
esac