source: appstream-generator/contrib/cleanup-cruft.sh.example @ 4841

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

Initial release

File size: 745 bytes
Line 
1#!/bin/bash
2#
3# Script cleaning up the AppStream metadata pool and cache.
4# This script should be run by a cronjob (e.g. every week).
5#
6
7set -e
8set -o pipefail
9set -u
10
11WORKSPACE_DIR="/srv/appstream/workspace"
12
13# only run one instance of the script
14LOCKFILE="$WORKSPACE_DIR/.lock"
15cleanup() {
16    rm -f "$LOCKFILE"
17}
18
19if ! lockfile -r8 $LOCKFILE; then
20    echo "aborting AppStream metadata cleanup because $LOCKFILE has already been locked"
21    exit 0
22fi
23trap cleanup 0
24
25# Start logging
26logdir="$WORKSPACE_DIR/logs/`date "+%Y/%m"`"
27mkdir -p $logdir
28NOW=`date "+%d_%H%M"`
29LOGFILE="$logdir/${NOW}_cleanup.log"
30exec >> "$LOGFILE" 2>&1
31
32cd $WORKSPACE_DIR
33
34# Cleanup superseded data
35appstream-generator cleanup
36
37# finish logging
38exec > /dev/null 2>&1
Note: See TracBrowser for help on using the repository browser.