]>
Commit | Line | Data |
---|---|---|
ee78a5ef | 1 | #!/bin/sh |
70df8302 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
337726bf | 5 | # Copyright (C) 2007-2012 IPFire Team <info@ipfire.org> # |
70df8302 MT |
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 | ||
337726bf AF |
24 | # scan sd? |
25 | echo "--> sd?" | |
32e62ec2 | 26 | for DEVICE in `find /sys/block/* -maxdepth 0 -name sd* -or -name vd* -exec basename {} \; | sort | uniq` |
337726bf | 27 | do |
0dcb85e8 AF |
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 | |
dbf157bb | 34 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
ee78a5ef | 35 | umount /harddisk 2> /dev/null |
149a26a8 | 36 | echo "${DEVICE} is source drive - SKIP" |
ee78a5ef | 37 | continue |
149a26a8 MT |
38 | else |
39 | umount /harddisk 2> /dev/null | |
4cdac3e5 | 40 | mount /dev/${DEVICE}1 /harddisk 2> /dev/null |
dbf157bb | 41 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
cf3235ad AF |
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" | |
337726bf | 49 | exit 1 # (always use /dev/sda as bootdevicename) |
cf3235ad | 50 | fi |
ee78a5ef MT |
51 | fi |
52 | done | |
53 | ||
337726bf AF |
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 | |
149a26a8 | 58 | mount /dev/${DEVICE}p1 /harddisk 2> /dev/null |
dbf157bb | 59 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
56b548f1 | 60 | umount /harddisk 2> /dev/null |
4cdac3e5 | 61 | echo "${DEVICE}p1 is source drive - SKIP" |
56b548f1 | 62 | continue |
149a26a8 | 63 | else |
56b548f1 | 64 | umount /harddisk 2> /dev/null |
0dcb85e8 AF |
65 | if [ "$(grep ${DEVICE} /proc/partitions)" = "" ]; then |
66 | umount /harddisk 2> /dev/null | |
67 | echo "${DEVICE} is empty - SKIP" | |
68 | continue | |
69 | fi | |
10183c9f | 70 | mount /dev/${DEVICE}1 /harddisk 2> /dev/null |
dbf157bb | 71 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
4cdac3e5 AF |
72 | umount /harddisk 2> /dev/null |
73 | echo "${DEVICE}1 is source drive - SKIP" | |
74 | continue | |
10183c9f | 75 | else |
4cdac3e5 AF |
76 | umount /harddisk 2> /dev/null |
77 | mount /dev/${DEVICE} /harddisk 2> /dev/null | |
dbf157bb | 78 | if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then |
4cdac3e5 AF |
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" | |
88e957f5 | 85 | exit 2 # Raid ( /dev/device/diskx ) |
4cdac3e5 | 86 | fi |
10183c9f | 87 | fi |
56b548f1 MT |
88 | fi |
89 | done | |
90 | ||
ee78a5ef | 91 | exit 10 # Nothing found |