Add a source check for fdd-image to mountdest.sh
[people/pmueller/ipfire-2.x.git] / src / install+setup / install / mountdest.sh
CommitLineData
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
22echo "Scanning for possible destination drives"
23
24# scan IDE devices
25echo "--> IDE"
26for DEVICE in $(kudzu -qps -t 30 -c HD -b IDE | grep device: | cut -d ' ' -f 2 | sort | uniq); do
149a26a8
MT
27 mount /dev/${DEVICE}1 /harddisk 2> /dev/null
28 if [ -n "$(ls /harddisk/ipfire-*.tbz2 2>/dev/null)" ]; then
ee78a5ef 29 umount /harddisk 2> /dev/null
4cdac3e5 30 echo "${DEVICE}1 is source drive - SKIP"
ee78a5ef 31 continue
149a26a8
MT
32 else
33 umount /harddisk 2> /dev/null
34 echo -n "$DEVICE" > /tmp/dest_device
35 echo "${DEVICE} - yes, it is our destination"
36 exit 0
ee78a5ef
MT
37 fi
38done
39
40# scan USB/SCSI devices
41echo "--> USB/SCSI"
42for DEVICE in $(kudzu -qps -t 30 -c HD -b SCSI | grep device: | cut -d ' ' -f 2 | sort | uniq); do
cf3235ad 43 mount /dev/${DEVICE} /harddisk 2> /dev/null
149a26a8 44 if [ -n "$(ls /harddisk/ipfire-*.tbz2 2>/dev/null)" ]; then
ee78a5ef 45 umount /harddisk 2> /dev/null
149a26a8 46 echo "${DEVICE} is source drive - SKIP"
ee78a5ef 47 continue
149a26a8
MT
48 else
49 umount /harddisk 2> /dev/null
4cdac3e5 50 mount /dev/${DEVICE}1 /harddisk 2> /dev/null
cf3235ad
AF
51 if [ -n "$(ls /harddisk/ipfire-*.tbz2 2>/dev/null)" ]; then
52 umount /harddisk 2> /dev/null
53 echo "${DEVICE}1 is source drive - SKIP"
54 continue
55 else
56 umount /harddisk 2> /dev/null
57 echo -n "$DEVICE" > /tmp/dest_device
58 echo "${DEVICE} - yes, it is our destination"
59 exit 1
60 fi
ee78a5ef
MT
61 fi
62done
63
56b548f1
MT
64# scan RAID devices
65echo "--> RAID"
66for DEVICE in $(kudzu -qps -t 30 -c HD -b RAID | grep device: | cut -d ' ' -f 2 | sort | uniq); do
149a26a8
MT
67 mount /dev/${DEVICE}p1 /harddisk 2> /dev/null
68 if [ -n "$(ls /harddisk/ipfire-*.tbz2 2>/dev/null)" ]; then
56b548f1 69 umount /harddisk 2> /dev/null
4cdac3e5 70 echo "${DEVICE}p1 is source drive - SKIP"
56b548f1 71 continue
149a26a8 72 else
56b548f1 73 umount /harddisk 2> /dev/null
10183c9f
AF
74 mount /dev/${DEVICE}1 /harddisk 2> /dev/null
75 if [ -n "$(ls /harddisk/ipfire-*.tbz2 2>/dev/null)" ]; then
4cdac3e5
AF
76 umount /harddisk 2> /dev/null
77 echo "${DEVICE}1 is source drive - SKIP"
78 continue
10183c9f 79 else
4cdac3e5
AF
80 umount /harddisk 2> /dev/null
81 mount /dev/${DEVICE} /harddisk 2> /dev/null
82 if [ -n "$(ls /harddisk/ipfire-*.tbz2 2>/dev/null)" ]; then
83 umount /harddisk 2> /dev/null
84 echo "${DEVICE} is source drive - SKIP"
85 continue
86 else
87 echo -n "$DEVICE" > /tmp/dest_device
88 echo "${DEVICE} - yes, it is our destination"
89 exit 2
90 fi
10183c9f 91 fi
56b548f1
MT
92 fi
93done
94
ee78a5ef 95exit 10 # Nothing found