File: postinst

package info (click to toggle)
prebaseconfig 1.07sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 288 kB
  • ctags: 7
  • sloc: sh: 196; makefile: 37
file content (54 lines) | stat: -rw-r--r-- 1,223 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh

. /usr/share/debconf/confmodule

set -e

log() {
    logger -t prebaseconfig "$@"
}

# Use this instead of /target/bin/run-parts because one of the
# parts will unmount /target/. Also, progress bar.
run_parts() {
    partsdir="$1"
    scriptcount=`ls "$partsdir"/* | wc -l`

    db_progress START 0 $scriptcount prebaseconfig/progress/title

    tmpfile=/tmp/prebaseconfig.stderr.log
    for script in "$partsdir"/*; do

	base=$(basename $script | sed 's/[0-9]*//')
	if ! db_progress INFO prebaseconfig/progress/$base; then
		db_subst prebaseconfig/progress/fallback SCRIPT "$base"
		db_progress INFO prebaseconfig/progress/fallback
	fi

        if [ -x "$script" ] ; then
            log "info: Running $script"
            if "$script" 2> $tmpfile ; then
		:
	    else
		code="$?"
		if [ "$code" = 10 ]; then
		    log "$script backed up"
    		    db_progress STOP
		    exit 10
		fi
		log "warning: $script returned error code $code"
	    fi
	    if [ -s "$tmpfile" ] ; then
		logger -t prebaseconfig < "$tmpfile"
	    fi
	    rm -f "$tmpfile"
        else
            log "error: Unable to execute $script"
        fi

	db_progress STEP 1
    done
    db_progress STOP
}

run_parts /usr/lib/prebaseconfig.d