]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/install+setup/install/mountdest.sh
Merge remote-tracking branch 'origin/next' into kernel-update
[people/teissler/ipfire-2.x.git] / src / install+setup / install / mountdest.sh
1 #!/bin/sh
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 ###############################################################################
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
27 if [ "$(grep ${DEVICE} /proc/partitions)" = "" ]; then
28 umount /harddisk 2> /dev/null
29 echo "${DEVICE} is empty - SKIP"
30 continue
31 fi
32 mount /dev/${DEVICE}1 /harddisk 2> /dev/null
33 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
34 umount /harddisk 2> /dev/null
35 echo "${DEVICE}1 is source drive - SKIP"
36 continue
37 else
38 umount /harddisk 2> /dev/null
39 echo -n "$DEVICE" > /tmp/dest_device
40 echo "${DEVICE} - yes, it is our destination"
41 exit 0 # IDE / use DEVICE for grub
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
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
54 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
55 umount /harddisk 2> /dev/null
56 echo "${DEVICE} is source drive - SKIP"
57 continue
58 else
59 umount /harddisk 2> /dev/null
60 mount /dev/${DEVICE}1 /harddisk 2> /dev/null
61 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
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"
69 exit 1 # SCSI/USB (always use /dev/sda as bootdevicename)
70 fi
71 fi
72 done
73
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
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
82 mount /dev/${DEVICE}p1 /harddisk 2> /dev/null
83 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
84 umount /harddisk 2> /dev/null
85 echo "${DEVICE}p1 is source drive - SKIP"
86 continue
87 else
88 umount /harddisk 2> /dev/null
89 if [ "$(grep ${DEVICE} /proc/partitions)" = "" ]; then
90 umount /harddisk 2> /dev/null
91 echo "${DEVICE} is empty - SKIP"
92 continue
93 fi
94 mount /dev/${DEVICE}1 /harddisk 2> /dev/null
95 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
96 umount /harddisk 2> /dev/null
97 echo "${DEVICE}1 is source drive - SKIP"
98 continue
99 else
100 umount /harddisk 2> /dev/null
101 mount /dev/${DEVICE} /harddisk 2> /dev/null
102 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
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"
109 exit 2 # Raid ( /dev/device/diskx )
110 fi
111 fi
112 fi
113 done
114
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
121 if [ "$(grep ${DEVICE} /proc/partitions)" = "" ]; then
122 umount /harddisk 2> /dev/null
123 echo "${DEVICE} is empty - SKIP"
124 continue
125 fi
126 mount /dev/${DEVICE} /harddisk 2> /dev/null
127 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
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
134 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
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
149 exit 10 # Nothing found