# netprofile module
#
# this module contains settings for saving/restore the urpmi settings

NAME="urpmi"
DESCRIPTION="Urpmi settings"

# list of files to be saved by netprofile
FILES="/etc/urpmi/
/var/lib/urpmi/"

function restore {
        if [ ! -d /var/lib/urpmi/ ]; then
                # we need to update the synthesis files
                mkdir /var/lib/urpmi
                log "The urpmi database is out of sync, updating now"
                notify "The urpmi database is out of sync, updating now"
                # network could still be down, so retry a few times
                for retry in $(seq 1 5); do 
                        urpmi.update -a
                        ret=$?
                        if [ ! "$ret" = "0" ]; then
                                sleep 1
                                continue
                        else
                                break
                        fi
                done
                if [ ! "$ret" = "0" ]; then
                        log "Was unable to update urpmi cache"
                        notify "The urpmi database could not be updated at this time because the network was not ready. You will have to update it manually for this network profile."
                fi
        fi
}
