Annotation of elwix/install2img.sh, revision 1.3.2.2
1.2 misho 1: #!/bin/sh
2: #
3: # ELWIX install script for image
4: #
5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
6: # by Michael Pounov <misho@elwix.org>
7: #
1.3.2.2 ! misho 8: # $Id: install2img.sh,v 1.3.2.1 2013/01/25 15:46:24 misho Exp $
1.2 misho 9: #
10:
11: [ -r ./config/rc.elwix ] && . ./config/rc.elwix
12: if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then
13: echo
14: echo "ELWIX project is not configured !?!"
15: echo
16: exit 1
17: fi
18:
19: if [ "${USER}" != "root" ]; then
20: echo
21: echo "ELWIX project is not configured - install must build under root !?!"
22: echo
23: exit 1
24: fi
25:
26: MNT="/mnt"
27: DEV=""
28:
29: mkdevice()
30: {
31: echo "+++ Make prepare file image ... "
1.3 misho 32: rm -f $1
33: dd if=/dev/zero of=$1 bs=1024 count=$2
1.2 misho 34:
1.3 misho 35: echo -n "+++ Assign memory device to image $1 ... "
36: DEV=`mdconfig -a -tvnode -f $1`
1.2 misho 37: echo $DEV
38:
39: if [ -z "$DEV" ]; then
1.3 misho 40: rm -f $1
1.2 misho 41: exit 3
42: fi
43: }
44:
45: initdev()
46: {
47: echo -n "+++ Init device label ... "
48: if disklabel -w $1; then
49: echo "OK"
50: else
51: echo "Failed!"
52: exit 3
53: fi
54:
55: if newfs -b8192 -f1024 -m0 -Lelwix ${1}a; then
56: echo "+++ Formatting ... OK"
57: else
58: echo "+++ Formatting ... Failed!"
59: exit 3
60: fi
61: }
62:
63: mountdev()
64: {
65: echo -n "+++ Mount device $1 to $MNT ... "
66: if mount /dev/${1}a $MNT; then
67: echo "OK"
68: else
69: echo "Failed!"
70: exit 4
71: fi
72: }
73:
74: umountdev()
75: {
76: echo -n "+++ Unmount $MNT ... "
77: if umount $MNT; then
78: echo "OK"
79: else
80: echo "Failed!"
81: exit 4
82: fi
83: }
84:
85: enablejfs()
86: {
87: if tunefs -n enable -j enable ${1}a; then
88: echo "Start FS Journaling ... OK"
89: else
90: echo "Start FS Journaling ... Failed!"
91: exit 6
92: fi
93: }
94:
95: boot2dev()
96: {
97: echo -n "+++ Installboot to device $1 ... "
1.3 misho 98: if disklabel -B -b ${WORLD}/boot/boot -m ${TARGET} $1; then
1.2 misho 99: echo "OK"
100: else
101: echo "Failed!"
102: exit 7
103: fi
104: }
105:
106: install2()
107: {
108: echo -n "+++ Install ELWIX OS from $1 into $MNT ... "
109: if tar -xzvpf $1 -C $MNT; then
110: echo "OK"
111: else
112: echo "Failed!"
113: exit 5
114: fi
115: }
116:
117: cleandev()
118: {
119: mdconfig -d -u $1
120: }
121:
122: gencksum()
123: {
124: echo -n "+++ Generate check sums ... "
1.3 misho 125: md5 $1 >$2
126: sha1 $1 >$3
1.2 misho 127: echo "OK"
128: }
129:
130: ### main()
131:
1.3 misho 132: if [ ! -r ${REL}/${OS} -a -r ${REL}/${OS_LITE} ]; then
1.2 misho 133: echo
134: echo "Error:: ELWIX OS file not found!"
135: echo
136: exit 2
137: fi
138:
1.3 misho 139: mkdevice $IMG ${1:-"${IMG_SIZE}"}
140: initdev $DEV
141: mountdev $DEV
142: install2 ${REL}/${OS}
143: umountdev
144: #enablejfs $DEV
145: boot2dev $DEV
146: cleandev $DEV
147: gencksum $IMG $MD5CHK $SHA1CHK
148:
1.2 misho 149:
1.3 misho 150: mkdevice $IMG_LITE ${1:-"${IMG_SIZE}"}
1.2 misho 151: initdev $DEV
152: mountdev $DEV
1.3.2.2 ! misho 153: install2 ${REL}/${OS_LITE}
! 154: umountdev
! 155: #enablejfs $DEV
! 156: boot2dev $DEV
! 157: cleandev $DEV
! 158: gencksum $IMG_LITE $MD5CHK_LITE $SHA1CHK_LITE
1.2 misho 159:
160: echo "ELWIX OS image complete."
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>