5 while getopts "f:i" option
15 printf "Option not recognized\n"
20 shift $
(($OPTIND - 1))
22 if [ $
(id
-u) -ne 0 ];then
23 printf "Installation is only possible as root\n"
27 printf "Checking if parted is installed"
28 parted
=$
(which parted
)
30 if [ ! -z $parted -a -x $parted ];then
37 printf "Checking if qemu-img is installed"
38 qimg
=$
(which qemu-img
)
40 if [ ! -z $qimg -a -x $qimg ];then
48 printf "Please give the name of the image file\n"
52 if [ -z $initramfs ];then
54 printf "Please give the name of the openadk archive file\n"
59 printf "Please give the full path prefix to kernel/initramfs\n"
65 printf "Generate qemu image\n"
66 $qimg create
-f raw
$1 512M
>/dev
/null
68 printf "Creating filesystem $filesystem\n"
70 printf "Create partition and filesystem\n"
71 $parted -s $1 mklabel msdos
72 $parted -s $1 mkpart primary ext2
0 100%
73 $parted -s $1 set 1 boot on
75 dd if=$1 of
=mbr bs
=16384 count
=1 2>/dev
/null
76 dd if=$1 skip
=16384 of
=$1.new
2>/dev
/null
78 if [ "$filesystem" = "ext2" -o "$filesystem" = "ext3" -o "$filesystem" = "ext4" ];then
82 mkfs.
$filesystem $mkfsopts ${1}.new
>/dev
/null
85 printf "Successfully created partition\n"
88 printf "Partition creation failed, Exiting.\n"
98 mount
-o loop
,offset
=16384 -t $filesystem $1 $tmp
100 if [ -z $initramfs ];then
101 printf "Extracting install archive\n"
103 printf "Fixing permissions\n"
105 chmod 4755 $tmp/bin
/busybox
107 printf "Copying kernel/initramfs\n"
108 mkdir
$tmp/boot
$tmp/dev
109 cp $2-kernel $tmp/boot
/kernel
110 cp $2-initramfs $tmp/boot
/initramfs
113 printf "Creating device nodes\n"
114 mknod
-m 666 $tmp/dev
/zero c
1 5
115 mknod
-m 666 $tmp/dev
/null c
1 3
116 mknod
-m 622 $tmp/dev
/console c
5 1
117 mknod
-m 666 $tmp/dev
/tty c
5 0
118 mknod
-m 666 $tmp/dev
/tty0 c
4 0
119 #mknod -m 660 $tmp/dev/hda b 3 0
120 #mknod -m 660 $tmp/dev/hda1 b 3 1
121 mknod
-m 666 $tmp/dev
/ttyS0 c
4 64
125 printf "Successfully installed.\n"
126 printf "Be sure $1 is writable for the user which use qemu\n"