#!/bin/bash
#================
# FILE          : config.sh
#----------------
# PROJECT       : OpenSuSE KIWI Image System
# COPYRIGHT     : (c) 2006 SUSE LINUX Products GmbH. All rights reserved
#               :
# AUTHOR        : Marcus Schaefer <ms@suse.de>
#               :
# BELONGS TO    : Operating System images
#               :
# DESCRIPTION   : configuration script for SUSE based
#               : operating systems
#               :
#               :
# STATUS        : BETA
#----------------
#======================================
# Functions...
#--------------------------------------
test -f /.kconfig && . /.kconfig
test -f /.profile && . /.profile

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

#======================================
# Mount system filesystems
#--------------------------------------
baseMount

#======================================
# Add missing gpg keys to rpm
#--------------------------------------
suseImportBuildKey

#======================================
# Activate services
#--------------------------------------
suseInsertService sshd
suseInsertService mgr-preregister

#======================================
# Setup default target, multi-user
#--------------------------------------
baseSetRunlevel 3

#==========================================
# remove package docs
#------------------------------------------
rm -rf /usr/share/doc/packages/*
rm -rf /usr/share/doc/manual/*
rm -rf /opt/kde*

#======================================
# only basic version of vim is
# installed; no syntax highlighting
#--------------------------------------
sed -i -e's/^syntax on/" syntax on/' /etc/vimrc

baseUpdateSysConfig /etc/sysconfig/network/dhcp DHCLIENT_SET_HOSTNAME yes
baseUpdateSysConfig /etc/sysconfig/ntp NTPD_FORCE_SYNC_ON_STARTUP "yes"
baseUpdateSysConfig /etc/sysconfig/ntp NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP "yes"


#======================================
# SuSEconfig
#--------------------------------------
suseConfig

#======================================
# Remove unneeded packages
#--------------------------------------
suseRemoveYaST
rpm -e cron logrotate --nodeps
rpm -e glibc-locale xz bzip2 dirmngr \
       perl-Bootloader gfxboot gfxboot-branding-SLE \
       perl-HTML-Parser perl-HTML-Tagset --nodeps

# drop more unneeded code/data
rm -rf usr/{share,lib}/locale/{[^e],e[^n]}*
rm -rf lib/modules/*/kernel/{sound,drivers/{bluetooth,pcmcia,isdn,media,net/wireless,net/irda,parport,platform/x86/{*wmi.ko,*laptop.ko}}} # 22MB
rm -f usr/lib/perl5/*/*/auto/Encode/??/??.so # 9MB

# remove the product file
rm -f /etc/products.d/*

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

ln -s /sbin/init /init

exit 0

