~ubuntu-branches/ubuntu/maverick/partman-basicfilesystems/maverick

« back to all changes in this revision

Viewing changes to check.d/check_swap

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2007-02-20 19:08:28 UTC
  • Revision ID: james.westby@ubuntu.com-20070220190828-knqmulq9is0rlfrk
Tags: 51ubuntu2
* Move sanity-checking scripts from finish.d to check.d.
* Set maintainer to ubuntu-installer@lists.ubuntu.com.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
. /lib/partman/definitions.sh
 
4
 
 
5
swap=false
 
6
 
 
7
for dev in $DEVICES/*; do
 
8
    [ -d "$dev" ] || continue
 
9
    cd $dev
 
10
    partitions=
 
11
    open_dialog PARTITIONS
 
12
    while { read_line num id size type fs path name; [ "$id" ]; }; do
 
13
        [ "$fs" != free ] || continue
 
14
        partitions="$partitions $id,$num"
 
15
    done
 
16
    close_dialog
 
17
    
 
18
    for part in $partitions; do
 
19
        id=${part%,*}
 
20
        num=${part#*,}
 
21
        [ -f $id/method ] || continue
 
22
        method=$(cat $id/method)
 
23
        if [ "$method" = swap ]; then
 
24
            swap=:
 
25
        fi
 
26
        [ ! -f $id/format ] || continue
 
27
        if [ "$method" = swap ]; then
 
28
            log "Check the swap space in $dev/$id"
 
29
            template=partman-basicfilesystems/progress_swap_checking
 
30
            db_subst $template PARTITION "$num"
 
31
            db_subst $template DEVICE $(humandev $(cat device))
 
32
            name_progress_bar $template
 
33
            open_dialog CHECK_FILE_SYSTEM $id
 
34
            read_line status
 
35
            close_dialog
 
36
            if [ "$status" != good ]; then
 
37
                db_subst partman-basicfilesystems/swap_check_failed PARTITION "$num"
 
38
                db_subst partman-basicfilesystems/swap_check_failed DEVICE $(humandev $(cat device))
 
39
                db_set partman-basicfilesystems/swap_check_failed 'true'
 
40
                db_input critical partman-basicfilesystems/swap_check_failed || true
 
41
                db_go || true
 
42
                db_get partman-basicfilesystems/swap_check_failed
 
43
                if [ "$RET" = 'true' ]; then
 
44
                    exit 1
 
45
                fi
 
46
            fi
 
47
        fi
 
48
    done
 
49
done
 
50
 
 
51
if ! $swap; then
 
52
    db_set partman-basicfilesystems/no_swap true
 
53
    db_input critical partman-basicfilesystems/no_swap || true
 
54
    db_go || true
 
55
    db_get partman-basicfilesystems/no_swap
 
56
    if [ "$RET" = true ]; then
 
57
        exit 1
 
58
    fi
 
59
fi