#!/bin/sh set -e install_local_dir() { if [ ! -d $1 ]; then mkdir -p $1 fi #chown root:staff $1 2> /dev/null || true #chmod 2775 $1 2> /dev/null || true } install_from_default() { if [ ! -f $2 ]; then cp -p $1 $2 fi } install_directory() { if [ ! -d /$1 ]; then mkdir /$1 chown root:$3 /$1 chmod $2 /$1 fi } preserve_directory() { if [ -f /etc/base-files.create-$1 ]; then install_directory $1 755 root rm -f /etc/base-files.create-$1 fi } if [ ! -e /etc/dpkg/origins/default ]; then if [ -e /etc/dpkg/origins/ubuntu ]; then ln -sf ubuntu /etc/dpkg/origins/default fi fi if [ "$1" = "configure" ] && [ "$2" = "" ]; then install_from_default /usr/share/base-files/nsswitch.conf /etc/nsswitch.conf install_from_default /usr/share/base-files/dot.profile /root/.profile install_from_default /usr/share/base-files/dot.bashrc /root/.bashrc install_from_default /usr/share/base-files/profile /etc/profile install_from_default /usr/share/base-files/networks /etc/networks install_directory srv 755 root install_directory opt 755 root install_directory etc/opt 755 root install_directory var/opt 755 root install_directory media 755 root install_directory var/mail 2775 mail if [ ! -L /var/spool/mail ]; then ln -s ../mail /var/spool/mail fi install_local_dir /usr/local install_local_dir /usr/local/share install_local_dir /usr/local/share/man install_local_dir /usr/local/bin install_local_dir /usr/local/games install_local_dir /usr/local/lib install_local_dir /usr/local/include install_local_dir /usr/local/sbin install_local_dir /usr/local/src install_local_dir /usr/local/etc ln -sf share/man /usr/local/man if [ ! -f /var/log/wtmp ]; then echo -n>/var/log/wtmp fi if [ ! -f /var/log/btmp ]; then echo -n>/var/log/btmp fi if [ ! -f /var/log/lastlog ]; then echo -n>/var/log/lastlog fi chown root:utmp /var/log/wtmp /var/log/btmp /var/log/lastlog chmod 664 /var/log/wtmp /var/log/btmp /var/log/lastlog fi if [ "$1" = "configure" ] && [ "$2" != "" ]; then if [ ! -d /var/spool/mail ] && [ ! -L /var/spool/mail ]; then if [ -f /etc/base-files.mailsymlink ]; then ln -sf `cat /etc/base-files.mailsymlink` /var/spool/mail else install_directory var/spool/mail 2775 mail fi fi if [ ! -L /var/mail ] && [ ! -d /var/mail ]; then ln -sf spool/mail /var/mail fi fi preserve_directory floppy preserve_directory cdrom preserve_directory initrd if [ ! -f /var/run/utmp ]; then echo -n>/var/run/utmp fi chown root:utmp /var/run/utmp chmod 664 /var/run/utmp if [ ! -d /var/lib/dpkg ]; then mkdir -m 755 -p /var/lib/dpkg chown root:root /var/lib/dpkg fi if [ ! -f /var/lib/dpkg/status ]; then echo > /var/lib/dpkg/status chmod 644 /var/lib/dpkg/status chown root:root /var/lib/dpkg/status fi if [ ! -f /usr/info/dir ] && [ ! -f /usr/share/info/dir ]; then install_from_default /usr/share/base-files/info.dir /usr/share/info/dir chmod 644 /usr/share/info/dir chown root:root /usr/share/info/dir fi rm -f /etc/base-files.mailsymlink if dpkg --compare-versions "$2" lt 5.0.0ubuntu17 && [ ! -e "/etc/motd" ]; then # Create symlink on installation (or versioned upgrade); # thereafter, the admin is free to modify accordingly ln -sf /var/run/motd /etc/motd fi if [ "$1" = "configure" ] && [ "$2" != "" ]; then if [ -f /etc/motd.tail ]; then if dpkg --compare-versions "$2" lt-nl 5.0.0ubuntu13; then # motd.tail is no longer generated by this package; # rather, the sysadmin can use motd.tail to append # text to the pam_motd dynamically generated motd mv -f /etc/motd.tail /etc/motd.tail.old # Clear out old MOTD, will be regenerated on next login rm -f /var/run/motd fi fi # If we're upgrading base-files, remove the upgrade-available flag # maintained by update-manager, and rerun the release-upgrade check # immediately (in the background) to update the flag. rm -f /var/lib/update-notifier/release-upgrade-available if [ -x /usr/lib/update-manager/check-new-release ]; then /usr/lib/update-manager/check-new-release -q > /var/lib/update-notifier/release-upgrade-available & fi if [ -f /etc/profile ]; then md5=`md5sum /etc/profile | cut -f 1 -d\ ` if grep -qw "$md5" /usr/share/base-files/profile.md5sums; then cp /usr/share/base-files/profile /etc/profile fi fi fi # Ubiquity 1.9.4 thru 1.10.9 failed to set kernel permissions after # copying from the Live CD, leaving the file globally writable. if dpkg --compare-versions "$2" le-nl "4.0.4ubuntu2" && dpkg --compare-versions "$2" ge "4.0.1ubuntu5" then find -L /boot -name "vmlinu[zx]-*" -perm /g+w,o+w -print0 | xargs -0rt chmod g-w,o-w || true fi # Ubiquity 1.7.5 thru 1.10.9 failed to restore the group id of # the process to root after doing work as the Live CD user, creating # files with that user's group as a result. if dpkg --compare-versions "$2" le-nl "4.0.4ubuntu2" && dpkg --compare-versions "$2" ge "4.0.1ubuntu1" then NINER_NINER_PATHS=" \ /boot \ /etc \ /usr/lib/locale \ /var/backups \ /var/cache/apt \ /var/cache/debconf \ /var/cache/fontconfig \ /var/cache/fonts \ /var/cache/ldconfig \ /var/cache/anthy \ /var/lib/apt \ /var/lib/dpkg \ /var/lib/belocs \ /var/lib/gconf \ /var/lib/defoma \ /var/lib/locales \ /var/log/installer " NINER_NINER_SYMLINKS=" \ /initrd.img \ /vmlinuz \ /cdrom \ /media/cdrom \ /etc/alternatives \ /usr/share/fonts \ /var/lib/anthy \ /var/lib/defoma " find -L $NINER_NINER_PATHS -gid 999 -print0 | xargs -0rt chgrp -h 0 || true find $NINER_NINER_SYMLINKS -gid 999 -print0 | xargs -0rt chgrp -h 0 || true find /media -maxdepth 1 -name "cdrom[0-9]*" -gid 999 -print0 | xargs -0rt chgrp -h 0 || true fi # Dell Latitude 2110 factory pre-installed images carried a leftover apt # configuration snippet which disables apt's enforcing of authenticated # packages. if dpkg --compare-versions "$2" le-nl "5.0.0ubuntu20.10.04.2" && [ -e /etc/apt/apt.conf.d/00secure ]; then md5=`md5sum /etc/apt/apt.conf.d/00secure | cut -f 1 -d\ ` if [ "$md5" = da402e2c3a805e234ae7d20fa55580a6 ]; then rm /etc/apt/apt.conf.d/00secure fi fi