#!/bin/bash

#Delete packages
apt-get clean

#Delete logs and apt lists
find /var/lib/apt/lists /var/log -type f | xargs rm

#Fill the device with zeros
dd if=/dev/zero of=/z bs=1M

#Remove the zero file
rm /z

#Remove m23debs (test sources)
grep -v "http://m23debs" /etc/apt/sources.list > /tmp/sources.list

#Add the URL for server update if missing
if [ `grep -c "m23inst.goos-habermann.de" /tmp/sources.list` -eq 0 ]
then
	echo "deb http://m23inst.goos-habermann.de ./" >> /tmp/sources.list
fi

cat /tmp/sources.list > /etc/apt/sources.list