a6ece2cacc
If you are running these jobs by hand you are doing something that will be expected to take a long time (initial sync, recovery, etc.). Make these scripts assume interactivity and default to *not* running under timeout -- it's too easy to forget NO_TIMEOUT when running manually and having the job killed. We already have an UNDER_CRON variable set so that we only send stats when running ... under cron. Reuse this here for the timeout flag. Change-Id: Ic2d2f39bb18d247c853284512fe0dc37485c00a4
60 lines
1.9 KiB
Bash
60 lines
1.9 KiB
Bash
#!/bin/bash -e
|
|
|
|
# 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.
|
|
|
|
source /usr/share/mirror-update/functions.sh
|
|
|
|
# Runs with timeout under cron
|
|
if [[ ${UNDER_CRON:-0} -eq 0 ]]; then
|
|
echo_ts "Running interactively"
|
|
TIMEOUT=""
|
|
set -x
|
|
else
|
|
TIMEOUT="timeout -k 2m 90m"
|
|
fi
|
|
|
|
REPREPRO_CONFIG=$1
|
|
MIRROR_VOLUME=$2
|
|
BASE=$(cat ${REPREPRO_CONFIG}/options | grep base | cut -d' ' -f2)
|
|
CONFIG_KEY=$(basename $REPREPRO_CONFIG)
|
|
|
|
UNREF_FILE=/var/run/reprepro/${MIRROR_VOLUME}.${CONFIG_KEY}.unreferenced-files
|
|
K5START="k5start -t -f /etc/reprepro.keytab service/reprepro -- ${TIMEOUT} "
|
|
REPREPRO="$K5START reprepro --confdir $REPREPRO_CONFIG"
|
|
|
|
echo_ts "Obtaining reprepro tokens and running reprepro update"
|
|
$REPREPRO update
|
|
|
|
echo_ts "Explicitly generating dist indices just in case some are missing"
|
|
$REPREPRO export
|
|
|
|
if [ -f $UNREF_FILE ] ; then
|
|
echo_ts "Cleaning up files made unreferenced on the last run"
|
|
$REPREPRO deleteifunreferenced < $UNREF_FILE
|
|
fi
|
|
|
|
echo_ts "Saving list of newly unreferenced files for next time"
|
|
k5start -t -f /etc/reprepro.keytab service/reprepro -- bash -c "reprepro --confdir $REPREPRO_CONFIG dumpunreferenced > $UNREF_FILE"
|
|
|
|
echo_ts "Checking state of mirror"
|
|
$REPREPRO checkpool fast
|
|
$REPREPRO check
|
|
|
|
date --iso-8601=ns | $K5START tee $BASE/timestamp.txt
|
|
echo_ts "reprepro completed successfully, running vos release."
|
|
vos_release $MIRROR_VOLUME
|
|
|
|
echo_ts "Done."
|