#!/bin/bash
# bootpartition sichern, soweit vorhanden
# (c) 2013 Stefan Schaefer -- invis-server.org
# Mail: stefan@invis-server.org
# Questions: http://forum.invis-server.org

# Konfigurationsdaten
conffile="/etc/invis/invis.conf"
passfile="/etc/invis/invis-pws.conf"

# Funktionen
# Werte aus Konfigurationsdatendatei extrahieren
# $1 = Konfigurationsdatei, $2 = Parameter, $3 Wert (Feld)
getconfdata() {
    cat $1 |grep "$2" | cut -d ":" -f $3
}

## Sicherungsverzeichnis

dasibase=`getconfdata $conffile "DasiDir" "2"`
dasidir="$dasibase/bootpartition"

if [[ ! -d $dasidir ]]; then
    mkdir -p $dasidir
fi

bootpart=`mount | grep "/boot "| cut -d " " -f1`
datum=`date +%Y%m%d`

if [[ -n $bootpart ]]; then
    echo "Ein Image der Bootpartition wird angelegt"
    dd if=$bootpart of=$dasidir/bootpart-$datum.img
fi

