#!/bin/bash

. /tmp/hooks/lgp.functions

LGP_MIRRORFILE=/etc/apt/sources.list.d/lgp.list

# exits now if no mirror to add
[ -z "$LGP_OTHERMIRRORS" ] && exit 0

echo "$LGP_OTHERMIRRORS" > $LGP_MIRRORFILE

# we have to check immediately that the new mirror list is correct
if apt-get update > /dev/null; then
	print_hook "add new sources.list content in $LGP_MIRRORFILE:\n$LGP_OTHERMIRRORS"
else
	wprint_hook "invalid sources.list content in $LGP_MIRRORFILE:\n$LGP_OTHERMIRRORS"
	echo
	wprint_hook "these entries will be removed."
	rm -f $LGP_MIRRORFILE
fi

