Monty Taylor f1c86c66a3 Add AFS apt mirror
The reprepro class in this is in-tree rather than in its own module
purely for ease of getting started. It's also highly hard-coded rather
than flexible.

This change will need a mirror.apt volume and service/reprepro principal
and keytab to be created before it lands.

Allow for pool trimming after a 2 hour delay. Each devstack run of
apt-get update should be able to be assumed to be valid for the length
of the devstack. For that reason, only delete files that are
unreferenced during the subsequent mirror run, ensuring at least a 2
hour delay between becoming unreferenced and going away.

Local testing indicates that a trusty mirror is 86G.

Change-Id: I84f6a0391f80e6bf567c4bfc18a41bd270fe8c01
2016-02-05 10:50:04 -06:00

40 lines
1.3 KiB
Bash

#!/bin/bash
# Copyright 2016 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -e
UNREF_FILE=/var/run/reprepro/unreferenced-files
echo "Obtaining reprepro tokens and running reprepro update"
k5start -t -f /etc/reprepro.keytab service/reprepro -- timeout -k 2m 30m reprepro update
if [ -f $UNREF_FILE ] ; then
echo "Cleaning up files made unreferenced on the last run"
k5start -t -f /etc/reprepro.keytab service/reprepro -- timeout -k 2m 30m reprepro deleteifunreferenced < $UNREF_FILE
fi
echo "Saving list of newly unreferenced files for next time"
reprepro dumpunreferenced > $UNREF_FILE
echo "Checking state of mirror"
reprepro checkpool fast
reprepro check
echo "reprepro completed successfully, running reprepro export."
k5start -t -f /etc/afsadmin.keytab service/afsadmin -- vos release -v mirror.apt
echo "Done."