File: debian-edu-install.firstboot

package info (click to toggle)
debian-edu-install 0.674
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 956 kB
  • ctags: 51
  • sloc: sh: 1,035; perl: 278; makefile: 181
file content (127 lines) | stat: -rwxr-xr-x 3,944 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh
#### BEGIN INIT INFO
# Provides:          xdebian-edu-firstboot
# Required-Start:    $remote_fs $all
# Required-Stop:
# Should-Start:      xdm kdm gdm
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Check the Debian Edu installation after first boot
# Description:       Run the self test and report any errors found.
#                    Install this as /etc/rc2.d/99xdebian-edu-firstboot
### END INIT INFO
#
# Author: Petter Reinholdtsen
# Date:   2006-09-22
#

. /lib/lsb/init-functions

set -e

do_start() {
    log_daemon_msg "Collecting testsuite results"
    logfile=/var/log/installer/debian-edu-testsuite.log

    mkdir -p /tmp/firstboot
    errfile=/tmp/firstboot/errors

    # only run the testsuite during development, not during production
    if $(grep "\-test" /etc/apt/sources.list > /dev/null ) ; then nice debian-edu-test-install > $logfile 2>&1 ; fi

    # find error messages in the d-i log and the self test
    if [ -f /var/log/installer/syslog  ] ; then
        # remove syslog prefix
        grep error: /var/log/installer/syslog | \
	    grep -v 'Fontconfig error:' |
	    sed 's/.*error: /error: /g' > $errfile
    fi
    grep error: $logfile >> $errfile || true

    log_end_msg 0

    if [ -s $errfile ] ; then
        $0 report-errors $errfile || true
    fi
    rm $errfile $logfile
    rmdir /tmp/firstboot

    # Do readahead profiling on the next boot, and not on the initial boot, to avoid
    # incuding the test in the readahead profiling.
    if [ -x /sbin/readahead-list ] ; then
        touch /etc/readahead/profile-once
    fi

    # Remove the script symlinks to make sure it only executes once after
    # the first boot
    update-rc.d -f xdebian-edu-firstboot remove > /dev/null
    rm -f /etc/init.d/xdebian-edu-firstboot
}

report_errors() {
    action="$1"
    errfile="$2"

    # Try to get debconf to pop up the dialog on top of kdm.  Need to
    # do this before starting debconf.
    XAUTHORITY="`ls -tr /var/run/xauth/* 2>/dev/null|tail -1`"
    if [ "$XAUTHORITY" ] && XAUTHORITY=$XAUTHORITY DISPLAY=:0 xhost > /dev/null 2>&1 ; then
        # Try to use kde frontend (require libqt-perl).  debconf will fall
        # back to dialog if the kde frontend fail to start.  The frontend
        # need to be set before confmodule is sourced to have effect.
        DISPLAY=:0
        DEBIAN_FRONTEND=kde
        export XAUTHORITY DISPLAY DEBIAN_FRONTEND
    fi

    . /usr/share/debconf/confmodule

    # Disable usplash if enabled and not using the X display, to get the debconf dialog to show up.
    # Need to do this after the $DISPLA variable is set up, to detect if the X connection is working.
    if [ -z "$DISPLAY" ] && type usplash_write >/dev/null 2>&1; then
        clear >/dev/tty8
        /sbin/usplash_write QUIT
        chvt 8
    fi

    log_daemon_msg "Reporting errors found"

    # Quick fix to make sure all error entries at least are
    # displayed.  The correct fix is to find out how to replace a
    # debconf variable with multiline content.  not sure why I
    # need to change this in to one long line
    errors=`cat $errfile | sed 's/$/, /g' | tr -d "\n" | sed 's/, $//'`

    # Take a look at how CURRENT_CONFIG is built up in
    # partman/partman-lvm/choose_partition/lvm/do_option

    db_subst debian-edu-install/errors-found ERRORS "$errors"

    db_fset debian-edu-install/errors-found seen false
    db_input critical debian-edu-install/errors-found || [ $? -eq 30 ]
    db_go

    log_end_msg 1 || true

    # Move back to tty1, to get the login prompt
    if [ -z "$DISPLAY" ] && type usplash_write >/dev/null 2>&1; then
        chvt 1
    fi
}

case "$1" in
    start)
        do_start
        ;;
    stop|force-reload|restart)
        ;;
    report-errors)
        report_errors $1 $2
	;;
    *)
        echo "Usage: /etc/init.d/xdebian-edu-firstboot {start|stop|restart|force-reload}"
        exit 1
        ;;
esac

exit 0