Update of /cvs/debian-boot/base-config/lib/menu
In directory gluck:/tmp/cvs-serv5869/lib/menu

Added Files:
        apt-get apt-get.mnu apt-setup apt-setup.mnu finish finish.mnu 
        hostname hostname.mnu intro intro.mnu keyboard keyboard.mnu 
        mta mta.mnu passwd passwd.mnu pkgsel pkgsel.mnu pon pon.mnu 
        shell shell.mnu timezone timezone.mnu 
Log Message:
Checking in my changes for version 2.0. This includes many file moves.


--- NEW FILE: mta ---
#!/bin/sh -e
# exim4 is the default MTA.
# However, it's possible that it was not installed, as we can also function
# with no MTA. Or the user may have already installed a different MTA.
if [ -e /var/lib/dpkg/info/exim4-config.config ]; then
        if [ "$1" = new ]; then
                exec dpkg-reconfigure --unseen-only --default-priority exim4-config
        else
                exec dpkg-reconfigure --default-priority exim4-config
        fi
fi

--- NEW FILE: timezone.mnu ---
Only-New: false
Debconf: true
Order: 30

--- NEW FILE: finish.mnu ---
Only-New: false
Debconf: true
Order: 120
Exit-Menu: true

--- NEW FILE: intro ---
#!/bin/bash -e
. /usr/share/debconf/confmodule

db_capb backup

db_fset base-config/intro seen false
db_input high base-config/intro || true
db_go || exit 30 # back to menu

if which setterm >/dev/null 2>&1; then
        setterm -blank 0 >/dev/tty </dev/tty
fi

--- NEW FILE: pon.mnu ---
Only-New: false
Debconf: true
Order: 60

--- NEW FILE: keyboard.mnu ---
Only-New: true
Debconf: false
Order: 20

--- NEW FILE: shell ---
#!/bin/sh
clear
echo $"Type 'exit' to return to base-config."
echo
sh -l

--- NEW FILE: hostname ---
#!/bin/bash -e
# Set the current hostname if empty, and create /etc/hostname if missing.

. /usr/share/debconf/confmodule

db_capb backup

hostnamefile=/etc/hostname

currname=`uname -n`
defaultname=localhost

log() {
    echo "base-config: $@" >&2
}

info() {
    log "info: $@"
}

set_default_from_dns() {
        # The interface testing work best if the loopback device is skipped.
        # Sorted order to test eth1 before eth0, so that the setting in eth0
        # is the one that take effect
        interfaces=`netstat -i | tail +3 | awk '{print $1}' | grep -v '^lo$' | sort -r`
        for interface in $interfaces; do
                ip=`/sbin/ifconfig $interface 2>&1 | grep 'inet addr:' | tr a-zA-Z: " 
" | awk '{print $1}'`
                if [ "$ip" ]; then
                    dnsname=`getent hosts $ip | awk '{ print $2 }'`
                    if [ "$dnsname" ]; then
                                db_set base-config/get-hostname "$dnsname"
                                priority=medium
                    else
                                info "Unable to find IP address '$ip' in DNS."
                    fi
                else
                        info "Unable to find IP address on if '$interface'"
                fi
        done
}

# Check the hostname for RFC 1123 compliance.  2 < length of each part
# < 63, only characters 'a-z.-', and no dash at the start or at the
# end.
is_hostname_bad() {
        filtered=`echo -n "$1" | sed 's/[^a-z.-]//'`
        if [ "$1" != "$filtered" ]; then
            return 0;
        fi
        for part in `echo -n "$1" | tr . " "`; do
            length=`echo -n "$part" |wc -c`
            if [ 2 -gt "$length" ] || [ "$length" -ge 63 ]; then
                return 0
            fi
            if echo -n "$part" | egrep -q "^-|-$"; then
                return 0
            fi
        done
        return 1
}

if [ -z "$currname" ] || [ "$currname" = localhost ]; then
        # Check IP addresses of interfaces, try to look up
        # using DNS, use that name as default hostname, and
        # ask medium priority question if there is a
        # default, and high priority question if the default
        # is empty.
        priority=high

        # Make sure there is some good default.  Only change
        # the default value, to make it possible to override
        # this using the debconf database.
        db_set base-config/get-hostname $defaultname
        set_default_from_dns
else
        # Ask at medium priority so the menu item does something if
        # manaully selected.
        priority=medium
        db_set base-config/get-hostname $currname
fi

# Prompt for the hostname, using the current name, if any, as the default.
hostname=
LOOPCOUNT=2
while [ -z "$hostname" ]; do
        db_fset base-config/get-hostname seen false
        db_input "$priority" base-config/get-hostname || [ $? -eq 30 ]
        db_go || exit 30 # back to menu
        db_get base-config/get-hostname
        hostname="$RET"

        if is_hostname_bad "$hostname"; then
                db_subst base-config/invalid-hostname HOSTNAME "$hostname"
                db_fset base-config/invalid-hostname seen false
                db_input critical base-config/invalid-hostname || [ $? -eq 30 ]
                db_go || exit 30 # back to menu TODO should use state machine
                hostname=
        fi

        # Only loop LOOPCOUNT times.
        LOOPCOUNT=`expr $LOOPCOUNT - 1 || true`
        if [ "0" -ge "$LOOPCOUNT" ]; then
                if [ -z "$hostname" ]; then
                        hostname="$defaultname"
                        info "Terminating loop, setting hostname to '$hostname'"
                fi
        fi
done

# If the user failed to enter a hostname, then use the current name.
if [ -z "$hostname" ]; then
        if [ -z "$currname" ]; then
                hostname=$defaultname
        else
                hostname=$currname
        fi
fi

# Set hostname.
if [ "$hostname" != "$currname" ]; then
        echo "$hostname" > "$hostnamefile"
        hostname "$hostname"
fi

--- NEW FILE: pkgsel ---
#!/bin/bash -e
# Run various programs to select packages to install.

# As two of those programs (aptitude, dselect) can be made to install
# packages, debconf cannot be run in the main part of this script. Instead
# it is run inside here.
if [ "$1" = select ]; then
        . /usr/share/debconf/confmodule

        db_capb backup
        db_settitle base-config/title

        # Building up the choices list is a little bit nasty.
        choices=""
        # Note that the list is in reverse order to what is displayed,
        # since new items are prepended as the string is built up.
        # The last item found will be the default.
        for program in "dselect" "aptitude" "tasksel"; do
                if which $program >/dev/null 2>&1; then
                        case "$program" in
                        dselect)
                                entry=$"dselect - old package selector (experts only)"
                        ;;
                        aptitude)
                                entry=$"aptitude - pick tasks or drill down to 
individual packages"
                        ;;
                        tasksel)
                                entry=$"tasksel - quickly choose from predefined 
collections of software"
                        ;;
                        esac
                        choices="$entry, $choices"
                        db_set base-config/pkgsel "$entry"
                fi
        done
        choices="$choices "$"nothing - you may manually run apt-get or any of the 
above later"
        db_subst base-config/pkgsel choices $choices
        db_fset base-config/pkgsel seen false
        db_input high base-config/pkgsel || true
        db_go || exit 30 # to main menu
        db_get base-config/pkgsel
        echo $RET >&5 # to the caller on special fd
else
        run () {
                # Make dpkg not background itself to get a shell.
                export DPKG_NO_TSTP="yes"
                        
                clear
                $1 $2 $3 $4 $5 $6 $7 $8 || true
                clear
        }

        
        # Make popularity-contest be selected for installation by default. It
        # lets the user choose whether or not to enable it. We need more
        # people using this so we can hope to get better data about who is
        # using what packages in debian.
        echo popularity-contest install | dpkg --set-selections
        
        # X needs three packages installed before its debconf config is run
        # to make it do hardware autodetection. The only way to make sure these
        # are installed properly is to install them now, before packages are
        # selected. This way, even if the user picks xserver-xfree86 in
        # aptitude and installs using aptitude, they will be available.
        for pkg in discover mdetect read-edid ; do
                if ! dpkg --get-selections | grep "$pkg" | grep -q install; then
                        extra="$pkg $extra"
                fi
        done
        if [ "$extra" ] ; then
                apt-get -y -f install $extra >/dev/null 2>&1 || true
                # They are removed later on if it looks like X was not selected.
                echo $extra > $TMPDIR/tmp-Xhack
        fi
        
        # Get the program to run. Gross.
        TMP=$(tempfile)
        $0 select 5>$TMP
        SEL="`cat $TMP`"
        rm -f $TMP
        
        # I'm banking on the program names not being translated to
        # something else, since I have to match against possibly localized
        # return values. Of course "nothing" may be translated, so I match
        # it at the end.
        case "$SEL" in
        *dselect*)
                run dselect select
        ;;
        *aptitude*)
                run aptitude
        ;;
        *tasksel*)
                run tasksel -riqs
        ;;
        *)
                exit 0
        esac
fi

--- NEW FILE: apt-setup.mnu ---
Only-New: false
Debconf: true
Order: 70

--- NEW FILE: timezone ---
#!/bin/sh -e
# Use tzsetup because it's just like tzconfig but has a debconf UI
# (Also, it can ask about whether the hardware clock is GMT..)
if [ "$1" = new ]; then
        tzsetup -y -g -U
else
        tzsetup -y -g
fi

--- NEW FILE: pkgsel.mnu ---
Only-New: false
Debconf: false
Order: 80

--- NEW FILE: keyboard ---
#!/bin/sh -e
# Keyboard configuration.
#
# Note that this needs to run before any stuff that might ask for keyboard
# input..

ETC_FILE=/etc/console/boottime.kmap.gz

if [ -e /root/dbootstrap_settings ]; then
        . /root/dbootstrap_settings || true
fi

if [ "$1" = with_debconf ]; then
        . /usr/share/debconf/confmodule

        if [ ! -e $ETC_FILE ]; then
                # Work out the keymap file to install.
                if [ "$KEYBD" ]; then
                        KEYMAP=/usr/share/keymaps/${KEYBD}.kmap.gz
                else
                        db_get debian-installer/keymap
                        KEYMAP=$(find /usr/share/keymaps/ -name "$RET.kmap*")
                fi
                
                if [ ! -z "$KEYMAP" ]; then
                        # uses loadkeys, which outputs non-errors to stderr,
                        # so ignore
                        install-keymap $KEYMAP >/dev/null 2>&1 || true
                fi
        fi
else
        $0 with_debconf
        if [ ! -e $ETC_FILE ]; then
                # This part cannot be run under debconf.
                if [ ! -e $ETC_FILE -a -f /bin/loadkeys ]; then
                        dpkg-reconfigure --unseen-only --default-priority console-data 
|| true
                fi
        fi
fi

--- NEW FILE: passwd.mnu ---
Only-New: false
Debconf: false
Order: 40

--- NEW FILE: shell.mnu ---
Only-New: false
Debconf: false
Order: 9999

--- NEW FILE: apt-setup ---
#!/bin/sh -e
# Set up apt sources list.

# On new installs, comment out the shipped sources.list, since it assumes
# they are on the network, which is wrong if this is a CD install (this may
# no longer br true; debootstrap generates a pretty decent sources.list).
# Anyway apt-setup generates a better one. Touch the file in any case, because
# apt-setup requires it exist.
touch /etc/apt/sources.list
if [ "$1" = "new" ]; then
        sed 's/^\([^#]\)/#\1/' /etc/apt/sources.list > /etc/apt/sources.list.new
        mv -f /etc/apt/sources.list.new /etc/apt/sources.list
fi

# Probe for cd's in the drive prior to setting up apt.
apt-setup probe

# Update available file; tasksel and dselect need it later.
# (but first, get the configuration from /etc/apt/apt.conf)
DPKG="/usr/bin/dpkg"
DPKG_OPTS="--admindir=/var/lib/dpkg"
APTCACHE="/usr/bin/apt-cache"
CACHEDIR="/var/cache/apt"
RES=`apt-config shell \
      DPKG Dir::Bin::dpkg/f \
      APTCACHE Dir::Bin::apt-cache/f \
      CACHEDIR Dir::Cache/d \
`
eval $RES
$APTCACHE dumpavail > $CACHEDIR/available
$DPKG "$DPKG_OPTS" --update-avail $CACHEDIR/available >/dev/null
rm -f $CACHEDIR/available

--- NEW FILE: pon ---
#!/bin/bash -e
# Set up and enable ppp so that it can use used to download packages
# a little later on.
. /usr/share/debconf/confmodule

db_capb backup

# s/390 has no ppp
machine=`uname -m`
if [ $machine = s390 ]; then
        exit 0
fi

# If the system has a default route, I assume that there is no point in
# setting up ppp for that system as it's already on some kind of network.
# route -n to avoid dns timeout delays.
# TODO: may need updates for ipv6
if route -n | grep -q '^0\.0\.0\.0'; then
        exit 0
fi

if [ -e /usr/bin/pon ]; then
        # Should ppp be used?
        db_fset base-config/use-ppp seen false
        db_input high base-config/use-ppp || true
        db_go || exit 30 # to main menu
        db_get base-config/use-ppp
        if [ "$RET" = true ]; then
                # Set up ppp if not already set up.
                # /usr/share/ppp/provider.peer is the new location, but
                # /usr/share/doc/ppp/examples/provider.peer is used by the
                # version in testing at the time this is written.
                RECONFIGPPP=0
                if [ ! -e /etc/ppp/peers/provider ]; then
                        RECONFIGPPP=1
                elif [ -e /usr/share/ppp/provider.peer ] &&
                     cmp -s /etc/ppp/peers/provider /usr/share/ppp/provider.peer; then
                        RECONFIGPPP=1
                elif [ -e /usr/share/doc/ppp/examples/provider.peer ] &&
                     cmp -s /etc/ppp/peers/provider 
/usr/share/doc/ppp/examples/provider.peer; then
                        RECONFIGPPP=1
                fi
                if [ "$RECONFIGPPP" = 1 ]; then
                        pppconfig --noname </dev/tty >/dev/tty || true
                fi
                # redirect 3 so it goes to background w/o
                # hanging debconf later..
                pon </dev/tty >/dev/tty 2>/dev/tty 3>/dev/tty || true
                # TODO: this should be much more robust. What if ppp
                # fails to dial?
        fi
fi

--- NEW FILE: intro.mnu ---
Only-New: true
Debconf: true
Order: 10

--- NEW FILE: hostname.mnu ---
Only-New: false
Debconf: true
Order: 50

--- NEW FILE: mta.mnu ---
Only-New: false
Debconf: false
Order: 100

--- NEW FILE: apt-get.mnu ---
Only-New: false
Debconf: false
Order: 90

--- NEW FILE: passwd ---
#!/bin/sh -e
# Password setup is done by the passwd package.
if [ "$1" = new ]; then
        exec dpkg-reconfigure --unseen-only --default-priority passwd
else
        exec dpkg-reconfigure --default-priority passwd
fi

--- NEW FILE: apt-get ---
#!/bin/bash -e
# Run apt to install any selected packages.

case "$1" in
''|new)
        clear

        # Make dpkg not background itself to get a shell.
        export DPKG_NO_TSTP="yes"
        
        # Set DEBIAN_FRONTEND, since some evil postinst scripts still
        # check it directly.
        if [ -z "$DEBIAN_FRONTEND" ] ; then
                DEBIAN_FRONTEND=$($0 get_frontend 4>&1 || true)
                if [ "$DEBIAN_FRONTEND" ] ; then
                        export DEBIAN_FRONTEND
                else
                        unset DEBIAN_FRONTEND || true
                fi
        fi
        
        if apt-get -y -f dselect-upgrade; then
                if [ "$KEEP_BASE_DEBS" != yes ]; then
                        apt-get -f clean || true
                fi
        else
                $0 failure
                # Jump to the menu.
                exit 1
        fi

        # If X was not installed, remove the three hardware detection
        # programs. Of course, this fails if the user manually picked
        # to install these, or wants them installed for some other reason.
        # But I cannot help that.
        if ! dpkg --get-selections | grep xserver-xfree86 | grep -q install; then
                if [ -f $TMPDIR/tmp-Xhack ] ; then
                        extra=`cat $TMPDIR/tmp-Xhack`
                        dpkg --purge $extra >/dev/null 2>&1 || true
                        rm $TMPDIR/tmp-Xhack
                fi
        fi
        ;;
failure)
        # This branch is reached if there was some problem installing.
        # It uses debconf (which the other branch cannot use) to explain
        # the failure to the user.
        . /usr/share/debconf/confmodule
        db_settitle base-config/title
        db_fset base-config/install-problem seen false
        db_input critical base-config/install-problem || true
        db_go || true
        ;;
get_frontend)
        . /usr/share/debconf/confmodule
        db_get debconf/frontend
        # Convert to lower case to avoid warning from newer debconf
        echo $RET | tr A-Z a-z >&4
        ;;
esac

--- NEW FILE: finish ---
#!/bin/bash -e
# Finish up the install, clean up anything necessary, and get the user to a
# login prompt.

. /usr/share/debconf/confmodule

db_capb backup

if [ "$1" = new ]; then
        # If a display manager is installed, ask about starting it.
        SERVICES=""
        for service in xdm gdm kdm; do
                if test -x /etc/init.d/$service; then
                        SERVICES="$service $SERVICES"
                fi
        done
        if [ "$SERVICES" ]; then
                db_fset base-config/start-display-manager seen false
                db_input low base-config/start-display-manager || true
                db_go || exit 30 # back up to menu
        fi
        
        # Display the final message.
        db_fset base-config/login seen false
        db_input high base-config/login || true
        db_go || exit 30 # back up to menu TODO should use state machine
        
        # Turn on console screen blanking again
        if which setterm >/dev/null 2>&1; then
                # It seem to be impossible to get the current timeout
                # value before changing it, so the only way to
                # undo the setting is to set the timeout period to some
                # random value. 10 minutes sounds like a good value.
                setterm -blank 10 </dev/tty >/dev/tty
        fi

        # s/390 has this weird system where you telnet in to run base-config.
        # Now that that's done, clean up after the root telnet hacks the s390
        # installer put in place.
        machine=`uname -m`
        if [ $machine = s390 ]; then
                # Reenable security for s390 now that installation has
                # been finished. Drop base-config call from /root/.profile
                sed -e 's/#password   required   pam_unix.so nullok obscure min=4 
max=8/password   required   pam_unix.so nullok obscure min=4 max=8/' 
</etc/pam.d/passwd >/etc/pam.d/passwd.tmp
                mv -f /etc/pam.d/passwd.tmp /etc/pam.d/passwd
                sed -e '/pts\//d' </etc/securetty >/etc/securetty.tmp
                mv -f /etc/securetty.tmp /etc/securetty
                sed -e '/\/usr\/sbin\/base-config/d' </root/.profile 
>/root/.profile.tmp
                mv -f /root/.profile.tmp /root/.profile
        fi
        
        # Start the display manager
        db_get base-config/start-display-manager
        if [ "$RET" = true ]; then
                for service in $SERVICES ; do
                        # Try to avoid trouble with debconf.
                        /etc/init.d/$service restart </dev/tty >/dev/tty 3>/dev/null 
|| true
                done
        fi

        # Finally, put the real inittab into place and tell init.
        if [ -f /etc/inittab.real ]; then
                mv -f /etc/inittab.real /etc/inittab
                telinit q >/dev/null
                rm -f /root/dbootstrap_settings # now that we're done with it
                # Clear the screen, in preparation for the login prompt
                clear </dev/tty >/dev/tty
        fi
fi


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to