source: appstream-generator/contrib/update-metadata.sh.example @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 973 bytes
Line 
1#!/bin/bash
2#
3# Example script for updating AppStream metadata using appstream-generator.
4# This script can easily be run by a cronjob.
5#
6
7set -e
8set -o pipefail
9set -u
10
11SUITES="sid stretch"
12
13WORKSPACE_DIR="/srv/appstream/workspace"
14PUBLIC_DIR="/srv/appstream/public"
15
16# only run one instance of the script
17LOCKFILE="$WORKSPACE_DIR/.lock"
18cleanup() {
19    rm -f "$LOCKFILE"
20}
21
22if ! lockfile -r8 $LOCKFILE; then
23    echo "aborting AppStream metadata extraction because $LOCKFILE has already been locked"
24    exit 0
25fi
26trap cleanup 0
27
28# Start logging
29logdir="$WORKSPACE_DIR/logs/`date "+%Y/%m"`"
30mkdir -p $logdir
31NOW=`date "+%d_%H%M"`
32LOGFILE="$logdir/${NOW}.log"
33exec >> "$LOGFILE" 2>&1
34
35cd $WORKSPACE_DIR
36
37# generate fresh metadata
38for suite in $SUITES; do
39    appstream-generator process $suite
40done
41
42# Sync updated data to public directory
43rsync -ak --delete-after --link-dest="$PUBLIC_DIR/" "$WORKSPACE_DIR/export/" "$PUBLIC_DIR/"
44
45# finish logging
46exec > /dev/null 2>&1
Note: See TracBrowser for help on using the repository browser.