]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/install+setup/install/mountdest.sh
Merge branch 'kernel-update' of ssh://git.ipfire.org/pub/git/ipfire-2.x into kernel...
[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-2012 IPFire Team <info@ipfire.org> #
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 sd?
25 echo "--> sd?"
26 for DEVICE in `find /sys/block/* -maxdepth 0 -name sd* -or -name vd* -exec basename {} \; | sort | uniq`
27 do
28 if [ "$(grep ${DEVICE} /proc/partitions)" = "" ]; then
29 umount /harddisk 2> /dev/null
30 echo "${DEVICE} is empty - SKIP"
31 continue
32 fi
33 mount /dev/${DEVICE} /harddisk 2> /dev/null
34 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
35 umount /harddisk 2> /dev/null
36 echo "${DEVICE} is source drive - SKIP"
37 continue
38 else
39 umount /harddisk 2> /dev/null
40 mount /dev/${DEVICE}1 /harddisk 2> /dev/null
41 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
42 umount /harddisk 2> /dev/null
43 echo "${DEVICE}1 is source drive - SKIP"
44 continue
45 else
46 umount /harddisk 2> /dev/null
47 echo -n "$DEVICE" > /tmp/dest_device
48 echo "${DEVICE} - yes, it is our destination"
49 exit 1 # (always use /dev/sda as bootdevicename)
50 fi
51 fi
52 done
53
54 # scan other
55 echo "--> other"
56 for DEVICE in `find /sys/block/* -maxdepth 0 ! -name sd* ! -name sr* ! -name fd* ! -name loop* ! -name ram* -exec basename {} \; | sort | uniq`
57 do
58 mount /dev/${DEVICE}p1 /harddisk 2> /dev/null
59 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
60 umount /harddisk 2> /dev/null
61 echo "${DEVICE}p1 is source drive - SKIP"
62 continue
63 else
64 umount /harddisk 2> /dev/null
65 if [ "$(grep ${DEVICE} /proc/partitions)" = "" ]; then
66 umount /harddisk 2> /dev/null
67 echo "${DEVICE} is empty - SKIP"
68 continue
69 fi
70 mount /dev/${DEVICE}1 /harddisk 2> /dev/null
71 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
72 umount /harddisk 2> /dev/null
73 echo "${DEVICE}1 is source drive - SKIP"
74 continue
75 else
76 umount /harddisk 2> /dev/null
77 mount /dev/${DEVICE} /harddisk 2> /dev/null
78 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
79 umount /harddisk 2> /dev/null
80 echo "${DEVICE} is source drive - SKIP"
81 continue
82 else
83 echo -n "$DEVICE" > /tmp/dest_device
84 echo "${DEVICE} - yes, it is our destination"
85 exit 2 # Raid ( /dev/device/diskx )
86 fi
87 fi
88 fi
89 done
90
91 exit 10 # Nothing found