#!/bin/bash

OLDSOURCES="/etc/apt/oldsources.paedml.$$"

echo "Dieses Skript macht aus einer PaedML(R) Linux 5.1"
echo "ein freies linuxmuster.net System."
echo "Dabei werden folgende Änderungen vorgenommen:"
echo
echo "  * Alle Paketquellen in /etc/apt/sources.list sowie "
echo "    in /etc/apt/sources.list.d werden zurückgesetzt."
echo "    Alle bisherigen Repos werden in der Datei  "
echo "    /etc/apt/oldsources.paedml.$$ gesammelt."
echo
echo "  * Der linuxmuster.net Release-Key wird importiert "
echo
echo "  * Die Paketlisten werden aktualisiert "
echo
echo "  * Das Paket linuxmuster-freefork wird installliert,"
echo "    welches möglicherweise  weitere Pakete nachzieht"
echo "    und/oder deinstalliert, so dass aus der PaedML ein"
echo "    linuxmuster.net-System wird"
echo

echo "Sind Sie sicher? [ja/NEIN]"

read answer

if [ $answer != "ja" ]; then
    echo "Um den Prozess zu starten, müssen Sie 'ja' eingeben."
        echo "Breche ab."
    exit 1
fi


# Sources sammeln
echo "# /etc/apt/sources.list" > $OLDSOURCES
cat /etc/apt/sources.list >> $OLDSOURCES
echo "" >> $OLDSOURCES

for i in /etc/apt/sources.list.d/*.list; do
   echo "# $i " >> $OLDSOURCES
   cat $i >> $OLDSOURCES
   echo "" >> $OLDSOURCES
done

# Sources löschen
rm -f /etc/apt/sources.list.d/*

# Neu anlegen
echo "# Debian Lenny Archive" > /etc/apt/sources.list
echo "deb http://archive.debian.org/debian/ lenny main non-free contrib" >> /etc/apt/sources.list
echo "deb-src http://archive.debian.org/debian/ lenny main non-free contrib" >> /etc/apt/sources.list

echo "# linuxmuster.net Sicherheitsupdates" > /etc/apt/sources.list.d/linuxmuster.net.security.list
echo "deb http://pkg.linuxmuster.net/ openml5-security/ " >> /etc/apt/sources.list.d/linuxmuster.net.security.list
echo "deb-src http://pkg.linuxmuster.net/ openml5-security/ " >> /etc/apt/sources.list.d/linuxmuster.net.security.list

echo "# linuxmuster.net Stable" > /etc/apt/sources.list.d/linuxmuster.net.stable.list
echo "deb http://pkg.linuxmuster.net/ openml5-stable/ " >> /etc/apt/sources.list.d/linuxmuster.net.stable.list
echo "deb-src http://pkg.linuxmuster.net/ openml5-stable/ " >> /etc/apt/sources.list.d/linuxmuster.net.stable.list

echo "# linuxmuster.net Addons" > /etc/apt/sources.list.d/linuxmuster.net.addons.disabled
echo "deb http://pkg.linuxmuster.net/ openml5-addons/ " >> /etc/apt/sources.list.d/linuxmuster.net.addons.disabled
echo "deb-src http://pkg.linuxmuster.net/ openml5-addons/ " >> /etc/apt/sources.list.d/linuxmuster.net.addons.disabled

echo "# linuxmuster.net Testing" > /etc/apt/sources.list.d/linuxmuster.net.testing.list
echo "deb http://pkg.linuxmuster.net/ openml5-testing/ " >> /etc/apt/sources.list.d/linuxmuster.net.testing.list
echo "deb-src http://pkg.linuxmuster.net/ openml5-testing/ " >> /etc/apt/sources.list.d/linuxmuster.net.testing.list

# Key holen und hinzufügen
wget http://pkg.linuxmuster.net/linuxmuster.net.key -O - | apt-key add -

apt-get update -qq
apt-get install linuxmuster-freefork

/etc/init.d/apache2 restart

mv /etc/apt/sources.list.d/linuxmuster.net.testing.list /etc/apt/sources.list.d/linuxmuster.net.testing.disabled
apt-get update -qq





