#!/bin/bash

function systemd_update_metadata_info()
{
    systemctl start lastore-update-metadata-info.service
}

function update_metadata_info()
{
    /usr/bin/lastore-tools update -r desktop -j applications -o /var/lib/lastore/applications.json
    /usr/bin/lastore-tools update -r desktop -j categories -o /var/lib/lastore/categories.json
    /usr/bin/lastore-tools update -r desktop -j mirrors -o /var/lib/lastore/mirrors.json
    /usr/bin/lastore-tools metadata -u --remote=http://cdn.packages.deepin.com/deepin/tree/lastore
}

if [[ -S /var/run/systemd/notify ]]; then
    systemd_update_metadata_info
else
    update_metadata_info
fi
