Convert into single docker image, change volume structure etc

Makefile inconsistent!
This commit is contained in:
2018-02-23 10:17:37 +01:00
parent 8c4f64cf96
commit 06437ac0b8
14 changed files with 104 additions and 161 deletions

30
dockerbin/cron-command Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# check lock
lock=/var/run/cloner.pid
dir_prefix=cloner
max_jobs=${JOBS:-3}
function die(){
echo $@ 1>&2
exit 1
}
# first, check process
if [ -f $lock ]
then
pid=$(cat $lock)
# if it still runs, die not so quietly
[ -n "$pid" ] && [ -d /proc/$pid ] && die "Another process running!"
fi
# else make some mess and setup trap
echo $BASHPID > $lock
find /data -maxdepth 1 -type d -name "${dir_prefix}-*" | \
parallel --lb -j $max_jobs -n 1 run-mirror-update

14
dockerbin/launch-cron Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# make parallel citation shut up
mkdir ~executor/.parallel
touch ~executor/.parallel/will-cite
# repair ownership
find /data \! -user executor -exec chown executor:executor {} \;
# run cron
crond -f

35
dockerbin/run-mirror-update Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
function log(){
local title=${raw:-$name}
[ -z "$title" ] || title=" [$title]"
echo "[$(date +"%X")]$title $@"
}
function die(){
log "$@" 1>&2
exit 1
}
scratch=$(mktemp -d -t tmp.XXXXXXXXXX)
function finish {
rm -rf "$scratch"
}
trap finish EXIT
# necessary checks
pathto=${1:-}
[ -n "$pathto" ] || die "No project specified"
raw=$(basename $pathto | sed 's/^cloner-//g')
# is it enabled?
[ -f "$pathto/.enabled" ] || die "$raw not enabled!"
env BASE=$pathto run-checker | while read line; do log "$line"; done