Annotation of /trunk/installer/include/prepare_disks.sh
Parent Directory | Revision Log
Revision 1035 -
(hide annotations)
(download)
(as text)
Sun May 30 18:37:54 2010 UTC (14 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 1941 byte(s)
Sun May 30 18:37:54 2010 UTC (14 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 1941 byte(s)
-code cleanup
1 | niro | 773 | #!/bin/sh |
2 | niro | 1020 | # $Id$ |
3 | niro | 773 | |
4 | : ${INSTALL_ROOT="/mnt/magellan"} | ||
5 | KNOWN_DISKS="ROOT BOOT SWAP HOME TMP USER VAR SVR OPT" | ||
6 | |||
7 | format_disks() | ||
8 | { | ||
9 | local disk | ||
10 | local disk_part | ||
11 | local disk_fs | ||
12 | local opts | ||
13 | local progress | ||
14 | |||
15 | declare -i progress=0 | ||
16 | |||
17 | # disk format | ||
18 | for disk in ${KNOWN_DISKS} | ||
19 | do | ||
20 | disk_part=$(eval echo \$PARTITION_DISK_${disk}) | ||
21 | disk_fs=$(eval echo \$PARTITION_FS_${disk}) | ||
22 | |||
23 | if [[ ! -z ${disk_part} ]] | ||
24 | then | ||
25 | if [[ ! -z ${disk_fs} ]] | ||
26 | then | ||
27 | case ${disk_fs} in | ||
28 | niro | 1020 | swap) mkswap ${disk_part} &> /dev/null;; |
29 | reiserfs) mkfs.${disk_fs} -f ${disk_part} &> /dev/null;; | ||
30 | keep-as-is) echo "keeping as-is." ;; | ||
31 | *) mkfs.${disk_fs} ${disk_part} &> /dev/null;; | ||
32 | niro | 773 | esac |
33 | fi | ||
34 | fi | ||
35 | |||
36 | (( progress++ )) | ||
37 | echo ${progress} 9 | awk '{print ($1 / $2 * 100) - 1}' | ||
38 | done | ||
39 | |||
40 | echo "100" | ||
41 | } | ||
42 | |||
43 | mount_disks() | ||
44 | { | ||
45 | local disk | ||
46 | local disk_part | ||
47 | local dest | ||
48 | |||
49 | # activate swap | ||
50 | swapon ${PARTITION_DISK_SWAP} | ||
51 | |||
52 | # first mount rootfs | ||
53 | mount ${PARTITION_DISK_ROOT} ${INSTALL_ROOT} | ||
54 | |||
55 | # than all other | ||
56 | for disk in ${KNOWN_DISKS} | ||
57 | do | ||
58 | case ${disk} in | ||
59 | BOOT) dest=boot ;; | ||
60 | HOME) dest=home ;; | ||
61 | TMP) dest=tmp ;; | ||
62 | USER) dest=usr ;; | ||
63 | VAR) dest=var ;; | ||
64 | SVR) dest=svr ;; | ||
65 | OPT) dest=opt ;; | ||
66 | *) continue ;; | ||
67 | esac | ||
68 | |||
69 | disk_part=$(eval echo \$PARTITION_DISK_${disk}) | ||
70 | if [[ ! -z ${disk_part} ]] | ||
71 | then | ||
72 | install -d ${INSTALL_ROOT}/${dest} | ||
73 | mount ${disk_part} ${INSTALL_ROOT}/${dest} | ||
74 | fi | ||
75 | done | ||
76 | } | ||
77 | |||
78 | umount_disks() | ||
79 | { | ||
80 | local disk | ||
81 | local disk_part | ||
82 | local dest | ||
83 | |||
84 | # first umount all other | ||
85 | for disk in ${KNOWN_DISKS} | ||
86 | do | ||
87 | # excludes | ||
88 | case ${disk} in | ||
89 | ROOT) continue ;; | ||
90 | SWAP) continue ;; | ||
91 | esac | ||
92 | |||
93 | disk_part=$(eval echo \$PARTITION_DISK_${disk}) | ||
94 | [[ ! -z ${disk_part} ]] && umount ${disk_part} | ||
95 | done | ||
96 | |||
97 | # then umount rootfs | ||
98 | umount ${PARTITION_DISK_ROOT} | ||
99 | |||
100 | # de-activate swap | ||
101 | swapoff ${PARTITION_DISK_SWAP} | ||
102 | } | ||
103 | |||
104 | case $1 in | ||
105 | --format | -f) format_disks ;; | ||
106 | --mount | -m ) mount_disks ;; | ||
107 | --umount | -u ) umount_disks ;; | ||
108 | niro | 1020 | *) echo "unknown option '$1'." ;; |
109 | niro | 773 | esac |
Properties
Name | Value |
---|---|
svn:executable | * |