aaa_base/aaa_base.post

364 lines
12 KiB
Bash

#!/bin/bash
#
#
# post.sh - to be done after extraction
#
# Copyright (c) 2003 SuSE Linux AG Nuernberg, Germany.
#
#
# Run this script in C-Locale, or some tools will fail.
export LC_ALL=C
#
# to make shure, var/lib/YaST/bin/bootsetup runs fine, delete
# usr/lib/YaST/.configured2
test -e usr/lib/YaST/.configured2 && rm -f usr/lib/YaST/.configured2
#
# there are some installation with an etc/psdevtab, which is only readable
# for root - this slows ps for any other user. starting ps as root, creates
# it, when it doesn't exist (readable). So simply delete it.
#
test -e etc/psdevtab && rm -f etc/psdevtab
#
# if the old inittab contains "/sbin/init.d", move it away
# and use inittab.rpmnew. RPM will overwrite old rpmnew files, so this
# should really the new one.
#
test -f etc/inittab.rpmnew && grep sbin.init.d etc/inittab >/dev/null 2>&1 && {
mv -f etc/inittab etc/inittab.sbin.init.d
mv -f etc/inittab.rpmnew etc/inittab
}
#
# if the old nsswitch.conf contains dns6, replace it with dns
#
test -f etc/nsswitch.conf.rpmnew && grep dns6 etc/nsswitch.conf >/dev/null 2>&1 && {
cp etc/nsswitch.conf etc/nsswitch.conf.aaa_base
sed "s|dns6|dns|g" < etc/nsswitch.conf.aaa_base > etc/nsswitch.conf
}
#
# the following rc.config-variables changed their names during the releases,
# so we have to change them here ...
# FONT to CONSOLE_FONT
# TRANSLATION to CONSOLE_UNICODEMAP
# GMT to HWCLOCK
# replace CREATE_RESOLVCONF by comment
# comment out NAMESERVER
# comment out SEARCHLIST
# comment out LANGUAGE
# delete umask line
#
if test -s etc/rc.config ; then
sed -e"s/^FONT=/CONSOLE_FONT=/" \
-e"s/^TRANSLATION=/CONSOLE_UNICODEMAP=/" \
-e"s/^GMT=/HWCLOCK=/" \
-e"s/^CREATE_RESOLVCONF=.*/# Update: SuSEconfig will no longer touch resolv.conf/" \
-e"s/^NAMESERVER=\(.*\)/# NAMESERVER=\1/" \
-e"s/^SEARCHLIST=\(.*\)/# SEARCHLIST=\1/" \
-e"s/^umask .*//" \
-e"s/^test \$rc_done=/test \"\$rc_done\"=/" \
-e"s/^LANGUAGE=/# LANGUAGE=/" etc/rc.config \
> etc/rc.config.t && mv etc/rc.config.t etc/rc.config
rm -f etc/rc.config.t
fi
# GMT might already be in sysconfig/clock
%{rename_sysconfig_variable -f etc/sysconfig/clock GMT HWCLOCK}
# XXX uncommented temporary
if [ -e etc/aaa_base_debug -a ! -e etc/rc.config ]; then
cat << EOF > etc/rc.config
#
# /etc/rc.config
#
# Copyright (c) 1996-2002 SuSE Linux AG Nuernberg, Germany.
# All rights reserved.
#
# Author: Werner Fink <werner@suse.de>, 1996
# Burchard Steinbild, 1996
#
# The configuration databases for shell scripts in /etc/init.d,
# /sbin/SuSEconfig and /etc/cron.daily/suse.de-* can now be found
# in the /etc/sysconfig directory. This file should not be used any
# longer and will disappear in one of the next releases.
#
# Please edit the files in the /etc/sysconfig directory and execute
# /sbin/SuSEconfig to configure everything.
#
EOF
chmod 644 etc/rc.config
fi
#
# Initialize runlevel links
#
%{fillup_and_insserv -py boot.proc boot.localfs boot.swap boot.clock boot.ldconfig boot.ipconfig boot.klog boot.localnet halt random reboot single nfs}
%{fillup_and_insserv -psy boot.crypto START_CRYPTO_FILESYSTEMS}
%{insserv_force_if_yast etc/init.d/boot.loadmodules etc/init.d/boot.cleanup etc/init.d/boot.rootfsck}
## powerfail probably needs empty header ...
# add Kill-links in boot.d if needed:
for i in proc localfs swap clock ldconfig ipconfig klog localnet crypto loadmodules sched ; do
if [ -f /etc/init.d/boot.d/S??boot.$i -a ! -f /etc/init.d/boot.d/K??boot.$i ] ; then
%{insserv_force_if_yast boot.$i}
fi
done
#
# remove old stuff from rc.config
if [ -x bin/fillup -a -f etc/rc.config ] ; then
bin/fillup -q -t -r -i -d "=" etc/rc.config var/adm/fillup-templates/removed_variables.aaa_base /dev/null
test -s etc/rc.config.new && mv etc/rc.config.new etc/rc.config
fi
%{remove_and_set -n security CONSOLE_SHUTDOWN}
%{remove_and_set -n suseconfig CHECK_INITTAB}
%{remove_and_set -n suseconfig HALT_SOUND}
if ! [ -d etc/sysconfig ] ; then
mkdir -p etc/sysconfig
fi
# language was called lang before
if [ ! -f etc/sysconfig/language -a -f etc/rc.config.d/lang.rc.config ] ; then
mv etc/rc.config.d/lang.rc.config etc/sysconfig/language
fi
for i in language backup boot kernel \
suseconfig clock proxy windowmanager sysctl mail \
cron news shutdown sw_management ; do
%{fillup_only -n $i}
done
# migrate HALT_SOUND value if set before
if [ -n "$HALT_SOUND" -a "$HALT_SOUND" != "no" ] ; then
sed -e "s|^HALT_SOUND=.*|HALT_SOUND=\"$HALT_SOUND\"|" \
etc/sysconfig/shutdown > etc/sysconfig/shutdown.new \
&& mv etc/sysconfig/shutdown.new etc/sysconfig/shutdown
fi
# fix sysconfig backup dir
if grep -q RCCONFIG_BACKUP_DIR../var/adm/backup/rpmdb etc/sysconfig/backup; then
sed -e "s|^RCCONFIG_BACKUP_DIR=.*|RCCONFIG_BACKUP_DIR=\"/var/adm/backup/sysconfig\"|" \
etc/sysconfig/backup > etc/sysconfig/backup.new \
&& mv etc/sysconfig/backup.new etc/sysconfig/backup
mkdir -p /var/adm/backup/sysconfig
mv /var/adm/backup/rpmdb/sysconfig[-_]* /var/adm/backup/sysconfig 2>/dev/null
fi
# clear old install settings of MODULES_LOADED_ON_BOOT
eval `grep "^MODULES_LOADED_ON_BOOT" etc/sysconfig/kernel`
MLOB_NEW=""
for i in $MODULES_LOADED_ON_BOOT ; do
case $i in
capability|raw1394|video1394) continue ;;
esac
MLOB_NEW="$MLOB_NEW${MLOB_NEW:+ }$i"
done
if test "$MODULES_LOADED_ON_BOOT" != "$MLOB_NEW" ; then
sed -e "s|^MODULES_LOADED_ON_BOOT=.*|MODULES_LOADED_ON_BOOT=\"$MLOB_NEW\"|" \
etc/sysconfig/kernel > etc/sysconfig/kernel.new \
&& mv etc/sysconfig/kernel.new etc/sysconfig/kernel
rm -f etc/sysconfig/kernel.new
fi
#
# Backup gshadow file and remove it (merge passwords into
# /etc/group before).
#
if [ -f /etc/gshadow -a -x /usr/sbin/grpunconv ]; then
cp -p /etc/gshadow /etc/gshadow-`date "+%Y%m%d"`
chmod 600 /etc/gshadow-`date "+%Y%m%d"`
/usr/sbin/grpunconv
fi
#
# handle password files
#
for i in passwd group shadow ; do
test -e var/adm/fillup-templates/$i.aaa_base || continue
echo -n "Updating etc/$i..."
if test -f etc/$i ; then
cp etc/$i etc/$i.tmp
rm -f etc/$i.add
sort -k 1,1 -t: -u etc/$i var/adm/fillup-templates/$i.aaa_base \
| sort -k 1,1 -t: etc/$i - | uniq -u > etc/$i.add
cat etc/$i.add >> etc/$i
rm -f etc/$i.add
if cmp -s etc/$i etc/$i.tmp ; then
echo "unchanged"
else
echo "modified"
fi
rm -f etc/$i.tmp
# If we have a NIS system, we have to make sure, that "^+" is at the end
grep -v "^+" etc/$i > etc/$i.tmp || :
grep "^+" etc/$i >> etc/$i.tmp || :
test -s etc/$i.tmp && cat etc/$i.tmp > etc/$i
rm -f etc/$i.tmp
else
cat var/adm/fillup-templates/$i.aaa_base > etc/$i
echo "new"
fi
done
# check/fix owner and permission of shadow files
for i in etc/shadow ; do
chmod 640 $i
chgrp shadow $i
done
#
# make sure that nobody and nogroup are set to 65534 (we had -2 in former times)
#
for i in etc/passwd etc/group ; do
sed -e"s/:-2:/:65534:/g" -e"s/:-2:/:65534:/g" < $i > $i.t
test -s $i.t && {
cat $i.t > $i
}
rm -f $i.t
chmod 644 $i
done
#
# Change primary group of nobody to nobody
#
if [ -x /usr/sbin/usermod ]; then
/usr/sbin/usermod -g nobody nobody 2> /dev/null ||:
fi
#
# create mtab if it does not exist
#
touch etc/mtab
#
# make sure that several log files exist
#
if test ! -d var/log ; then
mkdir -p var/log
fi
touch var/log/faillog
chmod 600 var/log/faillog
touch root/.bash_history
chmod 600 root/.bash_history
chown root:root var/log/faillog
touch var/log/lastlog
chmod 644 var/log/lastlog
chown root:tty var/log/lastlog
touch var/log/wtmp
chmod 664 var/log/wtmp
chown root:tty var/log/wtmp
if test -e usr/sbin/usrdel.local -a ! -e usr/sbin/userdel.local ; then
cp usr/sbin/usrdel.local usr/sbin/userdel.local
fi
if test ! -e usr/sbin/userdel.local ; then
mkdir -p usr/sbin
cat << EOT > usr/sbin/userdel.local
#!/bin/bash
#
# Here you can add your own stuff, that should be done for every user who
# will be deleted.
#
# When you delete a user with YaST, this script will be called
# with the login name as parameter. The rest of data can be taken
# from /etc/passwd.
#
EOT
chmod 744 usr/sbin/userdel.local
fi
##
## generate permissions.local
##
for suffix in rpmorig rpmsave ; do
if test -e etc/permissions.local.$suffix -a ! -e etc/permissions.local ; then
mv etc/permissions.local.$suffix etc/permissions.local
fi
done
if test ! -e etc/permissions.local ; then
cat << EOT > etc/permissions.local
#
# /etc/permissions.local
#
# Description: Roman Drahtmueller <draht@suse.de>, 2001
#
# This file is used by SuSEconfig and chkstat to check or set the modes
# and ownerships of files and directories in the installation.
#
# In particular, this file will not be touched during an upgrade of the
# SuSE Linux installation. It is designed to be a placeholder for local
# additions by the administrator of the system to reflect filemodes
# of locally installed packages (usually under /opt/local or /usr/local).
#
# Format:
# <file> <owner>.<group> <permission>
#
# Please see the file /etc/permissions for general usage hints of the
# /etc/permissions* files.
# Keep in mind that this file (/etc/permissions.local) is being used by
# default by SuSEconfig, the shell script that is used by yast and yast2
# after package installation and configuration changes to make the changes
# effective for the respective packages (eg generating the "real"
# configuration files).
# Always check if there are no conflicts between your \"local\" changes here
# and the settings in the other permissions files by calling
# \"SuSEconfig\" as root!
# Please remember that logfiles might be modified by the logfile
# rotation facilities (e.g. logrotate) so local settings might
# be overridden.
#
# example:
#/usr/local/bin/mtr root.root 4755
EOT
chmod 644 etc/permissions.local
fi
#
# Now do the ugly part. Delete mess from former times...
#
if test -L usr/i486-linux-libc6/lib/libqimgio.so ; then
rm -f usr/i486-linux-libc6/lib/libqimgio.so
fi
### import suse package build key to gpg keyring
if test -f root/.gnupg/pubring.gpg ; then
if test -x usr/bin/gpg -a -f usr/lib/libgdbm.so.2 ; then
chroot . usr/bin/gpg --export --armor --no-default-keyring \
--keyring root/.gnupg/suse_build_key build@suse.de \
| chroot . usr/bin/gpg --import || true
if ! chroot . usr/bin/gpg --list-keys build@suse.de >/dev/null 2>&1 ; then
echo "gpg import for build@suse.de failed, please import manually" >&2
fi
fi
else
cp root/.gnupg/suse_build_key root/.gnupg/pubring.gpg
fi
chmod 600 root/.gnupg/suse_build_key root/.gnupg/pubring.gpg
# change all /media mounts (subfs) to noauto
if test -f /etc/fstab ; then
rm -f /etc/fstab.$$
sed -e '/^[[:space:]]*#/{p;d}' -e '/[[:space:]]subfs.*noauto/{p;d}' -e '/\/media.*fs=\(cdfss\|floppyfss\)/s/\([[:space:]]subfs[[:space:]][[:space:]]*\)/\1noauto,/' < /etc/fstab > /etc/fstab.$$
cmp -s /etc/fstab /etc/fstab.$$ || {
mv /etc/fstab.$$ /etc/fstab
chmod 644 /etc/fstab
}
rm -f /etc/fstab.$$
fi
# IA64 Altix update hook
if test -d /proc/sgi_sn ; then
if grep -q "console=ttyS0" /etc/elilo.conf ; then
echo "replacing ttyS0 by ttySG0 in elilo.conf, inittab and securetty files"
#
rm -f /etc/elilo.conf.tmp
sed -e "s/console=ttyS0/console=ttySG0/g" /etc/elilo.conf > /etc/elilo.conf.tmp
cat /etc/elilo.conf.tmp > /etc/elilo.conf
rm -f /etc/elilo.conf.tmp
#
rm -f /etc/inittab.tmp
sed -e "s/getty\(.*\)ttyS0/getty\1ttySG0/g" /etc/inittab > /etc/inittab.tmp
cat /etc/inittab.tmp > /etc/inittab
rm -f /etc/inittab.tmp
#
rm -f /etc/securetty.tmp
sed -e "s/ttyS0/ttySG0/g" /etc/securetty > /etc/securetty.tmp
cat /etc/securetty.tmp > /etc/securetty
rm -f /etc/securetty.tmp
#
if grep -q /boot/efi /proc/mounts ; then
echo "calling elilo to update"
/sbin/elilo || true
fi
fi
fi
exit 0