#!/bin/bash
#======================================
# Functions...
#--------------------------------------
test -f /.kconfig && . /.kconfig
test -f /.profile && . /.profile

#======================================
# Greeting...
#--------------------------------------
echo "Configure image: [$kiwi_iname]..."



## <*****BASIC CONFIGURATION*****>

#======================================
## Select the default runlevel of the final image.
## select 3 for commandline + networking
## select 5 for complete GUI + networking.
#--------------------------------------
#baseSetRunlevel 5  -- Doesn't seem to be implemented in kiwi.

#======================================
## If any files are dumped into home directories of any users, using archives, the following command will set the apprpriate permissions on those files.
#--------------------------------------
baseSetupUserPermissions

#======================================
# Activate services
#--------------------------------------
## Enabling iptables service by default.
if [ -f /etc/init.d/iptables ]; then 
	/sbin/chkconfig iptables on
fi

if [ -f /etc/init.d/auditd ]; then 
	/sbin/chkconfig auditd on 
fi 

### Disabling unnecessary services

if [ -f /etc/init.d/mcstrans ]; then
	/sbin/chkconfig mcstrans off    ### When using multi-level security, this service will provide translation from selinux categories to user defined representation.
fi


if [ -f /etc/init.d/avahi-daemon ]; then
	/sbin/chkconfig "avahi-daemon" off   ## Disabling the avahi client daemon
fi 

if [ -f /etc/init.d/lvm2-monitor ]; then
	/sbin/chkconfig --levels 12345 "lvm2-monitor" off  ## logical volumes not used in basic image
fi 

if [ -f /etc/init.d/netconsole ]; then 
	/sbin/chkconfig netconsole off  ## Service for directing console to remote syslog server.
fi

if [ -f /etc/init.d/netfs ]; then
	/sbin/chkconfig netfs off ## Service for mounting network file systems like nfs,cifs etc.
fi
if [ -f /etc/init.d/rawdevices ]; then 
	/sbin/chkconfig rawdevices off  ## primarily used by oracle to assign raw devices to block devices.
fi 

if [ -f /etc/init.d/xinetd ];then 
	/sbin/chkconfig xinetd off  ## disabling the super daemon
fi

#if [ -f /etc/init.d/kudzu ]; then 
#	/sbin/chkconfig kudzu off  ## used for detecting new hardware
#fi 

if [ -f /etc/init.d/gpm ]; then
	/sbin/chkconfig gpm off  ## Mouse support for text virtual consoles
fi 

#if [ -f /etc/init.d/xfs ]; then   
#	/sbin/chkconfig xfs off  ## The font sizes on the xterms cannot be increased, unless this service is enabled. So, leaving it on for now. 
#fi

if [ -f  /etc/init.d/irqbalance ]; then 
	/sbin/chkconfig irqbalance off  ## Disabling irqbalance because the VM has only one proc.
fi

if [ -f /etc/init.d/NetworkManager ]; then
	/sbin/chkconfig NetworkManager on  ## Turning this service on to configure the network interface automatically to DHCP. 
fi

if [ -f /etc/init.d/haldaemon ]; then 
	/sbin/chkconfig haldaemon off
fi

if [ -f /etc/init.d/ip6tables ]; then 
       /sbin/chkconfig ip6tables off ## disable the ipv6 firewall.
fi
 
## <*****END OF BASIC CONFIGURATION*****>




## <****HACKS && FIXES *****>
##### Hacks to get the build running 
ln -s /sbin/mksquashfs /usr/bin/mksquashfs
#####



## <***** END OF HACKS && FIXES *****>

#======================================
# Umount kernel filesystems
#--------------------------------------
baseCleanMount

exit 0
