Magellan Linux

Contents of /trunk/installer/include/prepare_disks.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 773 - (show annotations) (download) (as text)
Wed Sep 24 10:54:00 2008 UTC (15 years, 7 months ago) by niro
File MIME type: application/x-sh
File size: 1865 byte(s)
-moved helper-scripts into include/ directory

1 #!/bin/sh
2
3 : ${INSTALL_ROOT="/mnt/magellan"}
4 KNOWN_DISKS="ROOT BOOT SWAP HOME TMP USER VAR SVR OPT"
5
6 format_disks()
7 {
8 local disk
9 local disk_part
10 local disk_fs
11 local opts
12 local progress
13
14 declare -i progress=0
15
16 # disk format
17 for disk in ${KNOWN_DISKS}
18 do
19 disk_part=$(eval echo \$PARTITION_DISK_${disk})
20 disk_fs=$(eval echo \$PARTITION_FS_${disk})
21
22 if [[ ! -z ${disk_part} ]]
23 then
24 if [[ ! -z ${disk_fs} ]]
25 then
26 case ${disk_fs} in
27 swap) mkswap ${disk_part} >&2;;
28 reiserfs) mkfs.${disk_fs} -f ${disk_part} >&2;;
29 *) mkfs.${disk_fs} ${disk_part} >&2;;
30 esac
31 fi
32 fi
33
34 (( progress++ ))
35 echo ${progress} 9 | awk '{print ($1 / $2 * 100) - 1}'
36 done
37
38 echo "100"
39 }
40
41 mount_disks()
42 {
43 local disk
44 local disk_part
45 local dest
46
47 # activate swap
48 swapon ${PARTITION_DISK_SWAP}
49
50 # first mount rootfs
51 mount ${PARTITION_DISK_ROOT} ${INSTALL_ROOT}
52
53 # than all other
54 for disk in ${KNOWN_DISKS}
55 do
56 case ${disk} in
57 BOOT) dest=boot ;;
58 HOME) dest=home ;;
59 TMP) dest=tmp ;;
60 USER) dest=usr ;;
61 VAR) dest=var ;;
62 SVR) dest=svr ;;
63 OPT) dest=opt ;;
64 *) continue ;;
65 esac
66
67 disk_part=$(eval echo \$PARTITION_DISK_${disk})
68 if [[ ! -z ${disk_part} ]]
69 then
70 install -d ${INSTALL_ROOT}/${dest}
71 mount ${disk_part} ${INSTALL_ROOT}/${dest}
72 fi
73 done
74 }
75
76 umount_disks()
77 {
78 local disk
79 local disk_part
80 local dest
81
82 # first umount all other
83 for disk in ${KNOWN_DISKS}
84 do
85 # excludes
86 case ${disk} in
87 ROOT) continue ;;
88 SWAP) continue ;;
89 esac
90
91 disk_part=$(eval echo \$PARTITION_DISK_${disk})
92 [[ ! -z ${disk_part} ]] && umount ${disk_part}
93 done
94
95 # then umount rootfs
96 umount ${PARTITION_DISK_ROOT}
97
98 # de-activate swap
99 swapoff ${PARTITION_DISK_SWAP}
100 }
101
102 case $1 in
103 --format | -f) format_disks ;;
104 --mount | -m ) mount_disks ;;
105 --umount | -u ) umount_disks ;;
106 *) echo "unkown option '$1'." ;;
107 esac

Properties

Name Value
svn:executable *