#!/bin/sh

# link the kernel and initrd for the inital package
cd /boot
ln -sf uImage-*.buffalo uImage.buffalo
ln -sf initrd-*.buffalo initrd.buffalo
# no search for .svn dir
# subversiontrees are used for /etc/portage & /var/lib/layman/go-genlink
# so remove manually
rm -rf /.svn
rm -rf /etc/.svn
rm -rf /etc/conf.d/.svn
rm -rf /etc/init.d/.svn
rm -rf /etc/layman/.svn
rm -rf /etc/profile.d/.svn
rm -rf /var/.svn
rm -rf /var/lib/.svn
rm -rf /var/lib/layman/.svn

# qemu-arm don't work with newer coreutils
# but the linkstation works with it
rm -f /etc/portage/package.mask/coreutils

# init bash profile for root
cp -Rv /etc/skel/.bash* /root/

# create the new portage dir
mkdir /usr/portage.new

# shrink the image by only syncing the requred dirs into /usr/portage
# the only dirs that survive are profiles (required), eclass (required), licenses (required)
# we have to use the IP as the resolve.conf file is already gone
# but a new one will be added in a later phase of catylast
rsync -aPv rsync://83.164.133.198/gentoo-portage/profiles /usr/portage.new/
rsync -aPv rsync://83.164.133.198/gentoo-portage/eclass /usr/portage.new/
rsync -aPv rsync://83.164.133.198/gentoo-portage/licenses /usr/portage.new/

# change password for root user
echo "root:goLsProLive" | chpasswd