Annotation of elwix/install2img.sh, revision 1.7
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.7 ! misho 8: # $Id: install2img.sh,v 1.6.2.5 2013/08/05 13:09:20 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.7 ! misho 132: if [ -z "$1" -o ! -r "$1" ]; then
1.2 misho 133: echo
1.7 ! misho 134: echo "Error:: ELWIX OS tar file '$1' not found!"
1.2 misho 135: echo
136: exit 2
1.7 ! misho 137: else
! 138: IMGNAME=$(basename $1 | sed -e "s/.tar.gz//")
! 139: MD5CHK="${REL}/${IMGNAME}.md5"
! 140: SHA1CHK="${REL}/${IMGNAME}.sha1"
! 141: IMG="${REL}/${IMGNAME}.img"
1.2 misho 142: fi
143:
1.7 ! misho 144: mkdevice $IMG ${2:-"${IMG_SIZE}"}
1.3 misho 145: initdev $DEV
146: mountdev $DEV
1.7 ! misho 147: install2 $1
1.3 misho 148: umountdev
149: #enablejfs $DEV
150: boot2dev $DEV
151: cleandev $DEV
152: gencksum $IMG $MD5CHK $SHA1CHK
153:
1.7 ! misho 154: echo "ELWIX OS image $IMGNAME complete."
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>