]>
Commit | Line | Data |
---|---|---|
ee78a5ef | 1 | #!/bin/sh |
70df8302 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
ee78a5ef MT |
21 | |
22 | echo "Scanning for possible destination drives" | |
23 | ||
24 | # scan IDE devices | |
25 | echo "--> IDE" | |
26 | for DEVICE in $(kudzu -qps -t 30 -c HD -b IDE | grep device: | cut -d ' ' -f 2 | sort | uniq); do | |
0dcb85e8 AF |
27 | if [ "$(grep ${DEVICE} /proc/partitions)" = "" ]; then |
28 | umount /harddisk 2> /dev/null | |
29 | echo "${DEVICE} is empty - SKIP" | |
30 | continue | |
31 | fi | |
149a26a8 | 32 | mount /dev/${DEVICE}1 /harddisk 2> /dev/null |
dbf157bb | 33 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
ee78a5ef | 34 | umount /harddisk 2> /dev/null |
4cdac3e5 | 35 | echo "${DEVICE}1 is source drive - SKIP" |
ee78a5ef | 36 | continue |
149a26a8 MT |
37 | else |
38 | umount /harddisk 2> /dev/null | |
39 | echo -n "$DEVICE" > /tmp/dest_device | |
40 | echo "${DEVICE} - yes, it is our destination" | |
88e957f5 | 41 | exit 0 # IDE / use DEVICE for grub |
ee78a5ef MT |
42 | fi |
43 | done | |
44 | ||
45 | # scan USB/SCSI devices | |
46 | echo "--> USB/SCSI" | |
47 | for DEVICE in $(kudzu -qps -t 30 -c HD -b SCSI | grep device: | cut -d ' ' -f 2 | sort | uniq); do | |
0dcb85e8 AF |
48 | if [ "$(grep ${DEVICE} /proc/partitions)" = "" ]; then |
49 | umount /harddisk 2> /dev/null | |
50 | echo "${DEVICE} is empty - SKIP" | |
51 | continue | |
52 | fi | |
53 | mount /dev/${DEVICE} /harddisk 2> /dev/null | |
dbf157bb | 54 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
ee78a5ef | 55 | umount /harddisk 2> /dev/null |
149a26a8 | 56 | echo "${DEVICE} is source drive - SKIP" |
ee78a5ef | 57 | continue |
149a26a8 MT |
58 | else |
59 | umount /harddisk 2> /dev/null | |
4cdac3e5 | 60 | mount /dev/${DEVICE}1 /harddisk 2> /dev/null |
dbf157bb | 61 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
cf3235ad AF |
62 | umount /harddisk 2> /dev/null |
63 | echo "${DEVICE}1 is source drive - SKIP" | |
64 | continue | |
65 | else | |
66 | umount /harddisk 2> /dev/null | |
67 | echo -n "$DEVICE" > /tmp/dest_device | |
68 | echo "${DEVICE} - yes, it is our destination" | |
88e957f5 | 69 | exit 1 # SCSI/USB (always use /dev/sda as bootdevicename) |
cf3235ad | 70 | fi |
ee78a5ef MT |
71 | fi |
72 | done | |
73 | ||
56b548f1 MT |
74 | # scan RAID devices |
75 | echo "--> RAID" | |
76 | for DEVICE in $(kudzu -qps -t 30 -c HD -b RAID | grep device: | cut -d ' ' -f 2 | sort | uniq); do | |
0dcb85e8 AF |
77 | if [ "$(grep ${DEVICE}p1 /proc/partitions)" = "" ]; then |
78 | umount /harddisk 2> /dev/null | |
79 | echo "${DEVICE}p1 is empty - SKIP" | |
80 | continue | |
81 | fi | |
149a26a8 | 82 | mount /dev/${DEVICE}p1 /harddisk 2> /dev/null |
dbf157bb | 83 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
56b548f1 | 84 | umount /harddisk 2> /dev/null |
4cdac3e5 | 85 | echo "${DEVICE}p1 is source drive - SKIP" |
56b548f1 | 86 | continue |
149a26a8 | 87 | else |
56b548f1 | 88 | umount /harddisk 2> /dev/null |
0dcb85e8 AF |
89 | if [ "$(grep ${DEVICE} /proc/partitions)" = "" ]; then |
90 | umount /harddisk 2> /dev/null | |
91 | echo "${DEVICE} is empty - SKIP" | |
92 | continue | |
93 | fi | |
10183c9f | 94 | mount /dev/${DEVICE}1 /harddisk 2> /dev/null |
dbf157bb | 95 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
4cdac3e5 AF |
96 | umount /harddisk 2> /dev/null |
97 | echo "${DEVICE}1 is source drive - SKIP" | |
98 | continue | |
10183c9f | 99 | else |
4cdac3e5 AF |
100 | umount /harddisk 2> /dev/null |
101 | mount /dev/${DEVICE} /harddisk 2> /dev/null | |
dbf157bb | 102 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
4cdac3e5 AF |
103 | umount /harddisk 2> /dev/null |
104 | echo "${DEVICE} is source drive - SKIP" | |
105 | continue | |
106 | else | |
107 | echo -n "$DEVICE" > /tmp/dest_device | |
108 | echo "${DEVICE} - yes, it is our destination" | |
88e957f5 | 109 | exit 2 # Raid ( /dev/device/diskx ) |
4cdac3e5 | 110 | fi |
10183c9f | 111 | fi |
56b548f1 MT |
112 | fi |
113 | done | |
114 | ||
88e957f5 AF |
115 | # Virtio devices |
116 | echo "--> Virtio" | |
117 | for DEVICE in vda vdb vdc vdd; do | |
118 | if [ ! -e /dev/${DEVICE} ]; then | |
119 | continue | |
120 | else | |
0dcb85e8 AF |
121 | if [ "$(grep ${DEVICE} /proc/partitions)" = "" ]; then |
122 | umount /harddisk 2> /dev/null | |
123 | echo "${DEVICE} is empty - SKIP" | |
124 | continue | |
125 | fi | |
88e957f5 | 126 | mount /dev/${DEVICE} /harddisk 2> /dev/null |
dbf157bb | 127 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
88e957f5 AF |
128 | umount /harddisk 2> /dev/null |
129 | echo "${DEVICE} is source drive - SKIP" | |
130 | continue | |
131 | else | |
132 | umount /harddisk 2> /dev/null | |
133 | mount /dev/${DEVICE}1 /harddisk 2> /dev/null | |
dbf157bb | 134 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
88e957f5 AF |
135 | umount /harddisk 2> /dev/null |
136 | echo "${DEVICE}1 is source drive - SKIP" | |
137 | continue | |
138 | else | |
139 | umount /harddisk 2> /dev/null | |
140 | echo -n "$DEVICE" > /tmp/dest_device | |
141 | echo "${DEVICE} - yes, it is our destination" | |
142 | exit 0 # like ide / use device for grub | |
143 | fi | |
144 | fi | |
145 | fi | |
146 | done | |
147 | ||
148 | ||
ee78a5ef | 149 | exit 10 # Nothing found |