]> wirehaze git hosting - BOS.git/blob - scripts/install.sh

wirehaze git hosting

Update shell.asm
[BOS.git] / scripts / install.sh
1 #! /bin/sh
2
3 # BOS Linux Installer version 0.2
4 # You must be root to run this script because of the floppy/loopback device
5
6 echo
7 echo -e "\E[33;1mBOS\E[0m - \E[32;1mLinux installer\E[0m"
8 echo
9
10 if [ `id -u` != "0" ]; then
11 echo -e "\E[31;1mYou must be root to use this installer!\E[0m"
12 echo
13 fi
14
15 if [ -z "$1" ]; then
16 echo "Usage is:"
17 echo -e "\E[31m$0 image\E[0m - Creates a floppy image called bos.img"
18 echo -e "\E[31m$0 floppy\E[0m - Install BOS into a floppy ( must be inserted )"
19 echo
20 echo "Note: this installer will create a bootable image/floppy."
21 echo "Floppy creation is not tested ( I don't have a floppy reader ) and it should be already formatted"
22 exit
23 fi
24
25 echo -e "\E[32mCompiling BOS...\E[0m"
26 ../utils/fasm ../kernel/kernel.asm ../kernel/kernel.sys
27 ../utils/fasm ../boot/BOS_boot.asm ../boot/BOS_boot.bin
28
29 if [ "$1" = "floppy" ]; then
30 echo -e "\E[32mStarting floppy installation...\E[0m"
31
32 #Install BOS_boot.bin as bootsector into bos.img
33 dd if=boot/BOS_boot.bin of=/dev/fd0 bs=1 count=512
34 mount /mnt/floppy
35
36 #Insert kernel.sys into image
37 cp ../kernel/kernel.sys /mnt/floppy
38
39 #Umount & cleanup
40 umount /mnt/floppy
41
42 echo -e "\E[33mBOS installed.\E[0m"
43
44 else
45 echo -e "\E[32mStarting image creation...\E[0m"
46
47 #Create empty image
48 if [ -e ../bos.img ]; then
49 rm -f ../bos.img
50 fi
51 dd if=/dev/zero of=bos.img bs=1k count=1440
52
53 #Format image in MSDOS format and mount it
54 mkdosfs ../bos.img
55 losetup /dev/loop3 ../bos.img
56
57 #Install BOS_boot.bin as bootsector into bos.img
58 dd if=../boot/BOS_boot.bin of=/dev/loop3 bs=1 count=512
59 if [ ! -e tmpmnt ]; then
60 mkdir tmpmnt
61 fi
62 mount -tmsdos /dev/loop3 tmpmnt
63
64 #Insert kernel.sys into image
65 cp ../kernel/kernel.sys tmpmnt
66
67 #Umount & cleanup
68 umount /dev/loop3
69 if [ -e tmpmnt ]; then
70 rm -rf tmpmnt
71 fi
72 losetup -d /dev/loop3
73
74 echo -e "\E[33mBOS image created! ( better do a chown on it now ;) )\E[0m"
75 fi