source: client/shared/lib/os-probes/50mounted-tests @ 1d1e06d

Last change on this file since 1d1e06d was 2cd8344, checked in by adv <adv@…>, 8 years ago

#796 os-probes librerias de grub con detección de nuevas versiones de sistemas opertativos (p.e win10). usado solo para ogLives antiguos (kernel 3.2)

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5378 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.4 KB
Line 
1#!/bin/sh
2# Sub-tests that require a mounted partition.
3set -e
4partition="$1"
5
6. /usr/share/os-prober/common.sh
7
8types="$(fs_type "$partition")" || types=NOT-DETECTED
9if [ "$types" = NOT-DETECTED ] || [ -z "$types" ]; then
10        debug "$1 type not recognised; skipping"
11        exit 0
12elif [ "$types" = swap ]; then
13        debug "$1 is a swap partition; skipping"
14        exit 0
15elif [ "$types" = LVM2_member ]; then
16        debug "$1 is a LVM member partition; skipping"
17        exit 0
18elif [ "$types" = crypto_LUKS ]; then
19        debug "$1 is a LUKS partition; skipping"
20        exit 0
21elif [ "$types" = ntfs ]; then
22        if type ntfs-3g >/dev/null 2>&1; then
23                types='ntfs-3g ntfs'
24        fi
25elif [ -z "$types" ]; then
26        if type cryptsetup >/dev/null 2>&1 && \
27           cryptsetup luksDump "$partition" >/dev/null 2>&1; then
28                debug "$1 is a LUKS partition; skipping"
29                exit 0
30        fi
31        for type in $(grep -v nodev /proc/filesystems); do
32                # hfsplus filesystems are mountable as hfs. Try hfs last so
33                # that we can tell the difference.
34                if [ "$type" = hfs ]; then
35                        delaytypes="${delaytypes:+$delaytypes }$type"
36                elif [ "$type" = fuseblk ]; then
37                        if type ntfs-3g >/dev/null 2>&1; then
38                                types="${types:+$types }ntfs-3g"
39                        fi
40                else
41                        types="${types:+$types }$type"
42                fi
43        done
44fi
45
46tmpmnt=/var/lib/os-prober/mount
47if [ ! -d "$tmpmnt" ]; then
48        mkdir "$tmpmnt"
49fi
50
51mounted=
52if type grub-mount >/dev/null 2>&1 && \
53   type grub-probe >/dev/null 2>&1 && \
54   grub-mount "$partition" "$tmpmnt" 2>/dev/null; then
55        mounted=1
56        type="$(grub-probe -d "$partition" -t fs)" || true
57        if [ "$type" ]; then
58                debug "mounted using GRUB $type filesystem driver"
59        else
60                debug "mounted using GRUB, but unknown filesystem?"
61                type=fuseblk
62        fi
63else
64        echo "Failed to probe $partition for filesystem type" >&2
65        exit 1
66fi
67
68if [ "$mounted" ]; then
69        for test in /usr/lib/os-probes/mounted/*; do
70                debug "running subtest $test"
71                if [ -f "$test" ] && [ -x "$test" ]; then
72                        if "$test" "$partition" "$tmpmnt" "$type"; then
73                                debug "os found by subtest $test"
74                                if ! umount "$tmpmnt"; then
75                                        warn "failed to umount $tmpmnt"
76                                fi
77                                case "$type" in
78                                    btrfs)
79                                        # umount to account for the bind-mount
80                                        if [ -x "$tmpmnt/@/lib" ] && \
81                                           ! umount $tmpmnt; then
82                                                warn "failed to umount $tmpmnt"
83                                        fi
84                                        ;;
85                                esac
86                                rmdir "$tmpmnt" || true
87                                exit 0
88                        fi
89                fi
90        done
91        if ! umount "$tmpmnt"; then
92                warn "failed to umount $tmpmnt"
93        fi
94fi
95
96rmdir "$tmpmnt" || true
97
98# No tests found anything.
99exit 1
Note: See TracBrowser for help on using the repository browser.