]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/install+setup/install/mountdest.sh
1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2013 IPFire Team <info@ipfire.org> #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 ###############################################################################
21 # Set histchars to an empty string so we are able to replace an
25 echo "Scanning for possible destination drives"
30 # Don't mount if the device does not exist.
31 [ -e "${what}" ] ||
return 1
33 mount
${what} /harddisk
2>/dev
/null
37 umount
-l /harddisk
2>/dev
/null
40 function check_source_drive
() {
41 local device
="/dev/${1}"
45 for dev
in ${device} ${device}1; do
46 # Mount the device (if possible).
47 _mount
${dev} ||
continue
49 if [ -n "$(ls /harddisk/ipfire-*.tlz 2>/dev/null)" ]; then
55 # Stop if the device has been detected as a source drive.
56 [ "${ret}" = "0" ] && break
62 for path
in /sys
/block
/*; do
63 device
=$
(basename ${path})
65 # Skip devices which cannot be used.
81 # Replace any exclamation marks (e.g. cciss!c0d0).
82 device_
=${device//!/\/}
84 # Guess if this could be a raid device.
85 for dev
in ${device_} ${device_}p1
; do
86 if [ -e "/dev/${dev}" ]; then
92 # Check if user want skip by commandline
93 if [ "$(grep "skipdst
=${device_}" /proc/cmdline)" ]; then
94 echo "${device_} was skipped via cmdline."
98 echo "Checking ${device_}"
99 if check_source_drive
${device_}; then
100 echo " is source drive - skipping"
104 device_size
=$
(cat /sys
/block
/${device}/size
)
105 if [ "${device_size}" = "0" ]; then
106 echo " is empty - skipping"
111 echo " OK, this is it..."
112 echo -n "${device_}" > /tmp
/dest_device
115 device_size
=$
(( ${device_size} / 2097152 ))
117 # Build string with drive details
118 device_str
="/dev/${device_} - ${device_size} GiB -"
119 device_str
="${device_str} $(cat /sys/block/${device}/device/vendor)"
120 device_str
="${device_str} $(cat /sys/block/${device}/device/model)"
122 # Remove all whitespace.
123 device_str
=$
(echo ${device_str})
125 echo -n "${device_str}" > /tmp
/dest_device_info