#!/bin/sh

install_from_default() {
  if [ ! -f $2 ]; then
    echo "Installing $2 from $1 ..."
    cp -p $1 $2
  fi
}

install_from_default /usr/share/base-files/dot.bash_profile /root/.bash_profile
install_from_default /usr/share/base-files/dot.bashrc       /root/.bashrc

if [ ! -f /var/run/utmp ]; then
	echo -n>/var/run/utmp
fi
if [ ! -f /var/log/wtmp ]; then
	echo -n>/var/log/wtmp
fi
chown root.root /var/run/utmp /var/log/wtmp
chmod 644 /var/run/utmp /var/log/wtmp

if [ ! -d /usr/local ]; then
	mkdir -m 755 -p /usr/local
	cd /usr/local && mkdir -m 755 -p bin man lib include sbin
fi

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 ]; then
	cat >/usr/info/dir << EOF
-*- Text -*-
This is the file .../info/dir, which contains the topmost node of
the Info hierarchy.  The first time you invoke Info you start off
looking at that node, which is (dir)Top.

File: dir	Node: Top	This is the top of the INFO tree
  This (the Directory node) gives a menu of major topics.  Typing "d"
  returns here, "q" exits, "?" lists all INFO commands, "h"  gives a
  primer for first-timers, "mTexinfo<Return>" visits Texinfo topic,
  etc.
  Or click mouse button 2 on a menu item or cross reference to select
  it.
  --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) ---

In Debian Linux, Info \`dir' entries are added with the command
\`install-info'.  Please refer to install-info(8) for usage details.

* Menu: The list of major topics begins on the next line.

General Commands

EOF
	chmod 644 /usr/info/dir
	chown root.root /usr/info/dir
fi
exit 0
