#!/bin/sh

PATH=$PATH:/sbin:/bin:/usr/bin:/usr/sbin

#
# here you can place whatever you want to do 
# when your system starts as a live system. 
#




##########################################
# clean stale links of apache conf files
#
if [ -d /etc/apache/conf.d ]; then
    for name in $(ls -1 /etc/apache/conf.d/*.conf 2>/dev/null); do
	if [ ! -e $name ]; then rm $name; fi
    done
fi

# 
rm -f /etc/nologin
rm -f /etc/crypttab

#
if [ -d /etc/network ]; then
    rm -f /etc/network/ifstate
    rm -f /etc/network/ifstate.hotplug
    touch /etc/network/ifstate
    touch /etc/network/ifstate.hotplug
fi


#
# probably you will not need all daemons in
# your live system
#
rm -f /etc/rc*.d/*ntpdate* 
rm -f /etc/rc*.d/*initrd*
rm -f /etc/rc*.d/*syslog*

#
# fix permissions for /etc/X11, this seems to be a bug
# in unionfs. Directories with man hardlinks get
# strange permissions.
#
if [ -d /etc/X11 ]; then
  chmod 755 /etc/X11 
fi


#########################################
# 
# fix unvisible mount point
#
mkdir -p /mnt/overlay



#
# if you have Xorg (e.g Ubuntu) you may like
# to generate a X11 config file
#
# (you do NOT need lb_hwdetect 
#  option (knoppix hardwaredetection) for ubuntu )
#
# this example shows how you could use additional
# boot options
#
if [ "$(grep x11config /proc/cmdline)" ]; then 
    if [ "$(which dpkg-reconfigure)" ]; then
	if [ "$(dpkg -l xserver-xorg | grep ^ii)" ]; then
	    dpkg-reconfigure -pcritical xserver-xorg
	fi
    fi
fi

